eina: unbreak byteswap checks

For one, eina_config.h.in is never used by anything since meson,
so doing any checks in it and expecting them to work is wrong.
Byteswaps are one place where this is the case, so move the
checks back in their appropriate place.
This commit is contained in:
Daniel Kolesa 2019-10-23 15:44:22 +02:00
parent 69b1b1cc3e
commit 84251f9f00
2 changed files with 11 additions and 37 deletions

View File

@ -23,14 +23,6 @@
# include <Exotic.h>
#endif
#ifdef __has_builtin
# define EINA_HAS_BUILTIN(x) __has_builtin(x)
#elif (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
# define EINA_HAS_BUILTIN(x) 1
#else
# define EINA_HAS_BUILTIN(x) 0 // Compatibility for the rest of the world
#endif
#ifdef EINA_MAGIC_DEBUG
# undef EINA_MAGIC_DEBUG
#endif
@ -95,32 +87,6 @@
#endif
@EINA_CONFIGURE_HAVE_ALLOCA_H@
#ifdef EINA_HAVE_BSWAP16
# undef EINA_HAVE_BSWAP16
#endif
#if EINA_HAS_BUILTIN(__builtin_bswap16)
# define EINA_HAVE_BSWAP16
#endif
#ifdef EINA_HAVE_BSWAP32
# undef EINA_HAVE_BSWAP32
#endif
#if EINA_HAS_BUILTIN(__builtin_bswap32)
# define EINA_HAVE_BSWAP32
#endif
#ifdef EINA_HAVE_BSWAP64
# undef EINA_HAVE_BSWAP64
#endif
#if EINA_HAS_BUILTIN(__builtin_bswap64)
# define EINA_HAVE_BSWAP64
#endif
#ifdef EINA_HAVE_BYTESWAP_H
# undef EINA_HAVE_BYTESWAP_H
#endif
@EINA_CONFIGURE_HAVE_BYTESWAP_H@
#ifdef EINA_HAVE_POSIX_SPINLOCK
# undef EINA_HAVE_POSIX_SPINLOCK
#endif

View File

@ -23,6 +23,14 @@
#ifndef EINA_INLINE_CPU_X_
#define EINA_INLINE_CPU_X_
#ifdef __has_builtin
# define EINA_HAS_BUILTIN(x) __has_builtin(x)
#elif (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
# define EINA_HAS_BUILTIN(x) 1
#else
# define EINA_HAS_BUILTIN(x) 0 // Compatibility for the rest of the world
#endif
#ifdef EINA_HAVE_BYTESWAP_H
# include <byteswap.h>
#endif
@ -30,7 +38,7 @@
static inline unsigned short
eina_swap16(unsigned short x)
{
#if defined EINA_HAVE_BSWAP16
#if EINA_HAS_BUILTIN(__builtin_bswap16)
return __builtin_bswap16(x);
#elif defined _MSC_VER /* Windows. Apparently in <stdlib.h>. */
return _byteswap_ushort(x);
@ -45,7 +53,7 @@ eina_swap16(unsigned short x)
static inline unsigned int
eina_swap32(unsigned int x)
{
#ifdef EINA_HAVE_BSWAP32
#if EINA_HAS_BUILTIN(__builtin_bswap32)
return __builtin_bswap32(x);
#elif defined _MSC_VER /* Windows. Apparently in <stdlib.h>. */
return _byteswap_ulong(x);
@ -62,7 +70,7 @@ eina_swap32(unsigned int x)
static inline unsigned long long
eina_swap64(unsigned long long x)
{
#ifdef EINA_HAVE_BSWAP64
#if EINA_HAS_BUILTIN(__builtin_bswap64)
return __builtin_bswap64(x);
#elif defined _MSC_VER /* Windows. Apparently in <stdlib.h>. */
return _byteswap_uint64(x);