xref: /openbsd-src/sys/dev/pci/drm/include/linux/math.h (revision c96eac12212738df022e8da546facc2482b97a41)
1f005ef32Sjsg /* Public domain. */
2f005ef32Sjsg 
3f005ef32Sjsg #ifndef _LINUX_MATH_H
4f005ef32Sjsg #define _LINUX_MATH_H
5f005ef32Sjsg 
6*c96eac12Sjsg #define mult_frac(x, n, d) (((x) * (n)) / (d))
7*c96eac12Sjsg 
8*c96eac12Sjsg #define round_up(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
9*c96eac12Sjsg #define round_down(x, y) (((x) / (y)) * (y)) /* y is power of two */
10*c96eac12Sjsg #define rounddown(x, y) (((x) / (y)) * (y)) /* arbitrary y */
11*c96eac12Sjsg #define DIV_ROUND_UP(x, y)	(((x) + ((y) - 1)) / (y))
12*c96eac12Sjsg #define DIV_ROUND_UP_ULL(x, y)	DIV_ROUND_UP(x, y)
13*c96eac12Sjsg #define DIV_ROUND_DOWN(x, y)	((x) / (y))
14*c96eac12Sjsg #define DIV_ROUND_DOWN_ULL(x, y)	DIV_ROUND_DOWN(x, y)
15*c96eac12Sjsg #define DIV_ROUND_CLOSEST(x, y)	(((x) + ((y) / 2)) / (y))
16*c96eac12Sjsg #define DIV_ROUND_CLOSEST_ULL(x, y)	DIV_ROUND_CLOSEST(x, y)
17*c96eac12Sjsg 
18f005ef32Sjsg #endif
19