-static inline uint16_t __u_bswap16(uint16_t val)
-{
- return ((val >> 8) & 0xffu) | ((val & 0xffu) << 8);
-}
+#define __eval_once(func, x) \
+ ({ __typeof__(x) __x = x; func(__x); })
+
+#define __eval_safe(func, x) \
+ __builtin_choose_expr(__is_constant(x), \
+ func(x), __eval_once(func, x))