[vlc-commits] Use overflow built-ins also on clang

Rémi Denis-Courmont git at videolan.org
Sun Nov 12 18:07:51 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Nov 12 19:07:15 2017 +0200| [b372a4430de8e8ce583662c5ccd52470dfd16f20] | committer: Rémi Denis-Courmont

Use overflow built-ins also on clang

They were already available as of version 3.4.0.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b372a4430de8e8ce583662c5ccd52470dfd16f20
---

 include/vlc_common.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/vlc_common.h b/include/vlc_common.h
index 8c89aef556..7c7c764fd7 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -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;



More information about the vlc-commits mailing list