arch/alpha/include/asm/bitops.h
Source file repositories/reference/linux-study-clean/arch/alpha/include/asm/bitops.h
File Facts
- System
- Linux kernel
- Corpus path
arch/alpha/include/asm/bitops.h- Extension
.h- Size
- 9669 bytes
- Lines
- 479
- Domain
- Architecture Layer
- Bucket
- arch/alpha
- 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
asm/compiler.hasm/barrier.hasm-generic/bitops/arch_hweight.hasm-generic/bitops/const_hweight.hasm-generic/bitops/non-instrumented-non-atomic.hasm-generic/bitops/le.hasm-generic/bitops/ext2-atomic-setbit.h
Detected Declarations
function set_bitfunction arch___set_bitfunction clear_bitfunction clear_bit_unlockfunction arch___clear_bitfunction __clear_bit_unlockfunction change_bitfunction arch___change_bitfunction test_and_set_bitfunction test_and_set_bit_lockfunction arch___test_and_set_bitfunction test_and_clear_bitfunction arch___test_and_clear_bitfunction test_and_change_bitfunction arch___test_and_change_bitfunction xor_unlock_is_negative_bytefunction ffz_bfunction ffzfunction __ffsfunction ffsfunction fls64function fls64function __flsfunction flsfunction __arch_hweight64function __arch_hweight32function __arch_hweight16function __arch_hweight8function sched_find_first_bit
Annotated Snippet
#ifndef _ALPHA_BITOPS_H
#define _ALPHA_BITOPS_H
#ifndef _LINUX_BITOPS_H
#error only <linux/bitops.h> can be included directly
#endif
#include <asm/compiler.h>
#include <asm/barrier.h>
/*
* Copyright 1994, Linus Torvalds.
*/
/*
* These have to be done with inline assembly: that way the bit-setting
* is guaranteed to be atomic. All bit operations return 0 if the bit
* was cleared before the operation and != 0 if it was not.
*
* To get proper branch prediction for the main line, we must branch
* forward to code at the end of this object's .text section, then
* branch back to restart the operation.
*
* bit 0 is the LSB of addr; bit 64 is the LSB of (addr+1).
*/
static inline void
set_bit(unsigned long nr, volatile void * addr)
{
unsigned long temp;
int *m = ((int *) addr) + (nr >> 5);
__asm__ __volatile__(
"1: ldl_l %0,%3\n"
" bis %0,%2,%0\n"
" stl_c %0,%1\n"
" beq %0,2f\n"
".subsection 2\n"
"2: br 1b\n"
".previous"
:"=&r" (temp), "=m" (*m)
:"Ir" (1UL << (nr & 31)), "m" (*m));
}
/*
* WARNING: non atomic version.
*/
static __always_inline void
arch___set_bit(unsigned long nr, volatile unsigned long *addr)
{
int *m = ((int *) addr) + (nr >> 5);
*m |= 1 << (nr & 31);
}
static inline void
clear_bit(unsigned long nr, volatile void * addr)
{
unsigned long temp;
int *m = ((int *) addr) + (nr >> 5);
__asm__ __volatile__(
"1: ldl_l %0,%3\n"
" bic %0,%2,%0\n"
" stl_c %0,%1\n"
" beq %0,2f\n"
".subsection 2\n"
"2: br 1b\n"
".previous"
:"=&r" (temp), "=m" (*m)
:"Ir" (1UL << (nr & 31)), "m" (*m));
}
static inline void
clear_bit_unlock(unsigned long nr, volatile void * addr)
{
smp_mb();
clear_bit(nr, addr);
}
/*
* WARNING: non atomic version.
*/
static __always_inline void
arch___clear_bit(unsigned long nr, volatile unsigned long *addr)
{
int *m = ((int *) addr) + (nr >> 5);
*m &= ~(1 << (nr & 31));
}
Annotation
- Immediate include surface: `asm/compiler.h`, `asm/barrier.h`, `asm-generic/bitops/arch_hweight.h`, `asm-generic/bitops/const_hweight.h`, `asm-generic/bitops/non-instrumented-non-atomic.h`, `asm-generic/bitops/le.h`, `asm-generic/bitops/ext2-atomic-setbit.h`.
- Detected declarations: `function set_bit`, `function arch___set_bit`, `function clear_bit`, `function clear_bit_unlock`, `function arch___clear_bit`, `function __clear_bit_unlock`, `function change_bit`, `function arch___change_bit`, `function test_and_set_bit`, `function test_and_set_bit_lock`.
- Atlas domain: Architecture Layer / arch/alpha.
- 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.