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