diff options
| author | 2021-12-06 09:31:18 +0100 | |
|---|---|---|
| committer | 2021-12-06 09:31:18 +0100 | |
| commit | d598c3c46ea69ea974f0613a651cd4ef3be0c870 (patch) | |
| tree | 92c4b32aa13596484d81988f530d888586ff7c7a /tools/include/linux/math.h | |
| parent | usb: core: Fix file path that does not exist (diff) | |
| parent | Linux 5.16-rc4 (diff) | |
| download | wireguard-linux-d598c3c46ea69ea974f0613a651cd4ef3be0c870.tar.xz wireguard-linux-d598c3c46ea69ea974f0613a651cd4ef3be0c870.zip | |
Merge 5.16-rc4 into usb-next
We need the USB fixes in here as well.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/include/linux/math.h')
| -rw-r--r-- | tools/include/linux/math.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/include/linux/math.h b/tools/include/linux/math.h new file mode 100644 index 000000000000..4e7af99ec9eb --- /dev/null +++ b/tools/include/linux/math.h @@ -0,0 +1,25 @@ +#ifndef _TOOLS_MATH_H +#define _TOOLS_MATH_H + +/* + * This looks more complex than it should be. But we need to + * get the type for the ~ right in round_down (it needs to be + * as wide as the result!), and we want to evaluate the macro + * arguments just once each. + */ +#define __round_mask(x, y) ((__typeof__(x))((y)-1)) +#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) +#define round_down(x, y) ((x) & ~__round_mask(x, y)) + +#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) + +#ifndef roundup +#define roundup(x, y) ( \ +{ \ + const typeof(y) __y = y; \ + (((x) + (__y - 1)) / __y) * __y; \ +} \ +) +#endif + +#endif |
