btrfs-progs: kernel-lib: add stubs for overflow builtins

Some older compilers do not support overflow builtins introduced in
5ad2aacd24 ("btrfs-progs: kernel-lib: sync include/overflow.h"). Add
stubs to make it compile. This fixes CI build of Centos 7.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2022-07-28 00:37:20 +02:00
parent ad1ed616f1
commit 1781549688
1 changed files with 16 additions and 0 deletions

View File

@ -57,6 +57,22 @@ static inline bool __must_check __must_check_overflow(bool overflow)
return overflow;
}
/*
* Stubs for compiler without the overflow builtin support, no actual checks
* are done.
*/
#if !HAVE___BUILTIN_ADD_OVERFLOW
#define __builtin_add_overflow(__a, __b, __d) (*(__d) = (__a) + (__b), 0)
#endif
#if !HAVE___BUILTIN_MUL_OVERFLOW
#define __builtin_mul_overflow(__a, __b, __d) (*(__d) = (__a) * (__b), 0)
#endif
#if !HAVE___BUILTIN_MUL_OVERFLOW
#define __builtin_sub_overflow(__a, __b, __d) (*(__d) = (__a) - (__b), 0)
#endif
/*
* For simplicity and code hygiene, the fallback code below insists on
* a, b and *d having the same type (similar to the min() and max()