Lines Matching +full:x +full:- +full:y
1 /* SPDX-License-Identifier: GPL-2.0 */
15 #define __round_mask(x, y) ((__typeof__(x))((y)-1)) argument
18 * round_up - round up to next specified power of 2
19 * @x: the value to round
20 * @y: multiple to round up to (must be a power of 2)
22 * Rounds @x up to next multiple of @y (which must be a power of 2).
25 #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) argument
28 * round_down - round down to next specified power of 2
29 * @x: the value to round
30 * @y: multiple to round down to (must be a power of 2)
32 * Rounds @x down to next multiple of @y (which must be a power of 2).
35 #define round_down(x, y) ((x) & ~__round_mask(x, y)) argument
43 DIV_ROUND_DOWN_ULL((unsigned long long)(ll) + (d) - 1, (d))
52 * roundup - round up to the next specified multiple
53 * @x: the value to up
54 * @y: multiple to round up to
56 * Rounds @x up to next multiple of @y. If @y will always be a power
59 #define roundup(x, y) ( \ argument
61 typeof(y) __y = y; \
62 (((x) + (__y - 1)) / __y) * __y; \
66 * rounddown - round down to next specified multiple
67 * @x: the value to round
68 * @y: multiple to round down to
70 * Rounds @x down to next multiple of @y. If @y will always be a power
73 #define rounddown(x, y) ( \ argument
75 typeof(x) __x = (x); \
76 __x - (__x % (y)); \
86 #define DIV_ROUND_CLOSEST(x, divisor)( \ argument
88 typeof(x) __x = x; \
90 (((typeof(x))-1) > 0 || \
91 ((typeof(divisor))-1) > 0 || \
94 (((__x) - ((__d) / 2)) / (__d)); \
98 * Same as above but for u64 dividends. divisor must be a 32-bit
101 #define DIV_ROUND_CLOSEST_ULL(x, divisor)( \ argument
104 unsigned long long _tmp = (x) + (__d) / 2; \
121 /* Calculate "x * n / d" without unnecessary overflow or loss of precision. */ in __STRUCT_FRACT()
122 #define mult_frac(x, n, d) \ in __STRUCT_FRACT() argument
124 typeof(x) x_ = (x); \ in __STRUCT_FRACT()
136 * abs - return absolute value of an argument
137 * @x: the value. If it is unsigned type, it is converted to signed type first.
141 * Return: an absolute value of x.
143 #define abs(x) __abs_choose_expr(x, long long, \ argument
144 __abs_choose_expr(x, long, \
145 __abs_choose_expr(x, int, \
146 __abs_choose_expr(x, short, \
147 __abs_choose_expr(x, char, \
149 __builtin_types_compatible_p(typeof(x), char), \
150 (char)({ signed char __x = (x); __x<0?-__x:__x; }), \
153 #define __abs_choose_expr(x, type, other) __builtin_choose_expr( \ argument
154 __builtin_types_compatible_p(typeof(x), signed type) || \
155 __builtin_types_compatible_p(typeof(x), unsigned type), \
156 ({ signed type __x = (x); __x < 0 ? -__x : __x; }), other)
159 * abs_diff - return absolute value of the difference between the arguments
174 __a > __b ? (__a - __b) : (__b - __a); \
178 * reciprocal_scale - "scale" a value into range [0, ep_ro)
183 * range [0, @ep_ro), where the upper interval endpoint is right-open.
200 u32 int_sqrt64(u64 x);
202 static inline u32 int_sqrt64(u64 x) in int_sqrt64() argument
204 return (u32)int_sqrt(x); in int_sqrt64()