libcoap  4.3.0rc1
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

COAP_STATIC_INLINE int bits_setb (uint8_t *vec, size_t size, uint8_t bit)
 Sets the bit bit in bit-vector vec. More...
 
COAP_STATIC_INLINE int bits_clrb (uint8_t *vec, size_t size, uint8_t bit)
 Clears the bit bit from bit-vector vec. More...
 
COAP_STATIC_INLINE 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()

COAP_STATIC_INLINE int bits_clrb ( uint8_t *  vec,
size_t  size,
uint8_t  bit 
)

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
vecThe bit-vector to change.
sizeThe size of vec in bytes.
bitThe 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()

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

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
vecThe bit-vector to read from.
sizeThe size of vec in bytes.
bitThe bit to get from vec.
Returns
1 if the bit is set, 0 otherwise.

Definition at line 71 of file bits.h.

◆ bits_setb()

COAP_STATIC_INLINE int bits_setb ( uint8_t *  vec,
size_t  size,
uint8_t  bit 
)

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
vecThe bit-vector to change.
sizeThe size of vec in bytes.
bitThe bit to set in vec.
Returns
-1 if bit does not fit into vec, 1 otherwise.

Definition at line 32 of file bits.h.