This source file includes following definitions.
- __ntohl
- __ntohs
1 #ifndef _ALPHA_BYTEORDER_H
2 #define _ALPHA_BYTEORDER_H
3
4 #undef ntohl
5 #undef ntohs
6 #undef htonl
7 #undef htons
8
9 #define LITTLE_ENDIAN
10 #define LITTLE_ENDIAN_BITFIELD
11
12 extern unsigned long int ntohl(unsigned long int);
13 extern unsigned short int ntohs(unsigned short int);
14 extern unsigned long int htonl(unsigned long int);
15 extern unsigned short int htons(unsigned short int);
16
17 extern unsigned long int __ntohl(unsigned long int);
18 extern unsigned short int __ntohs(unsigned short int);
19 extern unsigned long int __constant_ntohl(unsigned long int);
20 extern unsigned short int __constant_ntohs(unsigned short int);
21
22
23
24
25
26
27
28
29 extern __inline__ unsigned long int
30 __ntohl(unsigned long int x)
31 {
32 return (((x & 0x000000ffU) << 24) |
33 ((x & 0x0000ff00U) << 8) |
34 ((x & 0x00ff0000U) >> 8) |
35 ((x & 0xff000000U) >> 24));
36 }
37
38 #define __constant_ntohl(x) \
39 ((unsigned int)((((unsigned int)(x) & 0x000000ffU) << 24) | \
40 (((unsigned int)(x) & 0x0000ff00U) << 8) | \
41 (((unsigned int)(x) & 0x00ff0000U) >> 8) | \
42 (((unsigned int)(x) & 0xff000000U) >> 24)))
43
44 extern __inline__ unsigned short int
45 __ntohs(unsigned short int x)
46 {
47 return (((x & 0x00ff) << 8) |
48 ((x & 0xff00) >> 8));
49 }
50
51 #define __constant_ntohs(x) \
52 ((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \
53 (((unsigned short int)(x) & 0xff00) >> 8)))
54
55 #define __htonl(x) __ntohl(x)
56 #define __htons(x) __ntohs(x)
57 #define __constant_htonl(x) __constant_ntohl(x)
58 #define __constant_htons(x) __constant_ntohs(x)
59
60 #ifdef __OPTIMIZE__
61 # define ntohl(x) \
62 (__builtin_constant_p((long)(x)) ? \
63 __constant_ntohl((x)) : \
64 __ntohl((x)))
65 # define ntohs(x) \
66 (__builtin_constant_p((short)(x)) ? \
67 __constant_ntohs((x)) : \
68 __ntohs((x)))
69 # define htonl(x) \
70 (__builtin_constant_p((long)(x)) ? \
71 __constant_htonl((x)) : \
72 __htonl((x)))
73 # define htons(x) \
74 (__builtin_constant_p((short)(x)) ? \
75 __constant_htons((x)) : \
76 __htons((x)))
77 #endif
78
79 #endif