bits.h File Reference

Bit vector manipulation. More...

`#include <stdint.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.

## Functions

static int | bits_setb (uint8_t *vec, size_t size, uint8_t bit)
| Sets the bit `bit` in bit-vector `vec`. More...
static int | bits_clrb (uint8_t *vec, size_t size, uint8_t bit)
| Clears the bit `bit` from bit-vector `vec`. More...
static int | bits_getb (const uint8_t *vec, size_t size, uint8_t bit)
| Gets the status of bit `bit` from bit-vector `vec`. More...

## Detailed Description

Bit vector manipulation.

Definition in file bits.h.

## Function Documentation

## bits_clrb()

static int bits_clrb | ( | uint8_t * | vec,
|  | size_t | size,
|  | uint8_t | bit
| ) |  |

inline static

Clears the bit `bit` from bit-vector `vec`.

This function returns `1` if bit was cleared or `-1` on error (i.e. when the given bit does not fit in the vector).

Parameters

  vec | The bit-vector to change.
  size | The size of `vec` in bytes.
  bit | The bit to clear from `vec`.

Returns
  `-1` if `bit` does not fit into `vec`, `1` otherwise.

Definition at line 52 of file bits.h.

## bits_getb()

static int bits_getb | ( | const uint8_t * | vec,
|  | size_t | size,
|  | uint8_t | bit
| ) |  |

inline static

Gets the status of bit `bit` from bit-vector `vec`.

This function returns `1` if the bit is set, `0` otherwise (even in case of an error).

Parameters

  vec | The bit-vector to read from.
  size | The size of `vec` in bytes.
  bit | The bit to get from `vec`.

Returns
  `1` if the bit is set, `0` otherwise.

Definition at line 71 of file bits.h.

## bits_setb()

static int bits_setb | ( | uint8_t * | vec,
|  | size_t | size,
|  | uint8_t | bit
| ) |  |

inline static

Sets the bit `bit` in bit-vector `vec`.

This function returns `1` if bit was set or `-1` on error (i.e. when the given bit does not fit in the vector).

Parameters

  vec | The bit-vector to change.
  size | The size of `vec` in bytes.
  bit | The bit to set in `vec`.

Returns
  `-1` if `bit` does not fit into `vec`, `1` otherwise.

Definition at line 32 of file bits.h.