diff options
author | Enji Cooper <ngie@FreeBSD.org> | 2017-01-12 09:01:14 +0000 |
---|---|---|
committer | Enji Cooper <ngie@FreeBSD.org> | 2017-01-12 09:01:14 +0000 |
commit | 7ad417dff84775a57d6aef409066ac5afc93cc6f (patch) | |
tree | 9d62d3fa5f4bfd6a0ad60b4d236863190f506f11 /lib | |
parent | 17160457b41ff26b4384d8f82ed176a2844eb272 (diff) | |
download | src-7ad417dff84775a57d6aef409066ac5afc93cc6f.tar.gz src-7ad417dff84775a57d6aef409066ac5afc93cc6f.zip |
Add __BIT and __BITS macros from NetBSD to help support new testcases
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=311972
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libnetbsd/sys/cdefs.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/libnetbsd/sys/cdefs.h b/lib/libnetbsd/sys/cdefs.h index 46372f368afd..325c23422446 100644 --- a/lib/libnetbsd/sys/cdefs.h +++ b/lib/libnetbsd/sys/cdefs.h @@ -71,4 +71,13 @@ */ #define __arraycount(__x) (sizeof(__x) / sizeof(__x[0])) +/* __BIT(n): nth bit, where __BIT(0) == 0x1. */ +#define __BIT(__n) \ + (((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : \ + ((uintmax_t)1 << (uintmax_t)((__n) & (NBBY * sizeof(uintmax_t) - 1)))) + +/* __BITS(m, n): bits m through n, m < n. */ +#define __BITS(__m, __n) \ + ((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1)) + #endif /* _LIBNETBSD_SYS_CDEFS_H_ */ |