Adding upstream version 3.53.
[syslinux-debian/hramrach.git] / com32 / include / netinet / in.h
blob5fd71a6abe58780db30cf783d18b822c8a595bbc
1 #ifndef _NETINET_IN_H
2 #define _NETINET_IN_H
4 /* COM32 will be running on an i386 platform */
6 #include <stdint.h>
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);
23 } else {
24 asm("xchgb %h0,%b0 ; roll $16,%0 ; xchgb %h0,%b0" : "+abcd" (v));
25 return 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;
43 struct in_addr {
44 in_addr_t s_addr;
47 #endif /* _NETINET_IN_H */