include/linux/bitops.h
Source file repositories/reference/linux-study-clean/include/linux/bitops.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/bitops.h- Extension
.h- Size
- 10494 bytes
- Lines
- 397
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
Dependency Surface
asm/types.hlinux/bits.hlinux/typecheck.huapi/linux/kernel.hasm-generic/bitops/generic-non-atomic.hasm/bitops.h
Detected Declarations
function get_bitmask_orderfunction hweight_longfunction rol64function ror64function rol32function ror32function rol16function ror16function rol8function ror8function sign_extend32function sign_extend64function fls_longfunction get_count_orderfunction get_count_orderfunction parity8function __ffs64function fns
Annotated Snippet
* if (__ptr_test_bit(bit, &p)) {
* ...
* } else {
* ...
* }
*/
#define __ptr_test_bit(nr, addr) \
({ \
typecheck_pointer(*(addr)); \
test_bit(nr, (unsigned long *)(addr)); \
})
#ifdef __KERNEL__
#ifndef set_mask_bits
#define set_mask_bits(ptr, mask, bits) \
({ \
const typeof(*(ptr)) mask__ = (mask), bits__ = (bits); \
typeof(*(ptr)) old__, new__; \
\
old__ = READ_ONCE(*(ptr)); \
do { \
new__ = (old__ & ~mask__) | bits__; \
} while (!try_cmpxchg(ptr, &old__, new__)); \
\
old__; \
})
#endif
#ifndef bit_clear_unless
#define bit_clear_unless(ptr, clear, test) \
({ \
const typeof(*(ptr)) clear__ = (clear), test__ = (test);\
typeof(*(ptr)) old__, new__; \
\
old__ = READ_ONCE(*(ptr)); \
do { \
if (old__ & test__) \
break; \
new__ = old__ & ~clear__; \
} while (!try_cmpxchg(ptr, &old__, new__)); \
\
!(old__ & test__); \
})
#endif
#endif /* __KERNEL__ */
#endif
Annotation
- Immediate include surface: `asm/types.h`, `linux/bits.h`, `linux/typecheck.h`, `uapi/linux/kernel.h`, `asm-generic/bitops/generic-non-atomic.h`, `asm/bitops.h`.
- Detected declarations: `function get_bitmask_order`, `function hweight_long`, `function rol64`, `function ror64`, `function rol32`, `function ror32`, `function rol16`, `function ror16`, `function rol8`, `function ror8`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.