arch/mips/lib/bitops.c
Source file repositories/reference/linux-study-clean/arch/mips/lib/bitops.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/lib/bitops.c- Extension
.c- Size
- 4106 bytes
- Lines
- 163
- Domain
- Architecture Layer
- Bucket
- arch/mips
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
Dependency Surface
linux/bitops.hlinux/bits.hlinux/irqflags.hlinux/export.h
Detected Declarations
function Copyrightfunction __mips_clear_bitfunction __mips_change_bitfunction test_and_set_bit_lockfunction test_and_clear_bitfunction test_and_change_bitfunction __mips_xor_is_negative_byteexport __mips_set_bitexport __mips_clear_bitexport __mips_change_bitexport __mips_test_and_set_bit_lockexport __mips_test_and_clear_bitexport __mips_test_and_change_bit
Annotated Snippet
#include <linux/bitops.h>
#include <linux/bits.h>
#include <linux/irqflags.h>
#include <linux/export.h>
/**
* __mips_set_bit - Atomically set a bit in memory. This is called by
* set_bit() if it cannot find a faster solution.
* @nr: the bit to set
* @addr: the address to start counting from
*/
void __mips_set_bit(unsigned long nr, volatile unsigned long *addr)
{
volatile unsigned long *a = &addr[BIT_WORD(nr)];
unsigned int bit = nr % BITS_PER_LONG;
unsigned long mask;
unsigned long flags;
mask = 1UL << bit;
raw_local_irq_save(flags);
*a |= mask;
raw_local_irq_restore(flags);
}
EXPORT_SYMBOL(__mips_set_bit);
/**
* __mips_clear_bit - Clears a bit in memory. This is called by clear_bit() if
* it cannot find a faster solution.
* @nr: Bit to clear
* @addr: Address to start counting from
*/
void __mips_clear_bit(unsigned long nr, volatile unsigned long *addr)
{
volatile unsigned long *a = &addr[BIT_WORD(nr)];
unsigned int bit = nr % BITS_PER_LONG;
unsigned long mask;
unsigned long flags;
mask = 1UL << bit;
raw_local_irq_save(flags);
*a &= ~mask;
raw_local_irq_restore(flags);
}
EXPORT_SYMBOL(__mips_clear_bit);
/**
* __mips_change_bit - Toggle a bit in memory. This is called by change_bit()
* if it cannot find a faster solution.
* @nr: Bit to change
* @addr: Address to start counting from
*/
void __mips_change_bit(unsigned long nr, volatile unsigned long *addr)
{
volatile unsigned long *a = &addr[BIT_WORD(nr)];
unsigned int bit = nr % BITS_PER_LONG;
unsigned long mask;
unsigned long flags;
mask = 1UL << bit;
raw_local_irq_save(flags);
*a ^= mask;
raw_local_irq_restore(flags);
}
EXPORT_SYMBOL(__mips_change_bit);
/**
* __mips_test_and_set_bit_lock - Set a bit and return its old value. This is
* called by test_and_set_bit_lock() if it cannot find a faster solution.
* @nr: Bit to set
* @addr: Address to count from
*/
int __mips_test_and_set_bit_lock(unsigned long nr,
volatile unsigned long *addr)
{
volatile unsigned long *a = &addr[BIT_WORD(nr)];
unsigned int bit = nr % BITS_PER_LONG;
unsigned long mask;
unsigned long flags;
int res;
mask = 1UL << bit;
raw_local_irq_save(flags);
res = (mask & *a) != 0;
*a |= mask;
raw_local_irq_restore(flags);
return res;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/bits.h`, `linux/irqflags.h`, `linux/export.h`.
- Detected declarations: `function Copyright`, `function __mips_clear_bit`, `function __mips_change_bit`, `function test_and_set_bit_lock`, `function test_and_clear_bit`, `function test_and_change_bit`, `function __mips_xor_is_negative_byte`, `export __mips_set_bit`, `export __mips_clear_bit`, `export __mips_change_bit`.
- Atlas domain: Architecture Layer / arch/mips.
- Implementation status: integration 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.