Rizin
unix-like reverse engineering framework and cli tools
|
Output queue handling in multithreaded coding. More...
#include "outqueue.h"
Go to the source code of this file.
Macros | |
#define | BUF_SIZE_MAX (UINT64_MAX / LZMA_THREADS_MAX / 2 / 2) |
Functions | |
static lzma_ret | get_options (uint64_t *bufs_alloc_size, uint32_t *bufs_count, uint64_t buf_size_max, uint32_t threads) |
uint64_t | lzma_outq_memusage (uint64_t buf_size_max, uint32_t threads) |
Calculate the memory usage of an output queue. More... | |
lzma_ret | lzma_outq_init (lzma_outq *outq, const lzma_allocator *allocator, uint64_t buf_size_max, uint32_t threads) |
Initialize an output queue. More... | |
void | lzma_outq_end (lzma_outq *outq, const lzma_allocator *allocator) |
Free the memory associated with the output queue. More... | |
lzma_outbuf * | lzma_outq_get_buf (lzma_outq *outq) |
Get a new buffer. More... | |
bool | lzma_outq_is_readable (const lzma_outq *outq) |
Test if there is data ready to be read. More... | |
lzma_ret | lzma_outq_read (lzma_outq *restrict outq, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_vli *restrict unpadded_size, lzma_vli *restrict uncompressed_size) |
Read finished data. More... | |
Output queue handling in multithreaded coding.
Definition in file outqueue.c.
#define BUF_SIZE_MAX (UINT64_MAX / LZMA_THREADS_MAX / 2 / 2) |
This is to ease integer overflow checking: We may allocate up to 2 * LZMA_THREADS_MAX buffers and we need some extra memory for other data structures (that's the second /2).
Definition at line 19 of file outqueue.c.
|
static |
Definition at line 23 of file outqueue.c.
References BUF_SIZE_MAX, LZMA_OK, LZMA_OPTIONS_ERROR, LZMA_THREADS_MAX, and threads.
Referenced by lzma_outq_init(), and lzma_outq_memusage().
void lzma_outq_end | ( | lzma_outq * | outq, |
const lzma_allocator * | allocator | ||
) |
Free the memory associated with the output queue.
Definition at line 101 of file outqueue.c.
References allocator, lzma_outq::bufs, lzma_outq::bufs_mem, lzma_free(), and NULL.
Referenced by lzma_outq_init(), and stream_encoder_mt_end().
lzma_outbuf* lzma_outq_get_buf | ( | lzma_outq * | outq | ) |
Get a new buffer.
lzma_outq_has_buf() must be used to check that there is a buffer available before calling lzma_outq_get_buf().
Definition at line 114 of file outqueue.c.
References assert(), lzma_outbuf::buf, lzma_outq::buf_size_max, lzma_outq::bufs, lzma_outq::bufs_allocated, lzma_outq::bufs_mem, lzma_outq::bufs_pos, and lzma_outq::bufs_used.
Referenced by get_thread().
lzma_ret lzma_outq_init | ( | lzma_outq * | outq, |
const lzma_allocator * | allocator, | ||
uint64_t | buf_size_max, | ||
uint32_t | threads | ||
) |
Initialize an output queue.
outq | Pointer to an output queue. Before calling this function the first time, *outq should have been zeroed with memzero() so that this function knows that there are no previous allocations to free. |
allocator | Pointer to allocator or NULL |
buf_size_max | Maximum amount of data that a single buffer in the queue may need to store. |
threads | Number of buffers that may be in use concurrently. Note that more than this number of buffers will actually get allocated to improve performance when buffers finish out of order. |
Definition at line 57 of file outqueue.c.
References allocator, lzma_outq::buf_size_max, lzma_outq::bufs, lzma_outq::bufs_allocated, lzma_outq::bufs_mem, lzma_outq::bufs_pos, lzma_outq::bufs_used, get_options(), lzma_alloc(), LZMA_MEM_ERROR, LZMA_OK, lzma_outq_end(), NULL, lzma_outq::read_pos, return_if_error, SIZE_MAX, and threads.
Referenced by stream_encoder_mt_init().
Test if there is data ready to be read.
Call to this function must be protected with the same mutex that is used to protect lzma_outbuf.finished.
Definition at line 136 of file outqueue.c.
References lzma_outq::bufs, lzma_outq::bufs_allocated, lzma_outq::bufs_pos, lzma_outq::bufs_used, lzma_outbuf::finished, and i.
Referenced by wait_for_work().
Calculate the memory usage of an output queue.
Definition at line 42 of file outqueue.c.
References get_options(), LZMA_OK, threads, and UINT64_MAX.
Referenced by LZMA_API().
lzma_ret lzma_outq_read | ( | lzma_outq *restrict | outq, |
uint8_t *restrict | out, | ||
size_t *restrict | out_pos, | ||
size_t | out_size, | ||
lzma_vli *restrict | unpadded_size, | ||
lzma_vli *restrict | uncompressed_size | ||
) |
Read finished data.
outq | Pointer to an output queue |
out | Beginning of the output buffer |
out_pos | The next byte will be written to out[*out_pos]. |
out_size | Size of the out buffer; the first byte into which no data is written to is out[out_size]. |
unpadded_size | Unpadded Size from the Block encoder |
uncompressed_size | Uncompressed Size from the Block encoder |
Definition at line 147 of file outqueue.c.
References i, lzma_bufcpy(), LZMA_OK, LZMA_STREAM_END, out, out_pos, uncompressed_size, and unpadded_size.
Referenced by stream_encode_mt().