arch/s390/include/asm/bitops.h
Source file repositories/reference/linux-study-clean/arch/s390/include/asm/bitops.h
File Facts
- System
- Linux kernel
- Corpus path
arch/s390/include/asm/bitops.h- Extension
.h- Size
- 6073 bytes
- Lines
- 217
- Domain
- Architecture Layer
- Bucket
- arch/s390
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
Dependency Surface
linux/typecheck.hlinux/compiler.hlinux/types.hasm/asm.hasm-generic/bitops/atomic.hasm-generic/bitops/non-instrumented-non-atomic.hasm-generic/bitops/lock.hasm-generic/bitops/builtin-ffs.hasm-generic/bitops/builtin-__ffs.hasm-generic/bitops/ffz.hasm-generic/bitops/builtin-__fls.hasm-generic/bitops/builtin-fls.hasm-generic/bitops/fls64.hasm/arch_hweight.hasm-generic/bitops/const_hweight.hasm-generic/bitops/sched.hasm-generic/bitops/le.hasm-generic/bitops/ext2-atomic-setbit.h
Detected Declarations
function Authorfunction __builtin_constant_pfunction set_bit_invfunction clear_bit_invfunction test_and_clear_bit_invfunction __set_bit_invfunction __clear_bit_invfunction test_bit_invfunction __flogrfunction routines
Annotated Snippet
if (!(word & 0xffffffff00000000UL)) {
word <<= 32;
bit += 32;
}
if (!(word & 0xffff000000000000UL)) {
word <<= 16;
bit += 16;
}
if (!(word & 0xff00000000000000UL)) {
word <<= 8;
bit += 8;
}
if (!(word & 0xf000000000000000UL)) {
word <<= 4;
bit += 4;
}
if (!(word & 0xc000000000000000UL)) {
word <<= 2;
bit += 2;
}
if (!(word & 0x8000000000000000UL)) {
word <<= 1;
bit += 1;
}
return bit;
} else {
union register_pair rp __uninitialized;
rp.even = word;
asm("flogr %[rp],%[rp]"
: [rp] "+d" (rp.pair) : : "cc");
bit = rp.even;
/*
* The result of the flogr instruction is a value in the range
* of 0..64. Let the compiler know that the AND operation can
* be optimized away.
*/
__assume(bit <= 64);
return bit & 127;
}
}
/**
* ffs - find first bit set
* @word: the word to search
*
* This is defined the same way as the libc and
* compiler builtin ffs routines (man ffs).
*/
static __always_inline __flatten __attribute_const__ int ffs(int word)
{
unsigned int val = (unsigned int)word;
return BITS_PER_LONG - __flogr(-val & val);
}
#else /* CONFIG_CC_HAS_BUILTIN_FFS */
#include <asm-generic/bitops/builtin-ffs.h>
#endif /* CONFIG_CC_HAS_BUILTIN_FFS */
#include <asm-generic/bitops/builtin-__ffs.h>
#include <asm-generic/bitops/ffz.h>
#include <asm-generic/bitops/builtin-__fls.h>
#include <asm-generic/bitops/builtin-fls.h>
#include <asm-generic/bitops/fls64.h>
#include <asm/arch_hweight.h>
#include <asm-generic/bitops/const_hweight.h>
#include <asm-generic/bitops/sched.h>
#include <asm-generic/bitops/le.h>
#include <asm-generic/bitops/ext2-atomic-setbit.h>
#endif /* _S390_BITOPS_H */
Annotation
- Immediate include surface: `linux/typecheck.h`, `linux/compiler.h`, `linux/types.h`, `asm/asm.h`, `asm-generic/bitops/atomic.h`, `asm-generic/bitops/non-instrumented-non-atomic.h`, `asm-generic/bitops/lock.h`, `asm-generic/bitops/builtin-ffs.h`.
- Detected declarations: `function Author`, `function __builtin_constant_p`, `function set_bit_inv`, `function clear_bit_inv`, `function test_and_clear_bit_inv`, `function __set_bit_inv`, `function __clear_bit_inv`, `function test_bit_inv`, `function __flogr`, `function routines`.
- Atlas domain: Architecture Layer / arch/s390.
- 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.