From da257afe5777e1bcf3b6b01e2355252be956b511 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 25 Sep 2013 09:26:36 +0200 Subject: [PATCH] htonu64() and ntohu64 added to endianconv.h. --- src/endianconv.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/endianconv.h b/src/endianconv.h index 7afe61c62..7c16e175f 100644 --- a/src/endianconv.h +++ b/src/endianconv.h @@ -61,4 +61,14 @@ uint64_t intrev64(uint64_t v); #define intrev64ifbe(v) intrev64(v) #endif +/* The functions htonu64() and ntohu64() convert the specified value to + * network byte ordering and back. In big endian systems they are no-ops. */ +#if (BYTE_ORDER == BIG_ENDIAN) +#define htonu64(v) (v) +#define ntohu64(v) (v) +#else +#define htonu64(v) intrev64(v) +#define ntohu64(v) intrev64(v) +#endif + #endif