diff options
author | dimitri staessens <[email protected]> | 2017-06-05 19:17:30 +0000 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-06-05 19:17:30 +0000 |
commit | 3fde03d682361af24019b4a4f446fc887ddd7f79 (patch) | |
tree | 6658cfb2281db84cf4e050391fef3a666471a4ce /include | |
parent | d38da8b1deae62a57d24e7da94a9c25abbf2f438 (diff) | |
parent | ea1248d40a0c68f3e6cf09d03354f7a5fc6e2612 (diff) | |
download | ouroboros-3fde03d682361af24019b4a4f446fc887ddd7f79.tar.gz ouroboros-3fde03d682361af24019b4a4f446fc887ddd7f79.zip |
Merged in dstaesse/ouroboros/be-macro (pull request #514)
include: Fix macro for printing hash
Diffstat (limited to 'include')
-rw-r--r-- | include/ouroboros/endian.h | 6 | ||||
-rw-r--r-- | include/ouroboros/hash.h | 11 |
2 files changed, 12 insertions, 5 deletions
diff --git a/include/ouroboros/endian.h b/include/ouroboros/endian.h index 4738159e..16200028 100644 --- a/include/ouroboros/endian.h +++ b/include/ouroboros/endian.h @@ -26,9 +26,15 @@ #if defined(__linux__) || defined(__CYGWIN__) +#ifndef _BSD_SOURCE #define _BSD_SOURCE +#endif +#ifndef __USE_BSD #define __USE_BSD +#endif +#ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE +#endif #include <endian.h> #include <features.h> diff --git a/include/ouroboros/hash.h b/include/ouroboros/hash.h index de3ce541..eeca8a28 100644 --- a/include/ouroboros/hash.h +++ b/include/ouroboros/hash.h @@ -24,6 +24,7 @@ #ifndef OUROBOROS_LIB_HASH_H #define OUROBOROS_LIB_HASH_H +#include <ouroboros/endian.h> #include <ouroboros/ipcp.h> #include <ouroboros/crc32.h> @@ -32,11 +33,11 @@ #define HASH_FMT "%02x%02x%02x%02x" -#define HASH_VAL(hash) \ - ((*(unsigned int *) hash) & 0xFF000000) >> 24, \ - ((*(unsigned int *) hash) & 0x00FF0000) >> 16, \ - ((*(unsigned int *) hash) & 0x0000FF00) >> 8, \ - ((*(unsigned int *) hash) & 0x000000FF) +#define HASH_VAL(hash) \ + (betoh32(*(uint32_t *) hash) & 0xFF000000) >> 24, \ + (betoh32(*(uint32_t *) hash) & 0x00FF0000) >> 16, \ + (betoh32(*(uint32_t *) hash) & 0x0000FF00) >> 8, \ + (betoh32(*(uint32_t *) hash) & 0x000000FF) uint16_t hash_len(enum hash_algo algo); |