[vlc-commits] include: protect generic integer functions

Rémi Denis-Courmont git at videolan.org
Tue Oct 4 16:40:49 CEST 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Oct  4 17:22:59 2016 +0300| [4b85d992d6dea96f79accdf0e711598615b9e165] | committer: Rémi Denis-Courmont

include: protect generic integer functions

Those generic possibly built-in (else inline) functions are not
name-spaced, so make sure we don´t explode if the OS headers clobber
the namespace and define any of them as macros.

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

 include/vlc_common.h | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/include/vlc_common.h b/include/vlc_common.h
index 159d4ff..a9683d6 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -537,7 +537,7 @@ static inline uint8_t clip_uint8_vlc( int32_t a )
 
 /** Count leading zeroes */
 VLC_USED
-static inline unsigned clz (unsigned x)
+static inline unsigned (clz)(unsigned x)
 {
 #if VLC_GCC_VERSION(3,4)
     return __builtin_clz (x);
@@ -560,7 +560,7 @@ static inline unsigned clz (unsigned x)
 
 /** Count trailing zeroes */
 VLC_USED
-static inline unsigned ctz (unsigned x)
+static inline unsigned (ctz)(unsigned x)
 {
 #if VLC_GCC_VERSION(3,4)
     return __builtin_ctz (x);
@@ -578,7 +578,7 @@ static inline unsigned ctz (unsigned x)
 
 /** Bit weight */
 VLC_USED
-static inline unsigned popcount (unsigned x)
+static inline unsigned (popcount)(unsigned x)
 {
 #if VLC_GCC_VERSION(3,4)
     return __builtin_popcount (x);
@@ -595,7 +595,7 @@ static inline unsigned popcount (unsigned x)
 
 /** Bit weight of long long */
 VLC_USED
-static inline int popcountll(unsigned long long x)
+static inline int (popcountll)(unsigned long long x)
 {
 #if VLC_GCC_VERSION(3,4)
     return __builtin_popcountll(x);
@@ -611,7 +611,7 @@ static inline int popcountll(unsigned long long x)
 }
 
 VLC_USED
-static inline unsigned parity (unsigned x)
+static inline unsigned (parity)(unsigned x)
 {
 #if VLC_GCC_VERSION(3,4)
     return __builtin_parity (x);
@@ -622,22 +622,16 @@ static inline unsigned parity (unsigned x)
 #endif
 }
 
-#ifdef __OS2__
-#   undef bswap16
-#   undef bswap32
-#   undef bswap64
-#endif
-
 /** Byte swap (16 bits) */
 VLC_USED
-static inline uint16_t bswap16 (uint16_t x)
+static inline uint16_t (bswap16)(uint16_t x)
 {
     return (x << 8) | (x >> 8);
 }
 
 /** Byte swap (32 bits) */
 VLC_USED
-static inline uint32_t bswap32 (uint32_t x)
+static inline uint32_t (bswap32)(uint32_t x)
 {
 #if VLC_GCC_VERSION(4,3) || defined(__clang__)
     return __builtin_bswap32 (x);
@@ -651,7 +645,7 @@ static inline uint32_t bswap32 (uint32_t x)
 
 /** Byte swap (64 bits) */
 VLC_USED
-static inline uint64_t bswap64 (uint64_t x)
+static inline uint64_t (bswap64)(uint64_t x)
 {
 #if VLC_GCC_VERSION(4,3) || defined(__clang__)
     return __builtin_bswap64 (x);



More information about the vlc-commits mailing list