Adding upstream version 4.00~pre53+dfsg.
[syslinux-debian/hramrach.git] / com32 / include / netinet / in.h
blobccf04750d585d413a40cf49721353ba6ed25ecf4
1 #ifndef _NETINET_IN_H
2 #define _NETINET_IN_H
4 /* COM32 will be running on an i386 platform */
6 #include <stdint.h>
7 #include <klibc/compiler.h>
9 #define __htons_macro(v) ((uint16_t) \
10 (((uint16_t)(v) << 8) | \
11 ((uint16_t)(v) >> 8)))
13 static inline __constfunc uint16_t __htons(uint16_t v)
15 return __htons_macro(v);
18 #define htons(x) (__builtin_constant_p(x) ? __htons_macro(x) : __htons(x))
19 #define ntohs(x) htons(x)
21 #define __htonl_macro(v) ((uint32_t) \
22 ((((uint32_t)(v) & 0x000000ff) << 24) | \
23 (((uint32_t)(v) & 0x0000ff00) << 8) | \
24 (((uint32_t)(v) & 0x00ff0000) >> 8) | \
25 (((uint32_t)(v) & 0xff000000) >> 24)))
27 static inline __constfunc uint32_t __htonl(uint32_t v)
29 asm("xchgb %h0,%b0 ; roll $16,%0 ; xchgb %h0,%b0"
30 : "+q" (v));
31 return v;
34 #define htonl(x) (__builtin_constant_p(x) ? __htonl_macro(x) : __htonl(x))
35 #define ntohl(x) htonl(x)
37 #define __htonq_macro(v) ((uint64_t) \
38 (((uint64_t)__htonl_macro((uint32_t)(v)) << 32) | \
39 (__htonl_macro((uint32_t)((uint64_t)(v) >> 32)))))
41 static inline __constfunc uint64_t __htonq(uint64_t v)
43 return ((uint64_t)__htonl(v) << 32) | __htonl(v >> 32);
46 #define htonq(x) (__builtin_constant_p(x) ? __htonq_macro(x) : __htonq(x))
47 #define ntohq(x) htonq(x)
49 typedef uint32_t in_addr_t;
50 typedef uint16_t in_port_t;
52 struct in_addr {
53 in_addr_t s_addr;
56 #endif /* _NETINET_IN_H */