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
Tested-by: Aliaksey Kandratsenka <>
Tested-by: Aaron Miller <>
Reviewed-by: Damien Katz <>
Reviewed-by: Aaron Miller <>
  • Loading branch information...
Aliaksey Kandratsenka authored and alk committed Sep 14, 2012
1 parent b5937c4 commit 1968315932616118aaf7ec26b73607d7a3cacffb
Showing with 6 additions and 0 deletions.
  1. +6 −0 config_static.h
@@ -59,6 +59,12 @@
#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)
#define ntohll(a) couchstore_byteswap64(a)
#define htonll(a) couchstore_byteswap64(a)

0 comments on commit 1968315

Please sign in to comment.