Loading...
Searching...
No Matches
Bit Manipulation
Utility Functions
Collaboration diagram for Bit Manipulation:

## Files

file | bitops_arch.h
| amd64 bit manipulation functions
file | bitops.h
| bit manipulation functions
file | bitops_arch.h
| x86 bit manipulation functions

## Functions

void | l4util_set_bit (int b, volatile l4_umword_t *dest)
| Set bit in memory.
void | l4util_clear_bit (int b, volatile l4_umword_t *dest)
| Clear bit in memory.
void | l4util_complement_bit (int b, volatile l4_umword_t *dest)
| Complement bit in memory.
int | l4util_test_bit (int b, const volatile l4_umword_t *dest)
| Test bit (return value of bit).
int | l4util_bts (int b, volatile l4_umword_t *dest)
| Bit test and set.
int | l4util_btr (int b, volatile l4_umword_t *dest)
| Bit test and reset.
int | l4util_btc (int b, volatile l4_umword_t *dest)
| Bit test and complement.
int | l4util_bsr (l4_umword_t word)
| Bit scan reverse.
int | l4util_bsf (l4_umword_t word)
| Bit scan forward.
int | l4util_find_first_set_bit (const void *dest, l4_size_t size)
| Find the first set bit in a memory region.
int | l4util_find_first_zero_bit (const void *dest, l4_size_t size)
| Find the first zero bit in a memory region.
int | l4util_next_power2 (unsigned long val)
| Find the next power of 2 for a given number.

## Detailed Description

## Function Documentation

## l4util_bsf()

int l4util_bsf | ( | l4_umword_t | word | ) |

inline

Bit scan forward.

Parameters

  word | value (machine size)

Returns
  index of least significant bit set in word, -1 if no bit is set (word == 0)

"bit scan forward", find least significant bit set in word.

Definition at line 316 of file bitops.h.

## l4util_bsr()

int l4util_bsr | ( | l4_umword_t | word | ) |

inline

Bit scan reverse.

Parameters

  word | value (machine size)

Returns
  index of most significant set bit in word, -1 if no bit is set (word == 0)

"bit scan reverse", find most significant set bit in word (-> LOG2(word))

Definition at line 299 of file bitops.h.

## l4util_btc()

int l4util_btc | ( | int | b,
|  | volatile l4_umword_t * | dest )

inline

Bit test and complement.

Parameters

  b | bit position
  dest | destination operand

Returns
  Old value of bit b.

Complement bit b and return old value.

Definition at line 394 of file bitops.h.

## l4util_btr()

int l4util_btr | ( | int | b,
|  | volatile l4_umword_t * | dest )

inline

Bit test and reset.

Parameters

  b | bit position
  dest | destination operand

Returns
  Old value of bit b.

Reset bit b and return old value.

Definition at line 278 of file bitops.h.

References l4util_cmpxchg().

Here is the call graph for this function:

## l4util_bts()

int l4util_bts | ( | int | b,
|  | volatile l4_umword_t * | dest )

inline

Bit test and set.

Parameters

  b | bit position
  dest | destination operand

Returns
  Old value of bit b.

Set the b bit of dest to 1 and return the old value.

Definition at line 256 of file bitops.h.

References l4util_cmpxchg().

Here is the call graph for this function:

## l4util_clear_bit()

void l4util_clear_bit | ( | int | b,
|  | volatile l4_umword_t * | dest )

inline

Clear bit in memory.

Parameters

  b | bit position
  dest | destination operand

Definition at line 226 of file bitops.h.

References l4util_cmpxchg().

Here is the call graph for this function:

## l4util_complement_bit()

void l4util_complement_bit | ( | int | b,
|  | volatile l4_umword_t * | dest )

inline

Complement bit in memory.

Parameters

  b | bit position
  dest | destination operand

Definition at line 359 of file bitops.h.

## l4util_find_first_set_bit()

int l4util_find_first_set_bit | ( | const void * | dest,
|  | l4_size_t | size )

inline

Find the first set bit in a memory region.

Parameters

  dest | bit string
  size | size of string in bits (must be a multiple of L4_MWORD_BITS!)

Returns
  number of the first set bit, >= size if no bit is set

Definition at line 400 of file bitops.h.

## l4util_find_first_zero_bit()

int l4util_find_first_zero_bit | ( | const void * | dest,
|  | l4_size_t | size )

inline

Find the first zero bit in a memory region.

Parameters

  dest | bit string
  size | size of string in bits (must be a multiple of L4_MWORD_BITS!)

Returns
  number of the first zero bit, >= size if no bit is set

Definition at line 333 of file bitops.h.

## l4util_next_power2()

int l4util_next_power2 | ( | unsigned long | val | ) |

inline

Find the next power of 2 for a given number.

Parameters

  val | initial value

Returns
  next-highest power of 2

Definition at line 373 of file bitops.h.

## l4util_set_bit()

void l4util_set_bit | ( | int | b,
|  | volatile l4_umword_t * | dest )

inline

Set bit in memory.

Parameters

  b | bit position
  dest | destination operand

Definition at line 207 of file bitops.h.

References l4util_cmpxchg().

Here is the call graph for this function:

## l4util_test_bit()

int l4util_test_bit | ( | int | b,
|  | const volatile l4_umword_t * | dest )

inline

Test bit (return value of bit).

Parameters

  b | bit position
  dest | destination operand

Returns
  Value of bit b.

Definition at line 244 of file bitops.h.