byteorder: Simplify htoun64/untoh64 functions
authorTobias Brunner <tobias@strongswan.org>
Fri, 4 Mar 2016 09:15:49 +0000 (10:15 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 4 Mar 2016 17:43:26 +0000 (18:43 +0100)
src/libstrongswan/utils/utils/byteorder.h

index 53ec177..c3c0e67 100644 (file)
@@ -112,21 +112,8 @@ static inline void htoun64(void *network, u_int64_t host)
 {
        char *unaligned = (char*)network;
 
-#ifdef be64toh
        host = htobe64(host);
        memcpy((char*)unaligned, &host, sizeof(host));
-#else
-       u_int32_t high_part, low_part;
-
-       high_part = host >> 32;
-       high_part = htonl(high_part);
-       low_part  = host & 0xFFFFFFFFLL;
-       low_part  = htonl(low_part);
-
-       memcpy(unaligned, &high_part, sizeof(high_part));
-       unaligned += sizeof(high_part);
-       memcpy(unaligned, &low_part, sizeof(low_part));
-#endif
 }
 
 /**
@@ -168,24 +155,10 @@ static inline u_int32_t untoh32(void *network)
 static inline u_int64_t untoh64(void *network)
 {
        char *unaligned = (char*)network;
-
-#ifdef be64toh
        u_int64_t tmp;
 
        memcpy(&tmp, unaligned, sizeof(tmp));
        return be64toh(tmp);
-#else
-       u_int32_t high_part, low_part;
-
-       memcpy(&high_part, unaligned, sizeof(high_part));
-       unaligned += sizeof(high_part);
-       memcpy(&low_part, unaligned, sizeof(low_part));
-
-       high_part = ntohl(high_part);
-       low_part  = ntohl(low_part);
-
-       return (((u_int64_t)high_part) << 32) + low_part;
-#endif
 }
 
 /**