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