Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F175889917
D60716.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D60716.diff
View Options
diff --git a/sys/compat/linuxkpi/common/include/linux/bitfield.h b/sys/compat/linuxkpi/common/include/linux/bitfield.h
--- a/sys/compat/linuxkpi/common/include/linux/bitfield.h
+++ b/sys/compat/linuxkpi/common/include/linux/bitfield.h
@@ -2,6 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2020-2024 The FreeBSD Foundation
+ * Copyright (c) 2026 Bjoern A. Zeeb
*
* This software was developed by Björn Zeeb under sponsorship from
* the FreeBSD Foundation.
@@ -138,4 +139,40 @@
#define FIELD_GET(_mask, _value) \
((typeof(_mask))(((_value) & (_mask)) >> __bf_shf(_mask)))
+/* We do not run checks on this one (yet) so it equals FIELD_GET(). */
+#define __FIELD_GET(_mask, _value, _x) \
+ ((typeof(_mask))(((_value) & (_mask)) >> __bf_shf(_mask)))
+
+#define FIELD_GET_SIGNED(_mask, _value) \
+ ((typeof(_Generic((_mask), \
+ signed long long: (signed long long)0, \
+ unsigned long long: (signed long long)0, \
+ signed long: (signed long)0, \
+ unsigned long: (signed long)0, \
+ signed int: (signed int)0, \
+ unsigned int: (signed int)0, \
+ signed short: (signed short)0, \
+ unsigned short: (signed short)0, \
+ signed char: (signed char)0, \
+ unsigned char: (signed char)0, \
+ char: (signed char)0, \
+ default: (_mask)))) \
+ (((long long)(_value) << __builtin_clzll(_mask)) >> \
+ (__builtin_clzll(_mask) + __builtin_ctzll(_mask))))
+
+#define __field_get(_mask, _value) \
+ ({ \
+ typeof(_mask) __mask = _mask; \
+ typeof(__mask) __value = _value; \
+ unsigned int __shift; \
+ \
+ __shift = BITS_PER_TYPE(__mask) > 32 ? __ffs64(__mask) :\
+ __ffs(__mask); \
+ (__value & __mask) >> __shift; \
+ })
+
+#define field_get(_mask, _value) \
+ (__builtin_constant_p(_mask) ? __FIELD_GET(_mask, _value, "") : \
+ __field_get(_mask, _value))
+
#endif /* _LINUXKPI_LINUX_BITFIELD_H */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 15, 6:04 AM (4 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40821953
Default Alt Text
D60716.diff (1 KB)
Attached To
Mode
D60716: LinuxKPI: add field_get() and FIELD_GET_SIGNED()
Attached
Detach File
Event Timeline
Log In to Comment