Changeset 711e33fc in mainline
- Timestamp:
- 2008-04-02T20:39:04Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dfa7bac
- Parents:
- 0f718ab
- Location:
- uspace/lib/libc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/arch/amd64/include/endian.h
r0f718ab r711e33fc 46 46 /** @} 47 47 */ 48 49 -
uspace/lib/libc/include/endian.h
r0f718ab r711e33fc 38 38 #define __LITTLE_ENDIAN 1234 39 39 #define __BIG_ENDIAN 4321 40 #define __PDP_ENDIAN 341241 40 41 #include <stdint.h> 42 42 #include <libarch/endian.h> 43 44 #if (__BYTE_ORDER == __BIG_ENDIAN) 45 46 #define uint16_t_le2host(n) uint16_t_byteorder_swap(n) 47 #define uint32_t_le2host(n) uint32_t_byteorder_swap(n) 48 #define uint64_t_le2host(n) uint64_t_byteorder_swap(n) 49 50 #define uint16_t_be2host(n) (n) 51 #define uint32_t_be2host(n) (n) 52 #define uint64_t_be2host(n) (n) 53 54 #else 55 56 #define uint16_t_le2host(n) (n) 57 #define uint32_t_le2host(n) (n) 58 #define uint64_t_le2host(n) (n) 59 60 #define uint16_t_be2host(n) uint16_t_byteorder_swap(n) 61 #define uint32_t_be2host(n) uint32_t_byteorder_swap(n) 62 #define uint64_t_be2host(n) uint64_t_byteorder_swap(n) 63 64 #endif 65 66 67 static inline uint64_t uint64_t_byteorder_swap(uint64_t n) 68 { 69 return ((n & 0xff) << 56) | 70 ((n & 0xff00) << 40) | 71 ((n & 0xff0000) << 24) | 72 ((n & 0xff000000LL) << 8) | 73 ((n & 0xff00000000LL) >> 8) | 74 ((n & 0xff0000000000LL) >> 24) | 75 ((n & 0xff000000000000LL) >> 40) | 76 ((n & 0xff00000000000000LL) >> 56); 77 } 78 79 static inline uint32_t uint32_t_byteorder_swap(uint32_t n) 80 { 81 return ((n & 0xff) << 24) | 82 ((n & 0xff00) << 8) | 83 ((n & 0xff0000) >> 8) | 84 ((n & 0xff000000) >> 24); 85 } 86 87 static inline uint16_t uint16_t_byteorder_swap(uint16_t n) 88 { 89 return ((n & 0xff) << 8) | 90 ((n & 0xff00) >> 8); 91 } 43 92 44 93 #endif
Note:
See TracChangeset
for help on using the changeset viewer.