参照元†
- u32 型変数の指定されたビット位置にビットをセット、つまり 1 にする。
返り値†
/**
* set_bit - Atomically set a bit in memory
* @nr: the bit to set
* @addr: the address to start counting from
*
* This function is atomic and may not be reordered. See __set_bit()
* if you do not require the atomic guarantees.
*
* Note: there are no guarantees that this function will not be reordered
* on non x86 architectures, so if you are writing portable code,
* make sure not to rely on its reordering guarantees.
*
* Note that @nr may be almost arbitrarily large; this function is not
* restricted to acting on a single-word quantity.
*/
static __always_inline void
set_bit(unsigned int nr, volatile unsigned long *addr)
{
if (IS_IMMEDIATE(nr)) {
asm volatile(LOCK_PREFIX "orb %1,%0"
: CONST_MASK_ADDR(nr, addr)
: "iq" ((u8)CONST_MASK(nr))
: "memory");
} else {
asm volatile(LOCK_PREFIX "bts %1,%0"
: BITOP_ADDR(addr) : "Ir" (nr) : "memory");
- bts r/m32, imm8 命令は Bit Test and Set 命令のこと。
- 32ビット変数の指定された位置のビットを
キャリーフラグ(CF)に格納し、ビットを 1にする命令。
- この関数ではテストの方の機能は使わない(=キャリーフラグは見ない)ようだ。
}
}
コメント†