Lines Matching +full:two +full:- +full:dimensional
1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
16 * #define type_min(T) (T)(is_signed_type(T) ? (T)1 << (8*sizeof(T)-1) : 0)
17 * #define type_max(T) (T)(is_signed_type(T) ? ((T)1 << (8*sizeof(T)-1)) - 1 : ~(T)0)
21 * the type_max expression (but not if -fsanitize=undefined is in
27 * a-feature-not-a-bug, since people shouldn't be doing arithmetic on
32 * https://mail-index.netbsd.org/tech-misc/2007/02/05/0000.html -
35 #define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type)))
36 #define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T)))
37 #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
57 * check_add_overflow() - Calculate addition with overflow checking
65 * "safe for use" on a non-zero return value, which indicates that the
72 * check_sub_overflow() - Calculate subtraction with overflow checking
80 * "safe for use" on a non-zero return value, which indicates that the
87 * check_mul_overflow() - Calculate multiplication with overflow checking
95 * considered "safe for use" on a non-zero return value, which indicates
102 * check_shl_overflow() - Calculate a left-shifted value and check overflow
112 * - '@a << @s' causes bits to be lost when stored in *@d.
113 * - '@s' is garbage (e.g. negative) or so large that the result of
115 * - '@a' is negative.
116 * - '@a << @s' sets the sign bit, if any, in '*@d'.
146 * overflows_type - helper for checking the overflows between value, variables,
165 * castable_to_type - like __same_type(), but also allows for casted literals
181 * size_mul() - Calculate size_t multiplication with saturation at SIZE_MAX
200 * size_add() - Calculate size_t addition with saturation at SIZE_MAX
219 * size_sub() - Calculate size_t subtraction with saturation at SIZE_MAX
223 * Returns: calculate @minuend - @subtrahend, both promoted to size_t,
241 * array_size() - Calculate size of 2-dimensional array.
243 * @b: dimension two
245 * Calculates size of 2-dimensional array: @a * @b.
253 * array3_size() - Calculate size of 3-dimensional array.
255 * @b: dimension two
258 * Calculates size of 3-dimensional array: @a * @b * @c.
266 * flex_array_size() - Calculate size of a flexible array member
279 (count) * sizeof(*(p)->member) + __must_be_array((p)->member), \
280 size_mul(count, sizeof(*(p)->member) + __must_be_array((p)->member)))
283 * struct_size() - Calculate size of structure with trailing flexible array.
299 * struct_size_t() - Calculate size of structure with trailing flexible array
315 * _DEFINE_FLEX() - helper macro for DEFINE_FLEX() family.
321 * @count: Number of elements in the array; must be compile-time const.
326 "onstack flex array members require compile-time const count"); \
334 * DEFINE_FLEX() - Define an on-stack instance of structure with a trailing
340 * @count: Number of elements in the array; must be compile-time const.
342 * Define a zeroed, on-stack, instance of @type structure with a trailing
344 * Use __struct_size(@name) to get compile-time size of it afterwards.