diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-06-02 18:12:16 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-06-06 19:59:09 +0200 |
commit | c917a32122ac18c9b6112d67fbb815d84a053e4a (patch) | |
tree | 9dd8675e7792f75541c8c47e560063f34d087b77 /src/basic | |
parent | c9d81ae858cdf0482fa4c9c37e5f5e26d615e8c4 (diff) |
util-lib: add accessors for unaligned native endian words
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/unaligned.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/basic/unaligned.h b/src/basic/unaligned.h index 79be645bed..7c847a3ccb 100644 --- a/src/basic/unaligned.h +++ b/src/basic/unaligned.h @@ -109,3 +109,21 @@ static inline void unaligned_write_le64(void *_u, uint64_t a) { unaligned_write_le32(u, (uint32_t) a); unaligned_write_le32(u + 4, (uint32_t) (a >> 32)); } + +#if __BYTE_ORDER == __BIG_ENDIAN +#define unaligned_read_ne16 unaligned_read_be16 +#define unaligned_read_ne32 unaligned_read_be32 +#define unaligned_read_ne64 unaligned_read_be64 + +#define unaligned_write_ne16 unaligned_write_be16 +#define unaligned_write_ne32 unaligned_write_be32 +#define unaligned_write_ne64 unaligned_write_be64 +#else +#define unaligned_read_ne16 unaligned_read_le16 +#define unaligned_read_ne32 unaligned_read_le32 +#define unaligned_read_ne64 unaligned_read_le64 + +#define unaligned_write_ne16 unaligned_write_le16 +#define unaligned_write_ne32 unaligned_write_le32 +#define unaligned_write_ne64 unaligned_write_le64 +#endif |