Lines Matching +full:value +full:- +full:start
1 /* SPDX-License-Identifier: GPL-2.0 */
13 * - Avoid multiple evaluations of the arguments (so side-effects like
14 * "x++" happen only once) when non-constant.
15 * - Retain result as a constant expressions when called with only
18 * - Perform signed v unsigned type-checking (to generate compile
20 * - Unsigned char/short are always promoted to signed int and can be
22 * - Unsigned arguments can be compared against non-negative signed constants.
23 * - Comparison of a signed argument against an unsigned constant fails
34 /* True for a non-negative signed int constant */
36 (__builtin_choose_expr(__is_constexpr(x) && __is_signed(x), x, -1) >= 0)
56 __builtin_choose_expr(__is_constexpr((x) - (y)), \
75 __builtin_choose_expr(__is_constexpr((val) - (lo) + (hi)), \
81 * min - return minimum of two values of the same or compatible types
82 * @x: first value
83 * @y: second value
88 * max - return maximum of two values of the same or compatible types
89 * @x: first value
90 * @y: second value
95 * umin - return minimum of two non-negative values
97 * @x: first value
98 * @y: second value
104 * umax - return maximum of two non-negative values
105 * @x: first value
106 * @y: second value
112 * min3 - return minimum of three values
113 * @x: first value
114 * @y: second value
115 * @z: third value
120 * max3 - return maximum of three values
121 * @x: first value
122 * @y: second value
123 * @z: third value
128 * min_not_zero - return the minimum that is _not_ zero, unless both are zero
138 * clamp - return a value clamped to a given range with strict typechecking
139 * @val: current value
140 * @lo: lowest allowable value
141 * @hi: highest allowable value
156 * min_t - return minimum of two values, using the specified type
158 * @x: first value
159 * @y: second value
164 * max_t - return maximum of two values, using the specified type
166 * @x: first value
167 * @y: second value
173 * In the following legit use-case where the "array" passed is a simple pointer,
175 * --- 8< ---
179 * --- 8< ---
191 __unqual_scalar_typeof(__array[0]) __element = __array[--__len];\
192 while (__len--) \
197 * min_array - return minimum of values present in an array
206 * max_array - return maximum of values present in an array
215 * clamp_t - return a value clamped to a given range using a given type
217 * @val: current value
218 * @lo: minimum allowable value
219 * @hi: maximum allowable value
227 * clamp_val - return a value clamped to a given range using val's type
228 * @val: current value
229 * @lo: minimum allowable value
230 * @hi: maximum allowable value
239 static inline bool in_range64(u64 val, u64 start, u64 len) in in_range64() argument
241 return (val - start) < len; in in_range64()
244 static inline bool in_range32(u32 val, u32 start, u32 len) in in_range32() argument
246 return (val - start) < len; in in_range32()
250 * in_range - Determine if a value lies within a range.
251 * @val: Value to test.
252 * @start: First value in range.
255 * This is more efficient than "if (start <= val && val < (start + len))".
256 * It also gives a different answer if @start + @len overflows the size of
258 * which behaviour you want, or prove that start + len never overflow.
261 #define in_range(val, start, len) \ argument
262 ((sizeof(start) | sizeof(len) | sizeof(val)) <= sizeof(u32) ? \
263 in_range32(val, start, len) : in_range64(val, start, len))
266 * swap - swap values of @a and @b
267 * @a: first value
268 * @b: second value