vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Thu Nov 23 
22:09:17 2017 +0200| [12efcaae59cd6b4b141a43edd45c028e9a1160eb] | committer: 
Rémi Denis-Courmont

include: guard overflow builtins

Pointed-out-by: KO Myung-Hun <[email protected]>

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

 include/vlc_common.h | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/include/vlc_common.h b/include/vlc_common.h
index 6364afd44f..936df33bb6 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -47,7 +47,6 @@
 #include <stdio.h>
 #include <inttypes.h>
 #include <stddef.h>
-#include <limits.h>
 
 #ifndef __cplusplus
 # include <stdbool.h>
@@ -654,7 +653,7 @@ static inline uint64_t (bswap64)(uint64_t x)
 /* Integer overflow */
 static inline bool uadd_overflow(unsigned a, unsigned b, unsigned *res)
 {
-#if defined(__GNUC__) || defined(__clang__)
+#if VLC_GCC_VERSION(5,0) || defined(__clang__)
      return __builtin_uadd_overflow(a, b, res);
 #else
      *res = a + b;
@@ -665,7 +664,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)
 {
-#if defined(__GNUC__) || defined(__clang__)
+#if VLC_GCC_VERSION(5,0) || defined(__clang__)
      return __builtin_uaddl_overflow(a, b, res);
 #else
      *res = a + b;
@@ -676,7 +675,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)
 {
-#if defined(__GNUC__) || defined(__clang__)
+#if VLC_GCC_VERSION(5,0) || defined(__clang__)
      return __builtin_uaddll_overflow(a, b, res);
 #else
      *res = a + b;
@@ -709,9 +708,13 @@ static inline bool add_overflow(unsigned long long a, 
unsigned long long b,
 }
 #endif
 
+#if !(VLC_GCC_VERSION(5,0) || defined(__clang__))
+# include <limits.h>
+#endif
+
 static inline bool umul_overflow(unsigned a, unsigned b, unsigned *res)
 {
-#if defined(__GNUC__) || defined(__clang__)
+#if VLC_GCC_VERSION(5,0) || defined(__clang__)
      return __builtin_umul_overflow(a, b, res);
 #else
      *res = a * b;
@@ -722,7 +725,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)
 {
-#if defined(__GNUC__) || defined(__clang__)
+#if VLC_GCC_VERSION(5,0) || defined(__clang__)
      return __builtin_umull_overflow(a, b, res);
 #else
      *res = a * b;
@@ -733,7 +736,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)
 {
-#if defined(__GNUC__) || defined(__clang__)
+#if VLC_GCC_VERSION(5,0) || defined(__clang__)
      return __builtin_umulll_overflow(a, b, res);
 #else
      *res = a * b;

_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to