MentOS  0.8.0
The Mentoring Operating System
Macros | Functions
bitops.h File Reference

Bitmasks functions. More...

Go to the source code of this file.

Macros

#define bit_set(V, B)   ((V) | (1U << (B)))
 Sets the given bit.
 
#define bit_clear(V, B)   ((V) & ~(1U << (B)))
 Clears the given bit.
 
#define bit_flip(V, B)   ((V) ^ (1U << (B)))
 Flips the given bit.
 
#define bit_check(V, B)   ((V) & (1U << (B)))
 Checks if the given bit is 1.
 
#define bit_toggle(V, B, C)   ((C) ? bit_set(V, B) : bit_clear(V, B))
 Sets the given bit based on control bit C.
 
#define bit_set_assign(V, B)   ((V) |= (1U << (B)))
 Sets the given bit, permanently.
 
#define bit_clear_assign(V, B)   ((V) &= ~(1U << (B)))
 Clears the given bit, permanently.
 
#define bit_flip_assign(V, B)   ((V) ^= (1U << (B)))
 Flips the given bit, permanently.
 
#define bit_toggle_assign(V, B, C)   ((C) ? bit_set_assign(V, B) : bit_clear_assign(V, B))
 Sets the given bit based on control bit C.
 
#define bitmask_set(V, M)   ((V) | (M))
 Sets the bits identified by the mask.
 
#define bitmask_clear(V, M)   ((V) & ~(M))
 Clears the bits identified by the mask.
 
#define bitmask_flip(V, M)   ((V) ^ (M))
 Flips the bits identified by the mask.
 
#define bitmask_check(V, M)   ((V) & (M))
 Checks if the bits identified by the mask are all 1.
 
#define bitmask_exact(V, M)   (((V) & (M)) == (M))
 Checks if all the bits identified by the mask are all 1.
 
#define bitmask_set_assign(V, M)   ((V) |= (M))
 Sets the bits identified by the mask, permanently.
 
#define bitmask_clear_assign(V, M)   ((V) &= ~(M))
 Clears the bits identified by the mask, permanently.
 
#define bitmask_flip_assign(V, M)   ((V) ^= (M))
 Flips the bits identified by the mask, permanently.
 

Functions

static int find_first_zero (unsigned long value)
 Finds the first bit at zero, starting from the less significative bit. More...
 
static int find_first_non_zero (unsigned long value)
 Finds the first bit not zero, starting from the less significative bit. More...
 

Detailed Description

Bitmasks functions.

Function Documentation

◆ find_first_non_zero()

static int find_first_non_zero ( unsigned long  value)
inlinestatic

Finds the first bit not zero, starting from the less significative bit.

Parameters
valuethe value we need to analyze.
Returns
the position of the first non-zero bit.

◆ find_first_zero()

static int find_first_zero ( unsigned long  value)
inlinestatic

Finds the first bit at zero, starting from the less significative bit.

Parameters
valuethe value we need to analyze.
Returns
the position of the first zero bit.