51 #include <arpa/inet.h> 56 #define TB_USED_NEWBLOCK 3 273 #define TB_FLUSH_START(wrb, bl, res) do { \ 275 (*bl) = wrb->cur_rd_block; \ 276 tb_block_lock(*bl); \ 277 if (tb_isblockfree(*bl) != TB_FULL) { \ 279 tb_block_unlock(*bl); \ 296 #define TB_FLUSH_END(rdb, bl, s) do { \ 297 if (bl->refcount == 0) { \ 299 bl->data->size = 0; \ 300 tb_next_rd_block(rdb); \ 302 tb_block_unlock(bl); \ 362 #define TB_FILL_START(rdb, bl, res) do { \ 364 (*bl) = rdb->cur_wr_block; \ 365 tb_block_lock(*bl); \ 366 if (tb_isblockfree(*bl) == TB_SUCCESS) { \ 367 tb_next_wr_block(rdb); \ 368 (res) = TB_SUCCESS; \ 371 tb_block_unlock(*bl); \ 386 #define TB_FILL_END(rdb, bl, s) do { \ 387 bl->data->size = s; \ 388 bl->write_data += s; \ 389 bl->read_data = bl->data->data; \ 390 tb_block_unlock(bl); \ uint16_t cur_wr_block_idx
int tb_unlock(trap_buffer_t *tb)
void tb_first_rd_block(trap_buffer_t *tb)
int tb_pushmess2(trap_buffer_t *tb, const void *d1, uint16_t s1, const void *d2, uint16_t s2)
uint16_t cur_rd_block_idx
void tb_next_rd_block(trap_buffer_t *tb)
int tb_block_unlock(tb_block_t *bl)
int tb_lock(trap_buffer_t *tb)
struct tb_block_s tb_block_t
void tb_first_wr_block(trap_buffer_t *tb)
int tb_pushmess(trap_buffer_t *tb, const void *data, uint16_t size)
void tb_destroy(trap_buffer_t **tb)
int tb_block_lock(tb_block_t *bl)
void tb_next_wr_block(trap_buffer_t *tb)
void tb_clear_unused(trap_buffer_t *tb)
trap_buffer_t * tb_init(uint16_t nblocks, uint32_t blocksize)
tb_block_t * cur_wr_block
struct trap_buffer_s trap_buffer_t
int tb_getmess(trap_buffer_t *tb, const void **data, uint16_t *size)
int tb_isblockfree(tb_block_t *bl)
tb_block_t * cur_rd_block
struct tb_block_data_s data[0]