Linus Torvalds writes: (Summary) We were so myopically
staring at the __builtin_choose_expr() problem that we overlooked the
obvious solution.
obvious solution.
Using __builtin_constant_p() together with a ?: is in fact our common pattern, so that should be fine. The only real reason to use __builtin_choose_expr() is if you want to get the *type* to vary depending on which side you choose, but that's not an issue for min/max.
min/max.
There should be none. Gcc will turn the conditional for the ?: into a constant, and DTRT.
constant, and DTRT.
Linus
Linus
Linus
obvious solution.
Using __builtin_constant_p() together with a ?: is in fact our common pattern, so that should be fine. The only real reason to use __builtin_choose_expr() is if you want to get the *type* to vary depending on which side you choose, but that's not an issue for min/max.
min/max.
[...]
What will be the runtime effects?There should be none. Gcc will turn the conditional for the ?: into a constant, and DTRT.
constant, and DTRT.
Linus
Linus
Linus