arch/s390/include/asm/bitops.h

Source file repositories/reference/linux-study-clean/arch/s390/include/asm/bitops.h

File Facts

System
Linux kernel
Corpus path
arch/s390/include/asm/bitops.h
Extension
.h
Size
6073 bytes
Lines
217
Domain
Architecture Layer
Bucket
arch/s390
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (!(word & 0xffffffff00000000UL)) {
			word <<= 32;
			bit += 32;
		}
		if (!(word & 0xffff000000000000UL)) {
			word <<= 16;
			bit += 16;
		}
		if (!(word & 0xff00000000000000UL)) {
			word <<= 8;
			bit += 8;
		}
		if (!(word & 0xf000000000000000UL)) {
			word <<= 4;
			bit += 4;
		}
		if (!(word & 0xc000000000000000UL)) {
			word <<= 2;
			bit += 2;
		}
		if (!(word & 0x8000000000000000UL)) {
			word <<= 1;
			bit += 1;
		}
		return bit;
	} else {
		union register_pair rp __uninitialized;

		rp.even = word;
		asm("flogr	%[rp],%[rp]"
		    : [rp] "+d" (rp.pair) : : "cc");
		bit = rp.even;
		/*
		 * The result of the flogr instruction is a value in the range
		 * of 0..64. Let the compiler know that the AND operation can
		 * be optimized away.
		 */
		__assume(bit <= 64);
		return bit & 127;
	}
}

/**
 * ffs - find first bit set
 * @word: the word to search
 *
 * This is defined the same way as the libc and
 * compiler builtin ffs routines (man ffs).
 */
static __always_inline __flatten __attribute_const__ int ffs(int word)
{
	unsigned int val = (unsigned int)word;

	return BITS_PER_LONG - __flogr(-val & val);
}

#else /* CONFIG_CC_HAS_BUILTIN_FFS */

#include <asm-generic/bitops/builtin-ffs.h>

#endif /* CONFIG_CC_HAS_BUILTIN_FFS */

#include <asm-generic/bitops/builtin-__ffs.h>
#include <asm-generic/bitops/ffz.h>
#include <asm-generic/bitops/builtin-__fls.h>
#include <asm-generic/bitops/builtin-fls.h>
#include <asm-generic/bitops/fls64.h>
#include <asm/arch_hweight.h>
#include <asm-generic/bitops/const_hweight.h>
#include <asm-generic/bitops/sched.h>
#include <asm-generic/bitops/le.h>
#include <asm-generic/bitops/ext2-atomic-setbit.h>

#endif /* _S390_BITOPS_H */

Annotation

Implementation Notes