utils: make le16 endian conversion functions work with arguments that have side effects
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
This commit is contained in:
parent
fcd5ba8fbd
commit
bd47d85d38
1 changed files with 1 additions and 1 deletions
2
utils.h
2
utils.h
|
@ -99,7 +99,7 @@ void clock_gettime(int type, struct timespec *tv);
|
||||||
#define __LITTLE_ENDIAN LITTLE_ENDIAN
|
#define __LITTLE_ENDIAN LITTLE_ENDIAN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define __u_bswap16(x) ((uint16_t)((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)))
|
#define __u_bswap16(x) ({ uint16_t val = (x); ((uint16_t)(((val >> 8) & 0xffu) | ((val & 0xffu) << 8))); })
|
||||||
|
|
||||||
#if _GNUC_MIN_VER(4, 2)
|
#if _GNUC_MIN_VER(4, 2)
|
||||||
#define __u_bswap32(x) __builtin_bswap32(x)
|
#define __u_bswap32(x) __builtin_bswap32(x)
|
||||||
|
|
Loading…
Reference in a new issue