Functions | Variables
bitops.h File Reference

x86 bit operations More...

#include <stdint.h>

Go to the source code of this file.


static __attribute__ ((always_inline)) void set_bit(unsigned int bit
 Set bit atomically. More...
__asm__ __volatile__ ("lock btsl %k1, %0" :"+m"(*bytes) :"Ir"(bit))
__asm__ __volatile__ ("lock btrl %k1, %0" :"+m"(*bytes) :"Ir"(bit))
__asm__ __volatile__ ("lock btsl %k2, %0\n\t" "sbb %1, %1\n\t" :"+m"(*bytes), "=r"(old) :"Ir"(bit))
__asm__ __volatile__ ("lock btrl %k2, %0\n\t" "sbb %1, %1\n\t" :"+m"(*bytes), "=r"(old) :"Ir"(bit))


static volatile void * bits
int old

Detailed Description

x86 bit operations

We perform atomic bit set and bit clear operations using "lock bts" and "lock btr". We use the output constraint to inform the compiler that any memory from the start of the bit field up to and including the byte containing the bit may be modified. (This is overkill but shouldn't matter in practice since we're unlikely to subsequently read other bits from the same bit field.)

Definition in file bitops.h.

Function Documentation



◆ __attribute__()

static __attribute__ ( (always_inline)  )

Set bit atomically.

Test and clear bit atomically.

Test and set bit atomically.

Clear bit atomically.

bitBit to set
bitsBit field
bitBit to set
bitsBit field
Return values
oldOld value of bit (zero or non-zero)

◆ __volatile__() [1/4]

__asm__ __volatile__ ( "lock btsl %  k1,
%0" :"+m"*bytes :"Ir"  bit 

◆ __volatile__() [2/4]

__asm__ __volatile__ ( "lock btrl %  k1,
%0" :"+m"*bytes :"Ir"  bit 

◆ __volatile__() [3/4]

__asm__ __volatile__ ( "lock btsl %  k2,
%0\n\t" "sbb %  1,
%1\n\t" :"+m"*  bytes 

◆ __volatile__() [4/4]

__asm__ __volatile__ ( "lock btrl %  k2,
%0\n\t" "sbb %  1,
%1\n\t" :"+m"*  bytes 

Variable Documentation

◆ bits

static volatile void * bits

◆ old

return old

Definition at line 64 of file bitops.h.

Referenced by efi_file_path_claim(), generic_settings_store(), tcp_sack(), and usbkbd_report().