Commit b372a443 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use overflow built-ins also on clang

They were already available as of version 3.4.0.
parent a4f2b08c
......@@ -664,7 +664,7 @@ static inline uint64_t (bswap64)(uint64_t x)
/* Integer overflow */
static inline bool uadd_overflow(unsigned a, unsigned b, unsigned *res)
{
#ifdef __GNUC__
#if defined(__GNUC__) || defined(__clang__)
return __builtin_uadd_overflow(a, b, res);
#else
*res = a + b;
......@@ -675,7 +675,7 @@ static inline bool uadd_overflow(unsigned a, unsigned b, unsigned *res)
static inline bool uaddl_overflow(unsigned long a, unsigned long b,
unsigned long *res)
{
#ifdef __GNUC__
#if defined(__GNUC__) || defined(__clang__)
return __builtin_uaddl_overflow(a, b, res);
#else
*res = a + b;
......@@ -686,7 +686,7 @@ static inline bool uaddl_overflow(unsigned long a, unsigned long b,
static inline bool uaddll_overflow(unsigned long long a, unsigned long long b,
unsigned long long *res)
{
#ifdef __GNUC__
#if defined(__GNUC__) || defined(__clang__)
return __builtin_uaddll_overflow(a, b, res);
#else
*res = a + b;
......@@ -721,7 +721,7 @@ static inline bool add_overflow(unsigned long long a, unsigned long long b,
static inline bool umul_overflow(unsigned a, unsigned b, unsigned *res)
{
#ifdef __GNUC__
#if defined(__GNUC__) || defined(__clang__)
return __builtin_umul_overflow(a, b, res);
#else
*res = a * b;
......@@ -732,7 +732,7 @@ static inline bool umul_overflow(unsigned a, unsigned b, unsigned *res)
static inline bool umull_overflow(unsigned long a, unsigned long b,
unsigned long *res)
{
#ifdef __GNUC__
#if defined(__GNUC__) || defined(__clang__)
return __builtin_umull_overflow(a, b, res);
#else
*res = a * b;
......@@ -743,7 +743,7 @@ static inline bool umull_overflow(unsigned long a, unsigned long b,
static inline bool umulll_overflow(unsigned long long a, unsigned long long b,
unsigned long long *res)
{
#ifdef __GNUC__
#if defined(__GNUC__) || defined(__clang__)
return __builtin_umulll_overflow(a, b, res);
#else
*res = a * b;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment