[lttng-dev] [PATCH lttng-tools 21/24] Android : Adding bswap defintions

Charles Briere c.briere at samsung.com
Mon Oct 27 16:49:30 EDT 2014


From: Charles Briere <c.briere at samsung.com>

Mapping of bswap functions based on what's
available on Android's NDK

Signed-off-by: Charles Briere <c.briere at samsung.com>
---
 configure.ac               |  2 ++
 src/common/compat/endian.h | 11 ++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 45c6b30..91efd17 100644
--- a/configure.ac
+++ b/configure.ac
@@ -242,6 +242,8 @@ AC_CHECK_DECL([cmm_smp_mb__before_uatomic_or], [],
 
 AC_CHECK_DECLS([gettid], [], [], [[#include <unistd.h>]])
 
+AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64], [], [], [[#include <byteswap.h>]])
+
 # Check kmod library
 AC_ARG_WITH(kmod-prefix,
   AS_HELP_STRING([--with-kmod-prefix=PATH],
diff --git a/src/common/compat/endian.h b/src/common/compat/endian.h
index baea531..c03c231 100644
--- a/src/common/compat/endian.h
+++ b/src/common/compat/endian.h
@@ -21,11 +21,20 @@
 #ifdef __linux__
 #include <endian.h>
 
+#define HAVE_BSWAP (HAVE_DECL_BSWAP_16 && HAVE_DECL_BSWAP_32 && HAVE_DECL_BSWAP_64)
+#if HAVE_BSWAP
+# ifndef __bswap_16
+#  define __bswap_16(x) bswap_16(x)
+#  define __bswap_32(x) bswap_32(x)
+#  define __bswap_64(x) bswap_64(x)
+# endif
+#endif
+
 /*
  * htobe/betoh are not defined for glibc <2.9, so add them
  * explicitly if they are missing.
  */
-#ifdef __USE_BSD
+#if defined(__USE_BSD) || HAVE_BSWAP
 /* Conversion interfaces. */
 # include <byteswap.h>
 
-- 
2.1.2



More information about the lttng-dev mailing list