arch/parisc/include/asm/bitops.h
Source file repositories/reference/linux-study-clean/arch/parisc/include/asm/bitops.h
File Facts
- System
- Linux kernel
- Corpus path
arch/parisc/include/asm/bitops.h- Extension
.h- Size
- 5511 bytes
- Lines
- 210
- Domain
- Architecture Layer
- Bucket
- arch/parisc
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
Dependency Surface
linux/compiler.hasm/types.hasm/byteorder.hasm/barrier.hlinux/atomic.hasm-generic/bitops/non-atomic.hasm-generic/bitops/ffz.hasm-generic/bitops/__fls.hasm-generic/bitops/fls64.hasm-generic/bitops/hweight.hasm-generic/bitops/lock.hasm-generic/bitops/sched.hasm-generic/bitops/le.hasm-generic/bitops/ext2-atomic-setbit.h
Detected Declarations
function set_bitfunction clear_bitfunction change_bitfunction test_and_set_bitfunction test_and_clear_bitfunction test_and_change_bitfunction __ffsfunction ffsfunction fls
Annotated Snippet
#ifndef _PARISC_BITOPS_H
#define _PARISC_BITOPS_H
#ifndef _LINUX_BITOPS_H
#error only <linux/bitops.h> can be included directly
#endif
#include <linux/compiler.h>
#include <asm/types.h>
#include <asm/byteorder.h>
#include <asm/barrier.h>
#include <linux/atomic.h>
/* See http://marc.theaimsgroup.com/?t=108826637900003 for discussion
* on use of volatile and __*_bit() (set/clear/change):
* *_bit() want use of volatile.
* __*_bit() are "relaxed" and don't use spinlock or volatile.
*/
static __inline__ void set_bit(int nr, volatile unsigned long * addr)
{
unsigned long mask = BIT_MASK(nr);
unsigned long flags;
addr += BIT_WORD(nr);
_atomic_spin_lock_irqsave(addr, flags);
*addr |= mask;
_atomic_spin_unlock_irqrestore(addr, flags);
}
static __inline__ void clear_bit(int nr, volatile unsigned long * addr)
{
unsigned long mask = BIT_MASK(nr);
unsigned long flags;
addr += BIT_WORD(nr);
_atomic_spin_lock_irqsave(addr, flags);
*addr &= ~mask;
_atomic_spin_unlock_irqrestore(addr, flags);
}
static __inline__ void change_bit(int nr, volatile unsigned long * addr)
{
unsigned long mask = BIT_MASK(nr);
unsigned long flags;
addr += BIT_WORD(nr);
_atomic_spin_lock_irqsave(addr, flags);
*addr ^= mask;
_atomic_spin_unlock_irqrestore(addr, flags);
}
static __inline__ int test_and_set_bit(int nr, volatile unsigned long * addr)
{
unsigned long mask = BIT_MASK(nr);
unsigned long old;
unsigned long flags;
int set;
addr += BIT_WORD(nr);
_atomic_spin_lock_irqsave(addr, flags);
old = *addr;
set = (old & mask) ? 1 : 0;
if (!set)
*addr = old | mask;
_atomic_spin_unlock_irqrestore(addr, flags);
return set;
}
static __inline__ int test_and_clear_bit(int nr, volatile unsigned long * addr)
{
unsigned long mask = BIT_MASK(nr);
unsigned long old;
unsigned long flags;
int set;
addr += BIT_WORD(nr);
_atomic_spin_lock_irqsave(addr, flags);
old = *addr;
set = (old & mask) ? 1 : 0;
if (set)
*addr = old & ~mask;
_atomic_spin_unlock_irqrestore(addr, flags);
return set;
}
static __inline__ int test_and_change_bit(int nr, volatile unsigned long * addr)
{
Annotation
- Immediate include surface: `linux/compiler.h`, `asm/types.h`, `asm/byteorder.h`, `asm/barrier.h`, `linux/atomic.h`, `asm-generic/bitops/non-atomic.h`, `asm-generic/bitops/ffz.h`, `asm-generic/bitops/__fls.h`.
- Detected declarations: `function set_bit`, `function clear_bit`, `function change_bit`, `function test_and_set_bit`, `function test_and_clear_bit`, `function test_and_change_bit`, `function __ffs`, `function ffs`, `function fls`.
- Atlas domain: Architecture Layer / arch/parisc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.