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 * - Perform signed v unsigned type-checking (to generate compile
17 * - Unsigned char/short are always promoted to signed int and can be
19 * - Unsigned arguments can be compared against non-negative signed constants.
20 * - Comparison of a signed argument against an unsigned constant fails
31 * In particular, statically non-negative signed integer expressions
39 * that contains the value.
42 * value (but without evaluating it for side effects!
53 * Check whether a signed value is always non-negative.
58 * On 64-bit any integer or pointer type can safely be cast to 'long long'.
59 * But on 32-bit we need to avoid warnings about casting pointers to integers
60 * of different sizes without truncating 64-bit values so 'long' or 'long long'
61 * must be used depending on the size of the value.
63 * This does not work for 128-bit signed integers since the cast would truncate
101 * min - return minimum of two values of the same or compatible types
102 * @x: first value
103 * @y: second value
108 * max - return maximum of two values of the same or compatible types
109 * @x: first value
110 * @y: second value
115 * umin - return minimum of two non-negative values
117 * @x: first value
118 * @y: second value
124 * umax - return maximum of two non-negative values
125 * @x: first value
126 * @y: second value
138 * min3 - return minimum of three values
139 * @x: first value
140 * @y: second value
141 * @z: third value
147 * max3 - return maximum of three values
148 * @x: first value
149 * @y: second value
150 * @z: third 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
172 * min_not_zero - return the minimum that is _not_ zero, unless both are zero
198 * clamp - return a value clamped to a given range with typechecking
199 * @val: current value
200 * @lo: lowest allowable value
201 * @hi: highest allowable value
209 * clamp_t - return a value clamped to a given range using a given type
211 * @val: current value
212 * @lo: minimum allowable value
213 * @hi: maximum allowable value
221 * clamp_val - return a value clamped to a given range using val's type
222 * @val: current value
223 * @lo: minimum allowable value
224 * @hi: maximum allowable value
235 * In the following legit use-case where the "array" passed is a simple pointer,
237 * --- 8< ---
241 * --- 8< ---
253 __unqual_scalar_typeof(__array[0]) __element = __array[--__len];\
254 while (__len--) \
259 * min_array - return minimum of values present in an array
268 * max_array - return maximum of values present in an array
276 static inline bool in_range64(u64 val, u64 start, u64 len) in in_range64() argument
278 return (val - start) < len; in in_range64()
281 static inline bool in_range32(u32 val, u32 start, u32 len) in in_range32() argument
283 return (val - start) < len; in in_range32()
287 * in_range - Determine if a value lies within a range.
288 * @val: Value to test.
289 * @start: First value in range.
292 * This is more efficient than "if (start <= val && val < (start + len))".
293 * It also gives a different answer if @start + @len overflows the size of
295 * which behaviour you want, or prove that start + len never overflow.
298 #define in_range(val, start, len) \ argument
299 ((sizeof(start) | sizeof(len) | sizeof(val)) <= sizeof(u32) ? \
300 in_range32(val, start, len) : in_range64(val, start, len))
303 * swap - swap values of @a and @b
304 * @a: first value
305 * @b: second value