arch/arc/include/asm/bitops.h
Source file repositories/reference/linux-study-clean/arch/arc/include/asm/bitops.h
File Facts
- System
- Linux kernel
- Corpus path
arch/arc/include/asm/bitops.h- Extension
.h- Size
- 3870 bytes
- Lines
- 200
- Domain
- Architecture Layer
- Bucket
- arch/arc
- 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/types.hlinux/compiler.hasm-generic/bitops/hweight.hasm-generic/bitops/fls64.hasm-generic/bitops/sched.hasm-generic/bitops/lock.hasm-generic/bitops/atomic.hasm-generic/bitops/non-atomic.hasm-generic/bitops/le.hasm-generic/bitops/ext2-atomic-setbit.h
Detected Declarations
function Copyrightfunction constant_flsfunction flsfunction __attribute__function __attribute__function flsfunction __attribute__function __attribute__function __attribute__
Annotated Snippet
#ifndef _ASM_BITOPS_H
#define _ASM_BITOPS_H
#ifndef _LINUX_BITOPS_H
#error only <linux/bitops.h> can be included directly
#endif
#ifndef __ASSEMBLER__
#include <linux/types.h>
#include <linux/compiler.h>
#ifdef CONFIG_ISA_ARCOMPACT
/*
* Count the number of zeros, starting from MSB
* Helper for fls( ) friends
* This is a pure count, so (1-32) or (0-31) doesn't apply
* It could be 0 to 32, based on num of 0's in there
* clz(0x8000_0000) = 0, clz(0xFFFF_FFFF)=0, clz(0) = 32, clz(1) = 31
*/
static inline __attribute__ ((const)) int clz(unsigned int x)
{
unsigned int res;
__asm__ __volatile__(
" norm.f %0, %1 \n"
" mov.n %0, 0 \n"
" add.p %0, %0, 1 \n"
: "=r"(res)
: "r"(x)
: "cc");
return res;
}
static inline int constant_fls(unsigned int x)
{
int r = 32;
if (!x)
return 0;
if (!(x & 0xffff0000u)) {
x <<= 16;
r -= 16;
}
if (!(x & 0xff000000u)) {
x <<= 8;
r -= 8;
}
if (!(x & 0xf0000000u)) {
x <<= 4;
r -= 4;
}
if (!(x & 0xc0000000u)) {
x <<= 2;
r -= 2;
}
if (!(x & 0x80000000u))
r -= 1;
return r;
}
/*
* fls = Find Last Set in word
* @result: [1-32]
* fls(1) = 1, fls(0x80000000) = 32, fls(0) = 0
*/
static inline __attribute__ ((const)) int fls(unsigned int x)
{
if (__builtin_constant_p(x))
return constant_fls(x);
return 32 - clz(x);
}
/*
* __fls: Similar to fls, but zero based (0-31)
*/
static inline __attribute__ ((const)) unsigned long __fls(unsigned long x)
{
if (!x)
return 0;
else
return fls(x) - 1;
}
/*
* ffs = Find First Set in word (LSB to MSB)
* @result: [1-32], 0 if all 0's
Annotation
- Immediate include surface: `linux/types.h`, `linux/compiler.h`, `asm-generic/bitops/hweight.h`, `asm-generic/bitops/fls64.h`, `asm-generic/bitops/sched.h`, `asm-generic/bitops/lock.h`, `asm-generic/bitops/atomic.h`, `asm-generic/bitops/non-atomic.h`.
- Detected declarations: `function Copyright`, `function constant_fls`, `function fls`, `function __attribute__`, `function __attribute__`, `function fls`, `function __attribute__`, `function __attribute__`, `function __attribute__`.
- Atlas domain: Architecture Layer / arch/arc.
- 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.