diff options
| author | gkostka <kostka.grzegorz@gmail.com> | 2015-11-24 07:33:19 +0100 |
|---|---|---|
| committer | gkostka <kostka.grzegorz@gmail.com> | 2015-11-24 07:39:48 +0100 |
| commit | 1fcbe7f294d68c54752ab7a255a62a8dddd0b6a7 (patch) | |
| tree | 6cf90a4a2322ffede2744008ba775f52873b83c1 | |
| parent | 5dfdaf27ae4bdfab84d4853612b21e460fbd1c75 (diff) | |
Change duplicated functions (to_le*/to_be*) to reorder*
to_le*/to_be* now are macros with suitable endianes expansion
| -rw-r--r-- | lwext4/ext4_types.h | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/lwext4/ext4_types.h b/lwext4/ext4_types.h index fc576db..46bb166 100644 --- a/lwext4/ext4_types.h +++ b/lwext4/ext4_types.h @@ -1090,27 +1090,38 @@ struct jbd_fs { #define EXT4_CRC32_INIT (0xFFFFFFFFUL) /*****************************************************************************/ -#ifdef CONFIG_BIG_ENDIAN -static inline uint64_t to_le64(uint64_t n) + +static inline uint64_t reorder64(uint64_t n) { - return ((n & 0xff) << 56) | ((n & 0xff00) << 40) | - ((n & 0xff0000) << 24) | ((n & 0xff000000LL) << 8) | - ((n & 0xff00000000LL) >> 8) | ((n & 0xff0000000000LL) >> 24) | + return ((n & 0xff) << 56) | + ((n & 0xff00) << 40) | + ((n & 0xff0000) << 24) | + ((n & 0xff000000LL) << 8) | + ((n & 0xff00000000LL) >> 8) | + ((n & 0xff0000000000LL) >> 24) | ((n & 0xff000000000000LL) >> 40) | ((n & 0xff00000000000000LL) >> 56); } -static inline uint32_t to_le32(uint32_t n) +static inline uint32_t reorder32(uint32_t n) { - return ((n & 0xff) << 24) | ((n & 0xff00) << 8) | - ((n & 0xff0000) >> 8) | ((n & 0xff000000) >> 24); + return ((n & 0xff) << 24) | + ((n & 0xff00) << 8) | + ((n & 0xff0000) >> 8) | + ((n & 0xff000000) >> 24); } -static inline uint16_t to_le16(uint16_t n) +static inline uint16_t reorder16(uint16_t n) { - return ((n & 0xff) << 8) | ((n & 0xff00) >> 8); + return ((n & 0xff) << 8) | + ((n & 0xff00) >> 8); } +#ifdef CONFIG_BIG_ENDIAN +#define to_le64(_n) reorder64(_n) +#define to_le32(_n) reorder32(_n) +#define to_le16(_n) reorder16(_n) + #define to_be64(_n) _n #define to_be32(_n) _n #define to_be16(_n) _n @@ -1120,26 +1131,9 @@ static inline uint16_t to_le16(uint16_t n) #define to_le32(_n) _n #define to_le16(_n) _n -static inline uint64_t to_be64(uint64_t n) -{ - return ((n & 0xff) << 56) | ((n & 0xff00) << 40) | - ((n & 0xff0000) << 24) | ((n & 0xff000000LL) << 8) | - ((n & 0xff00000000LL) >> 8) | ((n & 0xff0000000000LL) >> 24) | - ((n & 0xff000000000000LL) >> 40) | - ((n & 0xff00000000000000LL) >> 56); -} - -static inline uint32_t to_be32(uint32_t n) -{ - return ((n & 0xff) << 24) | ((n & 0xff00) << 8) | - ((n & 0xff0000) >> 8) | ((n & 0xff000000) >> 24); -} - -static inline uint16_t to_be16(uint16_t n) -{ - return ((n & 0xff) << 8) | ((n & 0xff00) >> 8); -} - +#define to_be64(_n) reorder64(_n) +#define to_be32(_n) reorder32(_n) +#define to_be16(_n) reorder16(_n) #endif /****************************Access macros to ext4 structures*****************/ |
