summaryrefslogtreecommitdiffstats
path: root/lib/libnetbsd
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-02-04 16:49:50 +0000
committerngie <ngie@FreeBSD.org>2017-02-04 16:49:50 +0000
commitcea48e4c149a99ca2c75a8f8f5c73ca838d2ecd1 (patch)
treec1c19cd95b6fdd9192354ce5fff8d521c3d9da61 /lib/libnetbsd
parent3c2d6610b4f395363fd8c565af496d279ab44162 (diff)
downloadFreeBSD-src-cea48e4c149a99ca2c75a8f8f5c73ca838d2ecd1.zip
FreeBSD-src-cea48e4c149a99ca2c75a8f8f5c73ca838d2ecd1.tar.gz
MFC r311972:
Add __BIT and __BITS macros from NetBSD to help support new testcases
Diffstat (limited to 'lib/libnetbsd')
-rw-r--r--lib/libnetbsd/sys/cdefs.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/libnetbsd/sys/cdefs.h b/lib/libnetbsd/sys/cdefs.h
index 051959f..06e46fd 100644
--- a/lib/libnetbsd/sys/cdefs.h
+++ b/lib/libnetbsd/sys/cdefs.h
@@ -69,4 +69,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_ */
OpenPOWER on IntegriCloud