summaryrefslogtreecommitdiff
path: root/src/lib/eina/eina_inline_cpu.x
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/eina/eina_inline_cpu.x')
-rw-r--r--src/lib/eina/eina_inline_cpu.x14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/lib/eina/eina_inline_cpu.x b/src/lib/eina/eina_inline_cpu.x
index 0dd293c..da10760 100644
--- a/src/lib/eina/eina_inline_cpu.x
+++ b/src/lib/eina/eina_inline_cpu.x
@@ -23,6 +23,14 @@
23#ifndef EINA_INLINE_CPU_X_ 23#ifndef EINA_INLINE_CPU_X_
24#define EINA_INLINE_CPU_X_ 24#define EINA_INLINE_CPU_X_
25 25
26#ifdef __has_builtin
27# define EINA_HAS_BUILTIN(x) __has_builtin(x)
28#elif (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
29# define EINA_HAS_BUILTIN(x) 1
30#else
31# define EINA_HAS_BUILTIN(x) 0 // Compatibility for the rest of the world
32#endif
33
26#ifdef EINA_HAVE_BYTESWAP_H 34#ifdef EINA_HAVE_BYTESWAP_H
27# include <byteswap.h> 35# include <byteswap.h>
28#endif 36#endif
@@ -30,7 +38,7 @@
30static inline unsigned short 38static inline unsigned short
31eina_swap16(unsigned short x) 39eina_swap16(unsigned short x)
32{ 40{
33#if defined EINA_HAVE_BSWAP16 41#if EINA_HAS_BUILTIN(__builtin_bswap16)
34 return __builtin_bswap16(x); 42 return __builtin_bswap16(x);
35#elif defined _MSC_VER /* Windows. Apparently in <stdlib.h>. */ 43#elif defined _MSC_VER /* Windows. Apparently in <stdlib.h>. */
36 return _byteswap_ushort(x); 44 return _byteswap_ushort(x);
@@ -45,7 +53,7 @@ eina_swap16(unsigned short x)
45static inline unsigned int 53static inline unsigned int
46eina_swap32(unsigned int x) 54eina_swap32(unsigned int x)
47{ 55{
48#ifdef EINA_HAVE_BSWAP32 56#if EINA_HAS_BUILTIN(__builtin_bswap32)
49 return __builtin_bswap32(x); 57 return __builtin_bswap32(x);
50#elif defined _MSC_VER /* Windows. Apparently in <stdlib.h>. */ 58#elif defined _MSC_VER /* Windows. Apparently in <stdlib.h>. */
51 return _byteswap_ulong(x); 59 return _byteswap_ulong(x);
@@ -62,7 +70,7 @@ eina_swap32(unsigned int x)
62static inline unsigned long long 70static inline unsigned long long
63eina_swap64(unsigned long long x) 71eina_swap64(unsigned long long x)
64{ 72{
65#ifdef EINA_HAVE_BSWAP64 73#if EINA_HAS_BUILTIN(__builtin_bswap64)
66 return __builtin_bswap64(x); 74 return __builtin_bswap64(x);
67#elif defined _MSC_VER /* Windows. Apparently in <stdlib.h>. */ 75#elif defined _MSC_VER /* Windows. Apparently in <stdlib.h>. */
68 return _byteswap_uint64(x); 76 return _byteswap_uint64(x);