diff options
author | Felix Fietkau <nbd@nbd.name> | 2018-04-12 11:26:22 +0300 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2018-04-12 12:09:52 +0300 |
commit | 6eff829d788b36939325557066f58aafd6a05321 (patch) | |
tree | f1f5d07f43879eb81fc4a9cce3b841b184ea6b1f /utils.h | |
parent | ace64897d47b9bc7af277d8a3f8a0ff67976cba8 (diff) |
utils: fix build error with g++
g++ does not support __builtin_choose_expr, so we can't support
byte swapping as constant expression there.
Reported-by: Cleynhens Stijn <Stijn.Cleynhens@technicolor.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'utils.h')
-rw-r--r-- | utils.h | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -127,9 +127,18 @@ int clock_gettime(int type, struct timespec *tv); #define __eval_once(func, x) \ ({ __typeof__(x) __x = x; func(__x); }) +#ifdef __cplusplus +/* + * g++ does not support __builtin_choose_expr, so always use __eval_once. + * Unfortunately this means that the byte order functions can't be used + * as a constant expression anymore + */ +#define __eval_safe(func, x) __eval_once(func, x) +#else #define __eval_safe(func, x) \ __builtin_choose_expr(__is_constant(x), \ func(x), __eval_once(func, x)) +#endif #if __BYTE_ORDER == __LITTLE_ENDIAN |