Message ID | 20190821171721.20048-1-blp@ovn.org |
---|---|
State | Accepted |
Headers | show |
Series | [ovs-dev] sat-math: Do not use __builtin_s*_overflow() with sparse. | expand |
> On Aug 21, 2019, at 10:17 AM, Ben Pfaff <blp@ovn.org> wrote: > > Some versions of sparse do not understand __builtin_saddll_overflow() and > related GCC builtins for calculations with overflow detection. This patch > avoids using them when sparse is in use. > > Reported-by: Justin Pettit <jpettit@ovn.org> > Tested-by: Justin Pettit <jpettit@ovn.org> > Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org> --Justin
On Wed, Aug 21, 2019 at 10:20:36AM -0700, Justin Pettit wrote: > > > > On Aug 21, 2019, at 10:17 AM, Ben Pfaff <blp@ovn.org> wrote: > > > > Some versions of sparse do not understand __builtin_saddll_overflow() and > > related GCC builtins for calculations with overflow detection. This patch > > avoids using them when sparse is in use. > > > > Reported-by: Justin Pettit <jpettit@ovn.org> > > Tested-by: Justin Pettit <jpettit@ovn.org> > > Signed-off-by: Ben Pfaff <blp@ovn.org> > > Acked-by: Justin Pettit <jpettit@ovn.org> Thanks, applied and backported.
diff --git a/lib/sat-math.h b/lib/sat-math.h index 8dda1515fdd0..d668723878db 100644 --- a/lib/sat-math.h +++ b/lib/sat-math.h @@ -41,7 +41,7 @@ llsat_add__(long long int x, long long int y) static inline long long int llsat_add(long long int x, long long int y) { -#if __GNUC__ >= 5 || __has_builtin(__builtin_saddll_overflow) +#if (__GNUC__ >= 5 || __has_builtin(__builtin_saddll_overflow)) && !__CHECKER__ long long int sum; return (!__builtin_saddll_overflow(x, y, &sum) ? sum : x > 0 ? LLONG_MAX : LLONG_MIN); @@ -67,7 +67,7 @@ llsat_sub__(long long int x, long long int y) static inline long long int llsat_sub(long long int x, long long int y) { -#if __GNUC__ >= 5 || __has_builtin(__builtin_ssubll_overflow) +#if (__GNUC__ >= 5 || __has_builtin(__builtin_ssubll_overflow)) && !__CHECKER__ long long int difference; return (!__builtin_ssubll_overflow(x, y, &difference) ? difference : x >= 0 ? LLONG_MAX : LLONG_MIN); @@ -97,7 +97,7 @@ llsat_mul__(long long int x, long long int y) static inline long long int llsat_mul(long long int x, long long int y) { -#if __GNUC__ >= 5 || __has_builtin(__builtin_smulll_overflow) +#if (__GNUC__ >= 5 || __has_builtin(__builtin_smulll_overflow)) && !__CHECKER__ long long int product; return (!__builtin_smulll_overflow(x, y, &product) ? product : (x > 0) == (y > 0) ? LLONG_MAX : LLONG_MIN);