]> git.ozlabs.org Git - ccan/commitdiff
hash: use config.h settings for endian.
authorRusty Russell <rusty@rustcorp.com.au>
Sat, 2 Apr 2011 01:36:49 +0000 (12:06 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Sat, 2 Apr 2011 01:36:49 +0000 (12:06 +1030)
Leave old hacky #ifdef tests there for reference.

ccan/hash/hash.c
ccan/hash/hash.h

index a9948821227899190dae5e79c63cb435e7d5d575..4fe5cfe67c3f27c196964d5e00796ba80db49c67 100644 (file)
@@ -40,9 +40,7 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
 #include <time.h>       /* defines time_t for timings in the test */
 #include <stdint.h>     /* defines uint32_t etc */
 #include <sys/param.h>  /* attempt to define endianness */
-#endif
 
-#include "hash.h"
 #ifdef linux
 # include <endian.h>    /* attempt to define endianness */
 #endif
@@ -66,6 +64,19 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
 #else
 # error Unknown endian
 #endif
+#endif /* old hash.c headers. */
+
+#include "hash.h"
+
+#if HAVE_LITTLE_ENDIAN
+#define HASH_LITTLE_ENDIAN 1
+#define HASH_BIG_ENDIAN 0
+#elif HAVE_BIG_ENDIAN
+#define HASH_LITTLE_ENDIAN 0
+#define HASH_BIG_ENDIAN 1
+#else
+#error Unknown endian
+#endif
 
 #define hashsize(n) ((uint32_t)1<<(n))
 #define hashmask(n) (hashsize(n)-1)
index 3db75753fb503d5fd9b5284a2e6e0698bdf63b26..0400e6a3b29bbc4505e707ed5231ed197ad6f22a 100644 (file)
@@ -1,8 +1,8 @@
 #ifndef CCAN_HASH_H
 #define CCAN_HASH_H
+#include "config.h"
 #include <stdint.h>
 #include <stdlib.h>
-#include "config.h"
 #include <ccan/build_assert/build_assert.h>
 
 /* Stolen mostly from: lookup3.c, by Bob Jenkins, May 2006, Public Domain.