Flash Translation Layer  1.0
Macros | Functions
bits.h File Reference
#include <stdint.h>
#include <limits.h>
Include dependency graph for bits.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BITS_NOT_FOUND   ((uint64_t)UINT64_MAX)
 
#define BITS_PER_BYTE   (8)
 
#define BITS_PER_UINT64   (BITS_PER_BYTE * sizeof(uint64_t))
 
#define BITS_TO_UINT64_ALIGN(x)   (((uint64_t)x / BITS_PER_UINT64 + 1) * sizeof(uint64_t))
 
#define BITS_TO_UINT64(x)   ((uint64_t)x / BITS_PER_UINT64)
 

Functions

static void set_bit (uint64_t *bits, uint64_t index)
 set the index position bit in the array(uint64_t) More...
 
static int get_bit (uint64_t *bits, uint64_t index)
 get the value at the index position bit in the array(uint64_t) More...
 
static void reset_bit (uint64_t *bits, uint64_t index)
 reset the index position bit in the array(uint64_t) More...
 
static uint64_t find_first_zero_bit (uint64_t *bits, uint64_t size, uint64_t idx)
 find first zero bit in the array(uint64_t) More...
 
static uint64_t find_first_one_bit (uint64_t *bits, uint64_t size, uint64_t idx)
 find first one bit in the array(uint64_t) More...
 

Macro Definition Documentation

◆ BITS_NOT_FOUND

#define BITS_NOT_FOUND   ((uint64_t)UINT64_MAX)

◆ BITS_PER_BYTE

#define BITS_PER_BYTE   (8)

◆ BITS_PER_UINT64

#define BITS_PER_UINT64   (BITS_PER_BYTE * sizeof(uint64_t))

◆ BITS_TO_UINT64

#define BITS_TO_UINT64 (   x)    ((uint64_t)x / BITS_PER_UINT64)

◆ BITS_TO_UINT64_ALIGN

#define BITS_TO_UINT64_ALIGN (   x)    (((uint64_t)x / BITS_PER_UINT64 + 1) * sizeof(uint64_t))

Function Documentation

◆ find_first_one_bit()

static uint64_t find_first_one_bit ( uint64_t *  bits,
uint64_t  size,
uint64_t  idx 
)
static

find first one bit in the array(uint64_t)

Parameters
bitsarray which contains the bitmap
sizebitmap's size (the number of bits NOT bytes)
idxstart position bit
Returns
first one bit position

◆ find_first_zero_bit()

static uint64_t find_first_zero_bit ( uint64_t *  bits,
uint64_t  size,
uint64_t  idx 
)
static

find first zero bit in the array(uint64_t)

Parameters
bitsarray which contains the bitmap
sizebitmap's size (the number of bits NOT bytes)
idxstart position bit
Returns
first zero bit position

◆ get_bit()

static int get_bit ( uint64_t *  bits,
uint64_t  index 
)
static

get the value at the index position bit in the array(uint64_t)

Parameters
bitsarray which contains the bitmap
indexget position (bit position NOT byte or uint64_t position)
Returns
bit status at the index position

◆ reset_bit()

static void reset_bit ( uint64_t *  bits,
uint64_t  index 
)
static

reset the index position bit in the array(uint64_t)

Parameters
bitsarray which contains the bitmap
indexreset position (bit position NOT byte or uint64_t position)

◆ set_bit()

static void set_bit ( uint64_t *  bits,
uint64_t  index 
)
static

set the index position bit in the array(uint64_t)

Parameters
bitsarray which contains the bitmap
indexset position (bit position NOT byte or uint64_t position)