Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys add __BITMAP_TYPE
details: https://anonhg.NetBSD.org/src/rev/122abcd222a3
branches: trunk
changeset: 783128:122abcd222a3
user: christos <christos%NetBSD.org@localhost>
date: Fri Dec 07 02:27:58 2012 +0000
description:
add __BITMAP_TYPE
diffstat:
sys/sys/bitops.h | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diffs (53 lines):
diff -r e2d3c611144b -r 122abcd222a3 sys/sys/bitops.h
--- a/sys/sys/bitops.h Fri Dec 07 02:27:29 2012 +0000
+++ b/sys/sys/bitops.h Fri Dec 07 02:27:58 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bitops.h,v 1.10 2012/12/01 15:03:47 christos Exp $ */
+/* $NetBSD: bitops.h,v 1.11 2012/12/07 02:27:58 christos Exp $ */
/*-
* Copyright (c) 2007, 2010 The NetBSD Foundation, Inc.
@@ -294,31 +294,35 @@
return _v - _div * fast_divide32(_v, _div, _m, _s1, _s2);
}
+#define __BITMAP_TYPE(__s, __t, __n) struct __s { \
+ __t _b[__BITMAP_SIZE(__t, __n)]; \
+}
+
#define __BITMAP_BITS(__t) (sizeof(__t) * NBBY)
#define __BITMAP_SHIFT(__t) (ilog2(__BITMAP_BITS(__t)))
#define __BITMAP_MASK(__t) (__BITMAP_BITS(__t) - 1)
#define __BITMAP_SIZE(__t, __n) \
(((__n) + (__BITMAP_BITS(__t) - 1)) / __BITMAP_BITS(__t))
#define __BITMAP_BIT(__n, __v) \
- (1 << ((__n) & __BITMAP_MASK(*__v)))
+ (1 << ((__n) & __BITMAP_MASK(*(__v)->_b)))
#define __BITMAP_WORD(__n, __v) \
- ((__n) >> __BITMAP_SHIFT(*__v))
+ ((__n) >> __BITMAP_SHIFT(*(__v)->_b))
#define __BITMAP_SET(__n, __v) \
- (__v[__BITMAP_WORD(__n, __v)] |= __BITMAP_BIT(__n, __v))
+ ((__v)->_b[__BITMAP_WORD(__n, __v)] |= __BITMAP_BIT(__n, __v))
#define __BITMAP_CLR(__n, __v) \
- (__v[__BITMAP_WORD(__n, __v)] &= ~__BITMAP_BIT(__n, __v))
+ ((__v)->_b[__BITMAP_WORD(__n, __v)] &= ~__BITMAP_BIT(__n, __v))
#define __BITMAP_ISSET(__n, __v) \
- (__v[__BITMAP_WORD(__n, __v)] & __BITMAP_BIT(__n, __v))
+ ((__v)->_b[__BITMAP_WORD(__n, __v)] & __BITMAP_BIT(__n, __v))
#if __GNUC_PREREQ__(2, 95)
#define __BITMAP_ZERO(__v) \
- (void)__builtin_memset((__v), 0, sizeof(__v))
+ (void)__builtin_memset((__v), 0, sizeof(*__v))
#else
#define __BITMAP_ZERO(__v) do { \
size_t __i; \
- for (__i = 0; __i < __arraycount(__v); __i++) \
- (__v)[__i] = 0; \
+ for (__i = 0; __i < __arraycount(__v->_b); __i++) \
+ (__v)->_b[__i] = 0; \
} while (/* CONSTCOND */ 0)
#endif /* GCC 2.95 */
Home |
Main Index |
Thread Index |
Old Index