iPXE
Functions | Variables
bitops.h File Reference

x86 bit operations More...

#include <stdint.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static __attribute__ ((always_inline)) void set_bit(unsigned int bit
 Set bit atomically. More...
 
__asm__ __volatile__ ("lock bts %1, %0" :"+m"(*bytes) :"Ir"(bit))
 
__asm__ __volatile__ ("lock btr %1, %0" :"+m"(*bytes) :"Ir"(bit))
 
__asm__ __volatile__ ("lock bts %2, %0\n\t" "sbb %1, %1\n\t" :"+m"(*bytes), "=r"(old) :"Ir"(bit))
 
__asm__ __volatile__ ("lock btr %2, %0\n\t" "sbb %1, %1\n\t" :"+m"(*bytes), "=r"(old) :"Ir"(bit))
 

Variables

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

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ __attribute__()

static __attribute__ ( (always_inline)  )
inlinestatic

Set bit atomically.

Test and clear bit atomically.

Test and set bit atomically.

Clear bit atomically.

Parameters
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 bts %  1,
%0" :"+m"*bytes :"Ir"  bit 
)

◆ __volatile__() [2/4]

__asm__ __volatile__ ( "lock btr %  1,
%0" :"+m"*bytes :"Ir"  bit 
)

◆ __volatile__() [3/4]

__asm__ __volatile__ ( "lock bts %  2,
%0\n\t" "sbb %  1,
%1\n\t" :"+m"*  bytes 
)

◆ __volatile__() [4/4]

__asm__ __volatile__ ( "lock btr %  2,
%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 generic_settings_store(), tcp_sack(), and usbkbd_report().