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