utils: add const_* byteswapping functions
Some gcc versions have issues with the __builtin_choose_expr construct which attempts to automatically use the const versions of those functions. Make it possible to explicitly use const_* versions to avoid that. Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
6eff829d78
commit
3c1b33b7d5
1 changed files with 32 additions and 0 deletions
32
utils.h
32
utils.h
|
@ -142,6 +142,22 @@ int clock_gettime(int type, struct timespec *tv);
|
|||
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
|
||||
#define const_cpu_to_be64(x) __constant_swap64(x)
|
||||
#define const_cpu_to_be32(x) __constant_swap32(x)
|
||||
#define const_cpu_to_be16(x) __constant_swap16(x)
|
||||
|
||||
#define const_be64_to_cpu(x) __constant_swap64(x)
|
||||
#define const_be32_to_cpu(x) __constant_swap32(x)
|
||||
#define const_be16_to_cpu(x) __constant_swap16(x)
|
||||
|
||||
#define const_cpu_to_le64(x) (x)
|
||||
#define const_cpu_to_le32(x) (x)
|
||||
#define const_cpu_to_le16(x) (x)
|
||||
|
||||
#define const_le64_to_cpu(x) (x)
|
||||
#define const_le32_to_cpu(x) (x)
|
||||
#define const_le16_to_cpu(x) (x)
|
||||
|
||||
#define cpu_to_be64(x) __eval_safe(__constant_swap64, x)
|
||||
#define cpu_to_be32(x) __eval_safe(__constant_swap32, x)
|
||||
#define cpu_to_be16(x) __eval_safe(__constant_swap16, x)
|
||||
|
@ -160,6 +176,22 @@ int clock_gettime(int type, struct timespec *tv);
|
|||
|
||||
#else /* __BYTE_ORDER == __LITTLE_ENDIAN */
|
||||
|
||||
#define const_cpu_to_le64(x) __constant_swap64(x)
|
||||
#define const_cpu_to_le32(x) __constant_swap32(x)
|
||||
#define const_cpu_to_le16(x) __constant_swap16(x)
|
||||
|
||||
#define const_le64_to_cpu(x) __constant_swap64(x)
|
||||
#define const_le32_to_cpu(x) __constant_swap32(x)
|
||||
#define const_le16_to_cpu(x) __constant_swap16(x)
|
||||
|
||||
#define const_cpu_to_be64(x) (x)
|
||||
#define const_cpu_to_be32(x) (x)
|
||||
#define const_cpu_to_be16(x) (x)
|
||||
|
||||
#define const_be64_to_cpu(x) (x)
|
||||
#define const_be32_to_cpu(x) (x)
|
||||
#define const_be16_to_cpu(x) (x)
|
||||
|
||||
#define cpu_to_le64(x) __eval_safe(__constant_swap64, x)
|
||||
#define cpu_to_le32(x) __eval_safe(__constant_swap32, x)
|
||||
#define cpu_to_le16(x) __eval_safe(__constant_swap16, x)
|
||||
|
|
Loading…
Reference in a new issue