Libtrap: Internal development docs
0.11.7
|
Macros | |
#define | TB_FLUSH_START(wrb, bl, res) |
#define | TB_FLUSH_END(rdb, bl, s) |
Functions | |
int | tb_pushmess (trap_buffer_t *tb, const void *data, uint16_t size) |
int | tb_pushmess2 (trap_buffer_t *tb, const void *d1, uint16_t s1, const void *d2, uint16_t s2) |
void | tb_clear_unused (trap_buffer_t *tb) |
void | tb_next_wr_block (trap_buffer_t *tb) |
void | tb_first_wr_block (trap_buffer_t *tb) |
A set of functions used for output IFC (module sends messages).
#define TB_FLUSH_END | ( | rdb, | |
bl, | |||
s | |||
) |
Unlock the current free block after writing its content.
It MUST NOT be called when TB_FILL_START() returned TB_FULL.
[in] | rdb | Pointer to the buffer. |
[in] | bl | Pointer to block (tb_block_t *bl). |
[in] | s | Size of data written into the block. This will be set into header. |
Definition at line 296 of file trap_buffer.h.
#define TB_FLUSH_START | ( | wrb, | |
bl, | |||
res | |||
) |
Lock the current free block for getting its content.
After this code, it is possible to read size and data from bl. See TB_FLUSH_START() for unlocking the block.
Pseudocode: trap_buffer_t *b = tb_init(10, 100000); tb_block_t *bl; TB_FILL_START(b, &bl, res); if (res == TB_SUCCESS) { s = recv(...); TB_FILL_END(b, bl, s); }
[in] | wrb | Pointer to the buffer. |
[out] | bl | Pointer to block (tb_block_t **bl). |
[out] | res | Result of TB_FILL_START(), it is set to TB_SUCCESS or TB_FULL. |
Definition at line 273 of file trap_buffer.h.
void tb_clear_unused | ( | trap_buffer_t * | tb | ) |
Go through all blocks and those which are not used (refcount) mark as free.
[in] | tb | Pointer to the TRAP buffer. |
Definition at line 357 of file trap_buffer.c.
void tb_first_wr_block | ( | trap_buffer_t * | tb | ) |
Move to the first block for writing.
This function moves cur_block pointer to the first block.
[in] | tb | Pointer to the TRAP buffer |
Definition at line 130 of file trap_buffer.c.
void tb_next_wr_block | ( | trap_buffer_t * | tb | ) |
Move to the next block for writing.
This function moves cur_block pointer to the next block (it overflows after nblocks).
[in] | tb | Pointer to the TRAP buffer |
Definition at line 103 of file trap_buffer.c.
int tb_pushmess | ( | trap_buffer_t * | tb, |
const void * | data, | ||
uint16_t | size | ||
) |
Push message into the current block
[in] | tb | Pointer to the buffer. |
[in] | data | Pointer to the message to send. |
[in] | size | Size of the message to send. |
Definition at line 262 of file trap_buffer.c.
int tb_pushmess2 | ( | trap_buffer_t * | tb, |
const void * | d1, | ||
uint16_t | s1, | ||
const void * | d2, | ||
uint16_t | s2 | ||
) |
Push message (consisting of d1 and d2 parts) into the current block
[in] | tb | Pointer to the buffer. |
[in] | d1 | Pointer to the 1st part of the message to send. |
[in] | s1 | Size of the 1st part of the message to send. |
[in] | d2 | Pointer to the 2nd part of the message to send. |
[in] | s2 | Size of the 2nd part of the message to send. |
Definition at line 291 of file trap_buffer.c.