diff options
| author | 2009-05-15 09:07:06 -0400 | |
|---|---|---|
| committer | 2009-05-15 10:37:10 -0400 | |
| commit | 8d626d6a48871fdb62b8adeea98e1299eca61184 (patch) | |
| tree | bd7acdb12c4c33debf1e579be311b524713cce59 /include/utils/ByteOrder.h | |
| parent | dff73b85fef1000571f558314ca5161ed1b67ac0 (diff) | |
Implement the C++ class to write the backed up file data.
Diffstat (limited to 'include/utils/ByteOrder.h')
| -rw-r--r-- | include/utils/ByteOrder.h | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/include/utils/ByteOrder.h b/include/utils/ByteOrder.h index 4c0606763d..baa3a83ddd 100644 --- a/include/utils/ByteOrder.h +++ b/include/utils/ByteOrder.h @@ -38,6 +38,16 @@ * intent is to allow us to avoid byte swapping on the device. */ +static inline uint32_t android_swap_long(uint32_t v) +{ + return (v<<24) | ((v<<8)&0x00FF0000) | ((v>>8)&0x0000FF00) | (v>>24); +} + +static inline uint16_t android_swap_short(uint16_t v) +{ + return (v<<8) | (v>>8); +} + #define DEVICE_BYTE_ORDER LITTLE_ENDIAN #if BYTE_ORDER == DEVICE_BYTE_ORDER @@ -49,16 +59,6 @@ #else -static inline uint32_t android_swap_long(uint32_t v) -{ - return (v<<24) | ((v<<8)&0x00FF0000) | ((v>>8)&0x0000FF00) | (v>>24); -} - -static inline uint16_t android_swap_short(uint16_t v) -{ - return (v<<8) | (v>>8); -} - #define dtohl(x) (android_swap_long(x)) #define dtohs(x) (android_swap_short(x)) #define htodl(x) (android_swap_long(x)) @@ -66,4 +66,16 @@ static inline uint16_t android_swap_short(uint16_t v) #endif +#if BYTE_ORDER == LITTLE_ENDIAN +#define fromlel(x) (x) +#define fromles(x) (x) +#define tolel(x) (x) +#define toles(x) (x) +#else +#define fromlel(x) (android_swap_long(x)) +#define fromles(x) (android_swap_short(x)) +#define tolel(x) (android_swap_long(x)) +#define toles(x) (android_swap_short(x)) +#endif + #endif // _LIBS_UTILS_BYTE_ORDER_H |