Rev 2071 | Rev 2797 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2071 | Rev 2794 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | #define KERN_BYTEORDER_H_ |
36 | #define KERN_BYTEORDER_H_ |
37 | 37 | ||
38 | static inline uint64_t uint64_t_byteorder_swap(uint64_t n) |
38 | static inline uint64_t uint64_t_byteorder_swap(uint64_t n) |
39 | { |
39 | { |
40 | return ((n & 0xff) << 56) | |
40 | return ((n & 0xff) << 56) | |
41 | ((n & 0xff00) << 40) | |
41 | ((n & 0xff00) << 40) | |
42 | ((n & 0xff0000) << 24) | |
42 | ((n & 0xff0000) << 24) | |
43 | ((n & 0xff000000LL) << 8) | |
43 | ((n & 0xff000000LL) << 8) | |
44 | ((n & 0xff00000000LL) >> 8) | |
44 | ((n & 0xff00000000LL) >> 8) | |
45 | ((n & 0xff0000000000LL) >> 24) | |
45 | ((n & 0xff0000000000LL) >> 24) | |
46 | ((n & 0xff000000000000LL) >> 40) | |
46 | ((n & 0xff000000000000LL) >> 40) | |
47 | ((n & 0xff00000000000000LL) >> 56); |
47 | ((n & 0xff00000000000000LL) >> 56); |
48 | } |
48 | } |
49 | 49 | ||
50 | static inline uint32_t uint32_t_byteorder_swap(uint32_t n) |
50 | static inline uint32_t uint32_t_byteorder_swap(uint32_t n) |
51 | { |
51 | { |
52 | return ((n & 0xff) << 24) | |
52 | return ((n & 0xff) << 24) | |
53 | ((n & 0xff00) << 8) | |
53 | ((n & 0xff00) << 8) | |
54 | ((n & 0xff0000) >> 8) | |
54 | ((n & 0xff0000) >> 8) | |
55 | ((n & 0xff000000) >> 24); |
55 | ((n & 0xff000000) >> 24); |
- | 56 | } |
|
- | 57 | ||
- | 58 | static inline uint16_t uint16_t_byteorder_swap(uint16_t n) |
|
- | 59 | { |
|
- | 60 | return ((n & 0xff) << 8) | |
|
- | 61 | ((n & 0xff00) >> 8); |
|
56 | } |
62 | } |
57 | 63 | ||
58 | #endif |
64 | #endif |
59 | 65 | ||
60 | /** @} |
66 | /** @} |