Fall back to naive built-in byte-swap routines

EL5 lacks htobe64 and friends.  Using its byteswap.h requires an endianness
check in our headers, which is fragile and compiler-dependent.  It's a fair
amount of code [1], and is only useful on EL5.

So instead, let's include a fallback implementation of these functions, and use
it whenever we can't find the (now-)standard Linux or OS X routines.  The
fallback is endianness-independent and should work on any platform.

[1] https://github.com/rurban/mosh/commit/da1a5abd1e09f0c1e9295357bb480a643d9dc8e3
This commit is contained in:
Keegan McAllister
2012-04-13 16:44:00 -04:00
committed by Keith Winstein
parent 85d197346a
commit c2a5941f88
2 changed files with 73 additions and 1 deletions
+1 -1
View File
@@ -272,7 +272,7 @@ AC_CHECK_DECL([htobe64],
[AC_CHECK_DECL([OSSwapHostToBigInt64],
[AC_DEFINE([HAVE_OSX_SWAP], [1],
[Define if OSSwapHostToBigInt64 and friends exist.])],
[AC_MSG_ERROR([Unable to find byte swapping functions])],
[AC_MSG_WARN([Unable to find byte swapping functions; using built-in routines.])],
[[#include <libkern/OSByteOrder.h>]])],
[[#if defined(HAVE_ENDIAN_H)
#include <endian.h>