From ffeb285f7bf6856b2ce1c2f5bdbec0f06322f384 Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Mon, 10 Jun 2013 22:27:57 -0400 Subject: [PATCH] [libfko] handle endian detection on PPC (and other) systems Blair Zajac contributed a patch to handle endian detection on PPC systems and issue a compile time error if it cannot be determined. This commit affects the BYTEORDER macro. --- CREDITS | 6 ++++++ lib/fko_common.h | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CREDITS b/CREDITS index 96eccac2..58708a32 100644 --- a/CREDITS +++ b/CREDITS @@ -140,3 +140,9 @@ hlein - Suggested the ability to read a passphrase from STDIN and via a new --fd command line argument (github #74) to allow things like: $ gpg -d passphrasefile.pgp | fwknop -R -n myserver + +Blair Zajac + - Contributed patches to handle endian issues on PPC systems. + - Reported an issue where strndup() is not available on some PPC systems + and the fix is to use the local lib/fko_util.c implementation similarly + to Windows builds. diff --git a/lib/fko_common.h b/lib/fko_common.h index 24bb14c1..76dbac72 100644 --- a/lib/fko_common.h +++ b/lib/fko_common.h @@ -100,9 +100,23 @@ #define BYTEORDER 4321 #elif defined(_LITTLE_ENDIAN) #define BYTEORDER 1234 - #else - #error unable to determine BYTEORDER #endif +#elif defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__) + #if defined(__i386__) || defined(__ppc__) + #define BYTEORDER 4321 + #elif defined(__x86_64__) || defined(__ppc64) + #define BYTEORDER 87654321 + #endif +#elif defined(_LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN__) + #if defined(__i386__) || defined(__ppc__) + #define BYTEORDER 1234 + #elif defined(__x86_64__) || defined(__ppc64) + #define BYTEORDER 12345678 + #endif +#endif + +#ifndef BYTEORDER + #error unable to determine BYTEORDER #endif #ifdef WIN32