ddat interop with dat js cable interop with cabal js ddat's frontend = dat-thang cable fe = cable-thang dillo support based on cel's dillo-dat bootstrap node xplatform support Signed-off-by: divo <418@cryspace.space>
28 lines
1.1 KiB
C
28 lines
1.1 KiB
C
#ifndef SLEEP_BITFIELD_H
|
|
#define SLEEP_BITFIELD_H
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#define SLEEP_BITFIELD_DATA_BYTES 1024u
|
|
#define SLEEP_BITFIELD_TREE_BYTES 2048u
|
|
#define SLEEP_BITFIELD_INDEX_BYTES 256u
|
|
#define SLEEP_BITFIELD_RESERVED_BYTES 256u
|
|
|
|
typedef struct sleep_bitfield {
|
|
uint8_t data[SLEEP_BITFIELD_DATA_BYTES];
|
|
uint8_t tree[SLEEP_BITFIELD_TREE_BYTES];
|
|
uint8_t index[SLEEP_BITFIELD_INDEX_BYTES];
|
|
uint8_t reserved[SLEEP_BITFIELD_RESERVED_BYTES];
|
|
} sleep_bitfield_t;
|
|
|
|
void sleep_bitfield_clear(sleep_bitfield_t *field);
|
|
int sleep_bitfield_get_data(const sleep_bitfield_t *field, size_t bit);
|
|
int sleep_bitfield_get_tree(const sleep_bitfield_t *field, size_t bit);
|
|
int sleep_bitfield_set_data(sleep_bitfield_t *field, size_t bit, int present);
|
|
int sleep_bitfield_set_tree(sleep_bitfield_t *field, size_t bit, int present);
|
|
void sleep_bitfield_reindex(sleep_bitfield_t *field);
|
|
size_t sleep_bitfield_next_data(const sleep_bitfield_t *field, size_t start, int present);
|
|
int sleep_bitfield_encode(const sleep_bitfield_t *field, uint8_t *out, size_t capacity);
|
|
int sleep_bitfield_decode(sleep_bitfield_t *field, const uint8_t *input, size_t length);
|
|
#endif
|