Lines Matching +full:in +full:- +full:and +full:- +full:around

1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
10 * We need to compute the minimum and maximum values representable in a given
14 * #define type_min(T) (T)(is_signed_type(T) ? (T)1 << (8*sizeof(T)-1) : 0)
15 * #define type_max(T) (T)(is_signed_type(T) ? ((T)1 << (8*sizeof(T)-1)) - 1 : ~(T)0)
18 * undefined behaviour, and at least some versions of gcc warn about
19 * the type_max expression (but not if -fsanitize=undefined is in
20 * effect; in that case, the warning is deferred to runtime...).
22 * The slightly excessive casting in type_min is to make sure the
25 * a-feature-not-a-bug, since people shouldn't be doing arithmetic on
30 * https://mail-index.netbsd.org/tech-misc/2007/02/05/0000.html -
33 #define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type)))
34 #define __type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T)))
36 #define __type_min(T) ((T)((T)-type_max(T)-(T)1))
40 * Avoids triggering -Wtype-limits compilation warning,
48 * both the type-agnostic benefits of the macros while also being able to
49 * enforce that the return value is, in fact, checked.
57 * check_add_overflow() - Calculate addition with overflow checking
62 * Returns true on wrap-around, false otherwise.
65 * wrap-around occurred.
71 * wrapping_add() - Intentionally perform a wrapping addition
76 * Return the potentially wrapped-around addition without
77 * tripping any wrap-around sanitizers that may be enabled.
87 * wrapping_assign_add() - Intentionally perform a wrapping increment assignment
91 * Increments @var by @offset with wrap-around. Returns the resulting
92 * value of @var. Will not trip any wrap-around sanitizers.
103 * check_sub_overflow() - Calculate subtraction with overflow checking
108 * Returns true on wrap-around, false otherwise.
111 * wrap-around occurred.
117 * wrapping_sub() - Intentionally perform a wrapping subtraction
122 * Return the potentially wrapped-around subtraction without
123 * tripping any wrap-around sanitizers that may be enabled.
133 * wrapping_assign_sub() - Intentionally perform a wrapping decrement assign
137 * Decrements @var by @offset with wrap-around. Returns the resulting
138 * value of @var. Will not trip any wrap-around sanitizers.
149 * check_mul_overflow() - Calculate multiplication with overflow checking
154 * Returns true on wrap-around, false otherwise.
157 * wrap-around occurred.
163 * wrapping_mul() - Intentionally perform a wrapping multiplication
168 * Return the potentially wrapped-around multiplication without
169 * tripping any wrap-around sanitizers that may be enabled.
179 * check_shl_overflow() - Calculate a left-shifted value and check overflow
189 * - '@a << @s' causes bits to be lost when stored in *@d.
190 * - '@s' is garbage (e.g. negative) or so large that the result of
192 * - '@a' is negative.
193 * - '@a << @s' sets the sign bit, if any, in '*@d'.
223 * overflows_type - helper for checking the overflows between value, variables,
229 * Compares the @x expression for whether or not it can safely fit in
230 * the storage of the type in @T. @x and @T can have different types.
242 * castable_to_type - like __same_type(), but also allows for casted literals
258 * size_mul() - Calculate size_t multiplication with saturation at SIZE_MAX
277 * size_add() - Calculate size_t addition with saturation at SIZE_MAX
296 * size_sub() - Calculate size_t subtraction with saturation at SIZE_MAX
300 * Returns: calculate @minuend - @subtrahend, both promoted to size_t,
302 * composition with the size_add() and size_mul() helpers, neither
318 * array_size() - Calculate size of 2-dimensional array.
322 * Calculates size of 2-dimensional array: @a * @b.
330 * array3_size() - Calculate size of 3-dimensional array.
335 * Calculates size of 3-dimensional array: @a * @b * @c.
343 * flex_array_size() - Calculate size of a flexible array member
347 * @count: Number of elements in the array.
356 (count) * sizeof(*(p)->member) + __must_be_array((p)->member), \
357 size_mul(count, sizeof(*(p)->member) + __must_be_array((p)->member)))
360 * struct_size() - Calculate size of structure with trailing flexible array.
363 * @count: Number of elements in the array.
376 * struct_size_t() - Calculate size of structure with trailing flexible array
379 * @count: Number of elements in the array.
392 * _DEFINE_FLEX() - helper macro for DEFINE_FLEX() family.
398 * @count: Number of elements in the array; must be compile-time const.
403 "onstack flex array members require compile-time const count"); \
411 * DEFINE_RAW_FLEX() - Define an on-stack instance of structure with a trailing
417 * @count: Number of elements in the array; must be compile-time const.
419 * Define a zeroed, on-stack, instance of @type structure with a trailing
421 * Use __struct_size(@name) to get compile-time size of it afterwards.
427 * DEFINE_FLEX() - Define an on-stack instance of structure with a trailing
434 * @COUNT: Number of elements in the array; must be compile-time const.
436 * Define a zeroed, on-stack, instance of @TYPE structure with a trailing
438 * Use __struct_size(@NAME) to get compile-time size of it afterwards.