4 /* COM32 will be running on an i386 platform */
8 static inline uint16_t __htons(uint16_t v
)
10 return ((v
) << 8) | ((v
) >> 8);
13 #define htons(x) __htons(x)
14 #define ntohs(x) __htons(x)
16 static inline uint32_t __htonl(uint32_t v
)
18 if ( __builtin_constant_p(v
) ) {
19 return (((v
) & 0x000000ff) << 24) |
20 (((v
) & 0x0000ff00) << 8) |
21 (((v
) & 0x00ff0000) >> 8) |
22 (((v
) & 0xff000000) >> 24);
24 asm("xchgb %h0,%b0 ; roll $16,%0 ; xchgb %h0,%b0" : "+abcd" (v
));
29 #define htonl(x) __htonl(x)
30 #define ntohl(x) __htonl(x)
32 static inline uint64_t __htonq(uint64_t v
)
34 return ((uint64_t) __htonl(v
) << 32) | __htonl(v
>> 32);
37 #define htonq(x) __htonq(x)
38 #define ntohq(x) __htonq(x)
40 typedef uint32_t in_addr_t
;
41 typedef uint16_t in_port_t
;
47 #endif /* _NETINET_IN_H */