syslinux-3.08-2 sources from FC4
[bootcd.git] / syslinux / com32 / include / netinet / in.h
1 #ifndef _NETINET_IN_H
2 #define _NETINET_IN_H
3
4 /* COM32 will be running on an i386 platform */
5
6 #include <stdint.h>
7
8 static inline uint16_t __htons(uint16_t v)
9 {
10   return ((v) << 8) | ((v) >> 8);
11 }
12
13 #define htons(x) __htons(x)
14 #define ntohs(x) __htons(x)
15
16 static inline uint32_t __htonl(uint32_t v)
17 {
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;
26   }
27 }
28
29 #define htonl(x) __htonl(x)
30 #define ntohl(x) __htonl(x)
31
32 static inline uint64_t __htonq(uint64_t v)
33 {
34   return ((uint64_t) __htonl(v) << 32) | __htonl(v >> 32);
35 }
36
37 #define htonq(x) __htonq(x)
38 #define ntohq(x) __htonq(x)
39
40 #endif /* _NETINET_IN_H */
41
42
43