arch/powerpc/include/asm/word-at-a-time.h
Source file repositories/reference/linux-study-clean/arch/powerpc/include/asm/word-at-a-time.h
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/include/asm/word-at-a-time.h- Extension
.h- Size
- 4905 bytes
- Lines
- 207
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/wordpart.hasm/asm-compat.hasm/extable.h
Detected Declarations
struct word_at_a_timestruct word_at_a_timestruct word_at_a_timefunction prep_zero_maskfunction find_zerofunction has_zerofunction zero_bytemaskfunction has_zerofunction prep_zero_maskfunction create_zero_maskfunction find_zerofunction zero_bytemaskfunction count_masked_bytesfunction create_zero_maskfunction find_zerofunction has_zerofunction prep_zero_maskfunction load_unaligned_zero
Annotated Snippet
struct word_at_a_time {
const unsigned long high_bits, low_bits;
};
#define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0xfe) + 1, REPEAT_BYTE(0x7f) }
/* Bit set in the bytes that have a zero */
static inline long prep_zero_mask(unsigned long val, unsigned long rhs, const struct word_at_a_time *c)
{
unsigned long mask = (val & c->low_bits) + c->low_bits;
return ~(mask | rhs);
}
#define create_zero_mask(mask) (mask)
static inline long find_zero(unsigned long mask)
{
long leading_zero_bits;
asm (PPC_CNTLZL "%0,%1" : "=r" (leading_zero_bits) : "r" (mask));
return leading_zero_bits >> 3;
}
static inline unsigned long has_zero(unsigned long val, unsigned long *data, const struct word_at_a_time *c)
{
unsigned long rhs = val | c->low_bits;
*data = rhs;
return (val + c->high_bits) & ~rhs;
}
static inline unsigned long zero_bytemask(unsigned long mask)
{
return ~1ul << __fls(mask);
}
#else
#ifdef CONFIG_64BIT
/* unused */
struct word_at_a_time {
};
#define WORD_AT_A_TIME_CONSTANTS { }
/* This will give us 0xff for a NULL char and 0x00 elsewhere */
static inline unsigned long has_zero(unsigned long a, unsigned long *bits, const struct word_at_a_time *c)
{
unsigned long ret;
unsigned long zero = 0;
asm("cmpb %0,%1,%2" : "=r" (ret) : "r" (a), "r" (zero));
*bits = ret;
return ret;
}
static inline unsigned long prep_zero_mask(unsigned long a, unsigned long bits, const struct word_at_a_time *c)
{
return bits;
}
/* Alan Modra's little-endian strlen tail for 64-bit */
static inline unsigned long create_zero_mask(unsigned long bits)
{
unsigned long leading_zero_bits;
long trailing_zero_bit_mask;
asm("addi %1,%2,-1\n\t"
"andc %1,%1,%2\n\t"
"popcntd %0,%1"
: "=r" (leading_zero_bits), "=&r" (trailing_zero_bit_mask)
: "b" (bits));
return leading_zero_bits;
}
static inline unsigned long find_zero(unsigned long mask)
{
return mask >> 3;
}
/* This assumes that we never ask for an all 1s bitmask */
static inline unsigned long zero_bytemask(unsigned long mask)
{
return (1UL << mask) - 1;
}
#else /* 32-bit case */
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/wordpart.h`, `asm/asm-compat.h`, `asm/extable.h`.
- Detected declarations: `struct word_at_a_time`, `struct word_at_a_time`, `struct word_at_a_time`, `function prep_zero_mask`, `function find_zero`, `function has_zero`, `function zero_bytemask`, `function has_zero`, `function prep_zero_mask`, `function create_zero_mask`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.