xref: /openbsd-src/sys/dev/pci/drm/include/linux/bitfield.h (revision ad8b1aafbcc34f7eb86e4ebfd874be286017954b)
1 /* Public domain. */
2 
3 #ifndef _LINUX_BITFIELD_H
4 #define _LINUX_BITFIELD_H
5 
6 #include <asm/byteorder.h>
7 #include <linux/build_bug.h>
8 
9 #define __bf_shf(x) (__builtin_ffsll(x) - 1)
10 
11 #define FIELD_GET(_m, _v) \
12     ((typeof(_m))(((_v) & (_m)) >> __bf_shf(_m)))
13 
14 #define FIELD_PREP(_m, _v) \
15     (((typeof(_m))(_v) << __bf_shf(_m)) & (_m))
16 
17 #endif
18