xref: /openbsd/sys/dev/pci/drm/include/linux/align.h (revision c96eac12)
1 /* Public domain. */
2 
3 #ifndef _LINUX_ALIGN_H
4 #define _LINUX_ALIGN_H
5 
6 #include <sys/param.h>
7 
8 #define roundup2(x, y) (((x) + ((y) - 1)) & (~((__typeof(x))(y) - 1)))
9 #define rounddown2(x, y) ((x) & ~((__typeof(x))(y) - 1))
10 
11 #undef ALIGN
12 #define ALIGN(x, y) roundup2((x), (y))
13 
14 #define IS_ALIGNED(x, y)	(((x) & ((y) - 1)) == 0)
15 #define PTR_ALIGN(x, y)		((__typeof(x))roundup2((unsigned long)(x), (y)))
16 #define ALIGN_DOWN(x, y)	((__typeof(x))rounddown2((unsigned long)(x), (y)))
17 
18 #endif
19