Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F148217114
D22639.id65168.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
911 B
Referenced Files
None
Subscribers
None
D22639.id65168.diff
View Options
Index: head/sys/sys/bitset.h
===================================================================
--- head/sys/sys/bitset.h
+++ head/sys/sys/bitset.h
@@ -34,12 +34,19 @@
#ifndef _SYS_BITSET_H_
#define _SYS_BITSET_H_
+/*
+ * Whether expr is both constant and true. Result is itself constant.
+ * Used to enable optimizations for sets with a known small size.
+ */
+#define __constexpr_cond(expr) (__builtin_constant_p((expr)) && (expr))
+
#define __bitset_mask(_s, n) \
- (1L << ((__bitset_words((_s)) == 1) ? \
+ (1L << (__constexpr_cond(__bitset_words((_s)) == 1) ? \
(__size_t)(n) : ((n) % _BITSET_BITS)))
#define __bitset_word(_s, n) \
- ((__bitset_words((_s)) == 1) ? 0 : ((n) / _BITSET_BITS))
+ (__constexpr_cond(__bitset_words((_s)) == 1) ? \
+ 0 : ((n) / _BITSET_BITS))
#define BIT_CLR(_s, n, p) \
((p)->__bits[__bitset_word(_s, n)] &= ~__bitset_mask((_s), (n)))
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 17, 2:16 PM (1 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29803754
Default Alt Text
D22639.id65168.diff (911 B)
Attached To
Mode
D22639: bitset: avoid pessimized code when bitset size is not constant
Attached
Detach File
Event Timeline
Log In to Comment