Skip to content
Browse files

MB-100: use optimized 64-bit byteswap code on GNU/Linux

glibc does not have htonll but it does have bswap_64 as well as bsd's
htobe64. bswap_64 is more than good enough.

Change-Id: Iab325a0a5872d3a9379dac565ea177fe4bf6d9cb
Reviewed-on: http://review.couchbase.org/21493
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aaron Miller <apage43@ninjawhale.com>
Reviewed-by: Damien Katz <damien@couchbase.com>
Reviewed-by: Aaron Miller <apage43@ninjawhale.com>
  • Loading branch information...
1 parent b5937c4 commit 1968315932616118aaf7ec26b73607d7a3cacffb Aliaksey Kandratsenka committed with alk
Showing with 6 additions and 0 deletions.
  1. +6 −0 config_static.h
View
6 config_static.h
@@ -59,6 +59,12 @@
#ifdef WORDS_BIGENDIAN
#define ntohll(a) a
#define htonll(a) a
+#elif defined(__GLIBC__)
+#define HAVE_HTONLL 1
+/* GNU libc does have bswap which is optimized implementation */
+#include <byteswap.h>
+#define ntohll(a) bswap_64(a)
+#define htonll(a) bswap_64(a)
#else
#define ntohll(a) couchstore_byteswap64(a)
#define htonll(a) couchstore_byteswap64(a)

0 comments on commit 1968315

Please sign in to comment.
Something went wrong with that request. Please try again.