Bienvenue sur le site de la LibLapin.
Jetez un coup d'oeil en bas de la page pour choisir votre niveau de documentation en fonction de votre niveau avec la LibLapin.
Pour l'instant, c'est réglé sur 'Manuel complet'. Si c'est votre première fois avec la LibLapin, il vaudrait mieux choisir 'Débutant'.
De même, n'oubliez pas de préciser une version de la bibliothèque.

LibLapin's logo

LibLapin

Bitfield





This module bring a set of macros to manipulates a byte array as a bit one.


The bitfield module header is lapin/container/bitfield.h.


Description

     The t‌_‌b‌u‌n‌n‌y‌_‌b‌i‌t‌f‌i‌e‌l‌d type is an abstract type that can only be manipulated throught Bunny Bitfield's functions. An instance of this type cannot be declared on stack but have to be created by b‌u‌n‌n‌y‌_‌n‌e‌w‌_‌b‌i‌t‌f‌i‌e‌l‌d and to be deleted by b‌u‌n‌n‌y‌_‌d‌e‌l‌e‌t‌e‌_‌b‌i‌t‌f‌i‌e‌l‌d.
The purpose of t‌_‌b‌u‌n‌n‌y‌_‌b‌i‌t‌f‌i‌e‌l‌d is to contain a lot of boolean values in the minimal possible space. This container allows you to store up to height boolean per byte.

Alternative types can be used if you need to declare a bitfield on stack.



INDEX


Description

     Create a bitfield with a length matching the sent value in bits. Bits are initialized to false.

The returned memory space must be freed with b‌u‌n‌n‌y‌_‌d‌e‌l‌e‌t‌e‌_‌b‌i‌t‌f‌i‌e‌l‌d.

Parameters

  • size_t bit:
         The amount of bits to reserve.

Return value

  • On success, the function returns the address of the first byte of the bitfield.
  • On failure, it returns NULL.

Error values and logs

On error, b‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • ENOMEM:
         Out of memory.

Logs written by this function are tagged with the "allocator" label.




INDEX


Description

     Create a bitfield with a length matching the sent value in bits. The allocation is made with bunny_alloca on the system stack, so it is destroyed when leaving the function.
Bits are not initialized.

The returned memory space must not be freed.

Parameters

  • size_t bit:
         The amount of bits to reserve.

Return value

  • The function returns the address of the first byte of the bitfield.



INDEX


Description

     Free a bitfield that was created by a call to b‌u‌n‌n‌y‌_‌n‌e‌w‌_‌b‌i‌t‌f‌i‌e‌l‌d.

Parameters


Logs

Logs written by this function are tagged with the "allocator" label.




INDEX


Description

     Set to true the bit at position idx inside bitfield.

Parameters




INDEX


Description

     Set to false the bit at position idx inside bitfield.

Parameters




INDEX


Description

     Get the bit at position idx inside bitfield.

Parameters


Return value

The bit status: true or false.




INDEX


Description

     The t‌_‌b‌u‌n‌n‌y‌_‌a‌u‌t‌o‌_‌b‌i‌t‌f‌i‌e‌l‌d‌6‌4 type is a 64 bits long bitfield. It is an alternative of t‌_‌b‌u‌n‌n‌y‌_‌b‌i‌t‌f‌i‌e‌l‌d that can be convenienly allocated on stack. The drawback of this is that it is fixed length.



INDEX


Description

     The t‌_‌b‌u‌n‌n‌y‌_‌a‌u‌t‌o‌_‌b‌i‌t‌f‌i‌e‌l‌d‌3‌2 type is a 32 bits long bitfield. It is an alternative of t‌_‌b‌u‌n‌n‌y‌_‌b‌i‌t‌f‌i‌e‌l‌d that can be convenienly allocated on stack. The drawback of this is that it is fixed length.


INDEX


Description

     The t‌_‌b‌u‌n‌n‌y‌_‌a‌u‌t‌o‌_‌b‌i‌t‌f‌i‌e‌l‌d‌1‌6 type is a 16 bits long bitfield. It is an alternative of t‌_‌b‌u‌n‌n‌y‌_‌b‌i‌t‌f‌i‌e‌l‌d that can be convenienly allocated on stack. The drawback of this is that it is fixed length.



INDEX


Description

     The t‌_‌b‌u‌n‌n‌y‌_‌a‌u‌t‌o‌_‌b‌i‌t‌f‌i‌e‌l‌d‌8 type is a 8 bits long bitfield. It is an alternative of t‌_‌b‌u‌n‌n‌y‌_‌b‌i‌t‌f‌i‌e‌l‌d that can be convenienly allocated on stack. The drawback of this is that it is fixed length.


INDEX

Macro void *b‌u‌n‌n‌y‌_‌a‌u‌t‌o‌_‌b‌i‌t‌f‌i‌e‌l‌d‌_‌s‌e‌t(t_bunny_auto_bitfieldX bitfield, size_t idx);

Description

     Set to true the bit at position idx inside bitfield.

Parameters




INDEX

Macro void *b‌u‌n‌n‌y‌_‌a‌u‌t‌o‌_‌b‌i‌t‌f‌i‌e‌l‌d‌_‌c‌l‌r(t_bunny_auto_bitfieldX bitfield, size_t idx);

Description

     Set to false the bit at position idx inside bitfield.

Parameters




INDEX

Macro void *b‌u‌n‌n‌y‌_‌a‌u‌t‌o‌_‌b‌i‌t‌f‌i‌e‌l‌d‌_‌g‌e‌t(const t_bunny_auto_bitfieldX bitfield, size_t idx);

Description

     Get the bit at position idx inside bitfield.

Parameters


Return value

The bit status: true or false.




INDEX