Skip to content
Snippets Groups Projects
Commit a89ebcb7 authored by Avi Kivity's avatar Avi Kivity
Browse files

bsd: refine __ntohl() and friends as inline functions


inline functions can be overloaded and are less nasty than macros in other
ways (like evaluating their arguments only once).

Note we can't touch ntohl() itself, since it is defined to be an out-of-line
function by libc.

Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
parent a2866393
No related branches found
No related tags found
No related merge requests found
...@@ -296,10 +296,10 @@ ...@@ -296,10 +296,10 @@
#define __bswap16_const(_x) (__uint16_t)((_x) << 8 | (_x) >> 8) #define __bswap16_const(_x) (__uint16_t)((_x) << 8 | (_x) >> 8)
#define __htonl(x) __bswap32_const(x) static inline u_int32_t __htonl(u_int32_t x) { return __bswap32_const(x); }
#define __htons(x) __bswap16_const(x) static inline u_int16_t __htons(u_int16_t x) { return __bswap16_const(x); }
#define __ntohl(x) __bswap32_const(x) static inline u_int32_t __ntohl(u_int32_t x) { return __bswap32_const(x); }
#define __ntohs(x) __bswap16_const(x) static inline u_int16_t __ntohs(u_int16_t x) { return __bswap16_const(x); }
/* /*
* Basic byte order function prototypes for non-inline functions. * Basic byte order function prototypes for non-inline functions.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment