Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
common.h File Reference

Definitions common to the whole liblzma library. More...

#include "sysdefs.h"
#include "mythread.h"
#include "tuklib_integer.h"
#include "lzma.h"

Go to the source code of this file.

Data Structures

struct  lzma_filter_info_s
 
struct  lzma_next_coder_s
 Hold data and function pointers of the next filter in the chain. More...
 
struct  lzma_internal_s
 

Macros

#define LZMA_API_EXPORT
 
#define LZMA_API(type)
 
#define lzma_has_attribute(attr)
 
#define likely(expr)
 
#define unlikely(expr)
 
#define LZMA_BUFFER_SIZE   4096
 Size of temporary buffers needed in some filters.
 
#define LZMA_THREADS_MAX   16384
 
#define LZMA_MEMUSAGE_BASE   (UINT64_C(1) << 15)
 
#define LZMA_FILTER_RESERVED_START   (LZMA_VLI_C(1) << 62)
 
#define LZMA_SUPPORTED_FLAGS
 
#define LZMA_ACTION_MAX   ((unsigned int)(LZMA_FULL_BARRIER))
 Largest valid lzma_action value as unsigned integer.
 
#define LZMA_TIMED_OUT   LZMA_RET_INTERNAL1
 
#define LZMA_INDEX_DETECTED   LZMA_RET_INTERNAL2
 
#define LZMA_NEXT_CODER_INIT
 Macro to initialize lzma_next_coder structure.
 
#define return_if_error(expr)
 Return if expression doesn't evaluate to LZMA_OK.
 
#define lzma_next_coder_init(func, next, allocator)
 
#define lzma_next_strm_init(func, strm, ...)
 

Typedefs

typedef struct lzma_next_coder_s lzma_next_coder
 
typedef struct lzma_filter_info_s lzma_filter_info
 
typedef lzma_ret(* lzma_init_function) (lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter_info *filters)
 Type of a function used to initialize a filter encoder or decoder.
 
typedef lzma_ret(* lzma_code_function) (void *coder, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action)
 
typedef void(* lzma_end_function) (void *coder, const lzma_allocator *allocator)
 Type of a function to free the memory allocated for the coder.
 

Functions

void * lzma_alloc (size_t size, const lzma_allocator *allocator) lzma_attribute((__malloc__)) lzma_attr_alloc_size(1)
 Allocates memory.
 
void * lzma_attribute ((__malloc__)) lzma_attr_alloc_size(1) lzma_alloc_zero(size_t size
 
void lzma_free (void *ptr, const lzma_allocator *allocator)
 Frees memory.
 
lzma_ret lzma_strm_init (lzma_stream *strm)
 
lzma_ret lzma_next_filter_init (lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter_info *filters)
 
lzma_ret lzma_next_filter_update (lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter *reversed_filters)
 
void lzma_next_end (lzma_next_coder *next, const lzma_allocator *allocator)
 
size_t lzma_bufcpy (const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size)
 

Variables

void const lzma_allocatorallocator
 

Detailed Description

Definitions common to the whole liblzma library.

Macro Definition Documentation

◆ likely

#define likely ( expr)
Value:
(expr)

◆ LZMA_ACTION_MAX

#define LZMA_ACTION_MAX   ((unsigned int)(LZMA_FULL_BARRIER))

Largest valid lzma_action value as unsigned integer.

◆ LZMA_API

#define LZMA_API ( type)
Value:
#define LZMA_API_EXPORT
Definition common.h:30
#define LZMA_API_CALL
Definition lzma.h:202

◆ LZMA_API_EXPORT

#define LZMA_API_EXPORT

◆ LZMA_BUFFER_SIZE

#define LZMA_BUFFER_SIZE   4096

Size of temporary buffers needed in some filters.

◆ LZMA_FILTER_RESERVED_START

#define LZMA_FILTER_RESERVED_START   (LZMA_VLI_C(1) << 62)

Start of internal Filter ID space. These IDs must never be used in Streams.

◆ lzma_has_attribute

#define lzma_has_attribute ( attr)
Value:
0

◆ LZMA_INDEX_DETECTED

#define LZMA_INDEX_DETECTED   LZMA_RET_INTERNAL2

Special return value (lzma_ret) for use in stream_decoder_mt.c to indicate Index was detected instead of a Block Header.

◆ LZMA_MEMUSAGE_BASE

#define LZMA_MEMUSAGE_BASE   (UINT64_C(1) << 15)

Starting value for memory usage estimates. Instead of calculating size of every structure and taking into account malloc() overhead etc., we add a base size to all memory usage estimates. It's not very accurate but should be easily good enough.

◆ LZMA_NEXT_CODER_INIT

#define LZMA_NEXT_CODER_INIT
Value:
.coder = NULL, \
.init = (uintptr_t)(NULL), \
.code = NULL, \
.end = NULL, \
.get_progress = NULL, \
.get_check = NULL, \
.memconfig = NULL, \
.update = NULL, \
.set_out_limit = NULL, \
}
size_t uintptr_t
Definition fuzzer.c:71
struct lzma_next_coder_s lzma_next_coder
Definition common.h:148
#define LZMA_VLI_UNKNOWN
VLI value to denote that the value is unknown.
Definition vli.h:39
#define NULL
Definition getopt1.c:37

Macro to initialize lzma_next_coder structure.

◆ lzma_next_coder_init

#define lzma_next_coder_init ( func,
next,
allocator )
Value:
do { \
if ((uintptr_t)(func) != (next)->init) \
lzma_next_end(next, allocator); \
(next)->init = (uintptr_t)(func); \
} while (0)
void const lzma_allocator * allocator
Definition common.h:307

If next isn't already initialized, free the previous coder. Then mark that next is possibly initialized for the coder using this macro. "Possibly" means that if e.g. allocation of next->coder fails, the structure isn't actually initialized for this coder, but leaving next->init to func is still OK.

◆ lzma_next_strm_init

#define lzma_next_strm_init ( func,
strm,
... )
Value:
do { \
return_if_error(lzma_strm_init(strm)); \
const lzma_ret ret_ = func(&(strm)->internal->next, \
(strm)->allocator, __VA_ARGS__); \
if (ret_ != LZMA_OK) { \
lzma_end(strm); \
return ret_; \
} \
} while (0)
lzma_ret lzma_strm_init(lzma_stream *strm)
Definition common.c:170
lzma_ret
Return values used by several functions in liblzma.
Definition base.h:57
@ LZMA_OK
Operation completed successfully.
Definition base.h:58

Initializes lzma_strm and calls func() to initialize strm->internal->next. (The function being called will use lzma_next_coder_init()). If initialization fails, memory that wasn't freed by func() is freed along strm->internal.

◆ LZMA_SUPPORTED_FLAGS

#define LZMA_SUPPORTED_FLAGS
Value:
#define LZMA_TELL_ANY_CHECK
Definition container.h:474
#define LZMA_IGNORE_CHECK
Definition container.h:498
#define LZMA_CONCATENATED
Definition container.h:515
#define LZMA_TELL_NO_CHECK
Definition container.h:457
#define LZMA_TELL_UNSUPPORTED_CHECK
Definition container.h:466
#define LZMA_FAIL_FAST
Definition container.h:645

Supported flags that can be passed to lzma_stream_decoder(), lzma_auto_decoder(), or lzma_stream_decoder_mt().

◆ LZMA_THREADS_MAX

#define LZMA_THREADS_MAX   16384

Maximum number of worker threads within one multithreaded component. The limit exists solely to make it simpler to prevent integer overflows when allocating structures etc. This should be big enough for now... the code won't scale anywhere close to this number anyway.

◆ LZMA_TIMED_OUT

#define LZMA_TIMED_OUT   LZMA_RET_INTERNAL1

Special return value (lzma_ret) to indicate that a timeout was reached and lzma_code() must not return LZMA_BUF_ERROR. This is converted to LZMA_OK in lzma_code().

◆ return_if_error

#define return_if_error ( expr)
Value:
do { \
const lzma_ret ret_ = (expr); \
if (ret_ != LZMA_OK) \
return ret_; \
} while (0)

Return if expression doesn't evaluate to LZMA_OK.

There are several situations where we want to return immediately with the value of expr if it isn't LZMA_OK. This macro shortens the code a little.

◆ unlikely

#define unlikely ( expr)
Value:
(expr)

Typedef Documentation

◆ lzma_code_function

typedef lzma_ret(* lzma_code_function) (void *coder, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action)

Type of a function to do some kind of coding work (filters, Stream, Block encoders/decoders etc.). Some special coders use don't use both input and output buffers, but for simplicity they still use this same function prototype.

◆ lzma_end_function

typedef void(* lzma_end_function) (void *coder, const lzma_allocator *allocator)

Type of a function to free the memory allocated for the coder.

◆ lzma_filter_info

◆ lzma_init_function

Type of a function used to initialize a filter encoder or decoder.

◆ lzma_next_coder

Function Documentation

◆ lzma_alloc()

void * lzma_alloc ( size_t size,
const lzma_allocator * allocator )
extern

Allocates memory.

◆ lzma_attribute()

void * lzma_attribute ( (__malloc__) )
extern

Allocates memory and zeroes it (like calloc()). This can be faster than lzma_alloc() + memzero() while being backward compatible with custom allocators.

◆ lzma_bufcpy()

size_t lzma_bufcpy ( const uint8_t *restrict in,
size_t *restrict in_pos,
size_t in_size,
uint8_t *restrict out,
size_t *restrict out_pos,
size_t out_size )
extern

Copy as much data as possible from in[] to out[] and update *in_pos and *out_pos accordingly. Returns the number of bytes copied.

◆ lzma_free()

void lzma_free ( void * ptr,
const lzma_allocator * allocator )
extern

Frees memory.

◆ lzma_next_end()

void lzma_next_end ( lzma_next_coder * next,
const lzma_allocator * allocator )
extern

Frees the memory allocated for next->coder either using next->end or, if next->end is NULL, using lzma_free.

◆ lzma_next_filter_init()

lzma_ret lzma_next_filter_init ( lzma_next_coder * next,
const lzma_allocator * allocator,
const lzma_filter_info * filters )
extern

Initializes the next filter in the chain, if any. This takes care of freeing the memory of previously initialized filter if it is different than the filter being initialized now. This way the actual filter initialization functions don't need to use lzma_next_coder_init macro.

◆ lzma_next_filter_update()

lzma_ret lzma_next_filter_update ( lzma_next_coder * next,
const lzma_allocator * allocator,
const lzma_filter * reversed_filters )
extern

Update the next filter in the chain, if any. This checks that the application is not trying to change the Filter IDs.

◆ lzma_strm_init()

lzma_ret lzma_strm_init ( lzma_stream * strm)
extern

Allocates strm->internal if it is NULL, and initializes *strm and strm->internal. This function is only called via lzma_next_strm_init macro.

Variable Documentation

◆ allocator

void const lzma_allocator* allocator