mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
Merge tag 'bitmap-for-6.14' of https://github.com:/norov/linux
Pull bitmap updates from Yury Norov: "This includes const_true() series from Vincent Mailhol, another __always_inline rework from Nathan Chancellor for RISCV, and a couple of random fixes from Dr. David Alan Gilbert and I Hsin Cheng" * tag 'bitmap-for-6.14' of https://github.com:/norov/linux: cpumask: Rephrase comments for cpumask_any*() APIs cpu: Remove unused init_cpu_online riscv: Always inline bitops linux/bits.h: simplify GENMASK_INPUT_CHECK() compiler.h: add const_true()
This commit is contained in:
@@ -307,6 +307,28 @@ static inline void *offset_to_ptr(const int *off)
|
||||
*/
|
||||
#define statically_true(x) (__builtin_constant_p(x) && (x))
|
||||
|
||||
/*
|
||||
* Similar to statically_true() but produces a constant expression
|
||||
*
|
||||
* To be used in conjunction with macros, such as BUILD_BUG_ON_ZERO(),
|
||||
* which require their input to be a constant expression and for which
|
||||
* statically_true() would otherwise fail.
|
||||
*
|
||||
* This is a trade-off: const_true() requires all its operands to be
|
||||
* compile time constants. Else, it would always returns false even on
|
||||
* the most trivial cases like:
|
||||
*
|
||||
* true || non_const_var
|
||||
*
|
||||
* On the opposite, statically_true() is able to fold more complex
|
||||
* tautologies and will return true on expressions such as:
|
||||
*
|
||||
* !(non_const_var * 8 % 4)
|
||||
*
|
||||
* For the general case, statically_true() is better.
|
||||
*/
|
||||
#define const_true(x) __builtin_choose_expr(__is_constexpr(x), x, false)
|
||||
|
||||
/*
|
||||
* This is needed in functions which generate the stack canary, see
|
||||
* arch/x86/kernel/smpboot.c::start_secondary() for an example.
|
||||
|
||||
Reference in New Issue
Block a user