diff options
author | Casey Barker <crbarker@google.com> | 2011-08-04 16:18:59 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2011-08-04 16:20:04 -0700 |
commit | 43d1478b1690ecd0ef6b63890bc13438c1914e47 (patch) | |
tree | 122b7ece40701cc950390e1a6dc3f56f83cb46f0 /lib/hash.h | |
parent | c71c6043a7617e6e6c2b8748550014f54476faa7 (diff) |
lib: Adapt headers for use in C++.
This commit makes several library headers suitable for inclusion in C++.
It adds [extern "C"] guards and makes minor changes to fix casting and
keyword issues.
Diffstat (limited to 'lib/hash.h')
-rw-r--r-- | lib/hash.h | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -22,6 +22,10 @@ #include <string.h> #include "util.h" +#ifdef __cplusplus +extern "C" { +#endif + /* This is the public domain lookup3 hash by Bob Jenkins from * http://burtleburtle.net/bob/c/lookup3.c, modified for style. */ @@ -81,8 +85,8 @@ static inline uint32_t hash_int(uint32_t x, uint32_t basis) * quality. */ static inline uint32_t hash_boolean(bool x, uint32_t basis) { - enum { P0 = 0xc2b73583 }; /* This is hash_int(1, 0). */ - enum { P1 = 0xe90f1258 }; /* This is hash_int(2, 0). */ + const uint32_t P0 = 0xc2b73583; /* This is hash_int(1, 0). */ + const uint32_t P1 = 0xe90f1258; /* This is hash_int(2, 0). */ return (x ? P0 : P1) ^ HASH_ROT(basis, 1); } @@ -108,4 +112,8 @@ static inline uint32_t hash_pointer(const void *p, uint32_t basis) return hash_int((uint32_t) (uintptr_t) p, basis); } +#ifdef __cplusplus +} +#endif + #endif /* hash.h */ |