common.h | common.h | |||
---|---|---|---|---|
skipping to change at line 35 | skipping to change at line 35 | |||
# endif | # endif | |||
// Don't use ifdef or defined() below. | // Don't use ifdef or defined() below. | |||
#elif HAVE_VISIBILITY | #elif HAVE_VISIBILITY | |||
# define LZMA_API_EXPORT __attribute__((__visibility__("default"))) | # define LZMA_API_EXPORT __attribute__((__visibility__("default"))) | |||
#else | #else | |||
# define LZMA_API_EXPORT | # define LZMA_API_EXPORT | |||
#endif | #endif | |||
#define LZMA_API(type) LZMA_API_EXPORT type LZMA_API_CALL | #define LZMA_API(type) LZMA_API_EXPORT type LZMA_API_CALL | |||
#define LZMA_UNSTABLE | ||||
#include "lzma.h" | #include "lzma.h" | |||
// These allow helping the compiler in some often-executed branches, whose | // These allow helping the compiler in some often-executed branches, whose | |||
// result is almost always the same. | // result is almost always the same. | |||
#ifdef __GNUC__ | #ifdef __GNUC__ | |||
# define likely(expr) __builtin_expect(expr, true) | # define likely(expr) __builtin_expect(expr, true) | |||
# define unlikely(expr) __builtin_expect(expr, false) | # define unlikely(expr) __builtin_expect(expr, false) | |||
#else | #else | |||
# define likely(expr) (expr) | # define likely(expr) (expr) | |||
# define unlikely(expr) (expr) | # define unlikely(expr) (expr) | |||
skipping to change at line 74 | skipping to change at line 72 | |||
/// Start of internal Filter ID space. These IDs must never be used | /// Start of internal Filter ID space. These IDs must never be used | |||
/// in Streams. | /// in Streams. | |||
#define LZMA_FILTER_RESERVED_START (LZMA_VLI_C(1) << 62) | #define LZMA_FILTER_RESERVED_START (LZMA_VLI_C(1) << 62) | |||
/// Supported flags that can be passed to lzma_stream_decoder() | /// Supported flags that can be passed to lzma_stream_decoder() | |||
/// or lzma_auto_decoder(). | /// or lzma_auto_decoder(). | |||
#define LZMA_SUPPORTED_FLAGS \ | #define LZMA_SUPPORTED_FLAGS \ | |||
( LZMA_TELL_NO_CHECK \ | ( LZMA_TELL_NO_CHECK \ | |||
| LZMA_TELL_UNSUPPORTED_CHECK \ | | LZMA_TELL_UNSUPPORTED_CHECK \ | |||
| LZMA_TELL_ANY_CHECK \ | | LZMA_TELL_ANY_CHECK \ | |||
| LZMA_IGNORE_CHECK \ | ||||
| LZMA_CONCATENATED ) | | LZMA_CONCATENATED ) | |||
/// Largest valid lzma_action value as unsigned integer. | ||||
#define LZMA_ACTION_MAX ((unsigned int)(LZMA_FULL_BARRIER)) | ||||
/// Special return value (lzma_ret) to indicate that a timeout was reached | /// 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 | /// and lzma_code() must not return LZMA_BUF_ERROR. This is converted to | |||
/// LZMA_OK in lzma_code(). This is not in the lzma_ret enumeration because | /// LZMA_OK in lzma_code(). This is not in the lzma_ret enumeration because | |||
/// there's no need to have it in the public API. | /// there's no need to have it in the public API. | |||
#define LZMA_TIMED_OUT 32 | #define LZMA_TIMED_OUT 32 | |||
/// Type of encoder/decoder specific data; the actual structure is defined | /// Type of encoder/decoder specific data; the actual structure is defined | |||
/// differently in different coders. | /// differently in different coders. | |||
typedef struct lzma_coder_s lzma_coder; | typedef struct lzma_coder_s lzma_coder; | |||
typedef struct lzma_next_coder_s lzma_next_coder; | typedef struct lzma_next_coder_s lzma_next_coder; | |||
typedef struct lzma_filter_info_s lzma_filter_info; | typedef struct lzma_filter_info_s lzma_filter_info; | |||
/// Type of a function used to initialize a filter encoder or decoder | /// Type of a function used to initialize a filter encoder or decoder | |||
typedef lzma_ret (*lzma_init_function)( | typedef lzma_ret (*lzma_init_function)( | |||
lzma_next_coder *next, lzma_allocator *allocator, | lzma_next_coder *next, const lzma_allocator *allocator, | |||
const lzma_filter_info *filters); | const lzma_filter_info *filters); | |||
/// Type of a function to do some kind of coding work (filters, Stream, | /// 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 | /// Block encoders/decoders etc.). Some special coders use don't use both | |||
/// input and output buffers, but for simplicity they still use this same | /// input and output buffers, but for simplicity they still use this same | |||
/// function prototype. | /// function prototype. | |||
typedef lzma_ret (*lzma_code_function)( | typedef lzma_ret (*lzma_code_function)( | |||
lzma_coder *coder, lzma_allocator *allocator, | lzma_coder *coder, const lzma_allocator *allocator, | |||
const uint8_t *restrict in, size_t *restrict in_pos, | const uint8_t *restrict in, size_t *restrict in_pos, | |||
size_t in_size, uint8_t *restrict out, | size_t in_size, uint8_t *restrict out, | |||
size_t *restrict out_pos, size_t out_size, | size_t *restrict out_pos, size_t out_size, | |||
lzma_action action); | lzma_action action); | |||
/// Type of a function to free the memory allocated for the coder | /// Type of a function to free the memory allocated for the coder | |||
typedef void (*lzma_end_function)( | typedef void (*lzma_end_function)( | |||
lzma_coder *coder, lzma_allocator *allocator); | lzma_coder *coder, const lzma_allocator *allocator); | |||
/// Raw coder validates and converts an array of lzma_filter structures to | /// Raw coder validates and converts an array of lzma_filter structures to | |||
/// an array of lzma_filter_info structures. This array is used with | /// an array of lzma_filter_info structures. This array is used with | |||
/// lzma_next_filter_init to initialize the filter chain. | /// lzma_next_filter_init to initialize the filter chain. | |||
struct lzma_filter_info_s { | struct lzma_filter_info_s { | |||
/// Filter ID. This is used only by the encoder | /// Filter ID. This is used only by the encoder | |||
/// with lzma_filters_update(). | /// with lzma_filters_update(). | |||
lzma_vli id; | lzma_vli id; | |||
/// Pointer to function used to initialize the filter. | /// Pointer to function used to initialize the filter. | |||
skipping to change at line 149 | skipping to change at line 151 | |||
uintptr_t init; | uintptr_t init; | |||
/// Pointer to function to do the actual coding | /// Pointer to function to do the actual coding | |||
lzma_code_function code; | lzma_code_function code; | |||
/// Pointer to function to free lzma_next_coder.coder. This can | /// Pointer to function to free lzma_next_coder.coder. This can | |||
/// be NULL; in that case, lzma_free is called to free | /// be NULL; in that case, lzma_free is called to free | |||
/// lzma_next_coder.coder. | /// lzma_next_coder.coder. | |||
lzma_end_function end; | lzma_end_function end; | |||
/// Pointer to a function to get progress information. If this is NU | ||||
LL, | ||||
/// lzma_stream.total_in and .total_out are used instead. | ||||
void (*get_progress)(lzma_coder *coder, | ||||
uint64_t *progress_in, uint64_t *progress_out); | ||||
/// Pointer to function to return the type of the integrity check. | /// Pointer to function to return the type of the integrity check. | |||
/// Most coders won't support this. | /// Most coders won't support this. | |||
lzma_check (*get_check)(const lzma_coder *coder); | lzma_check (*get_check)(const lzma_coder *coder); | |||
/// Pointer to function to get and/or change the memory usage limit. | /// Pointer to function to get and/or change the memory usage limit. | |||
/// If new_memlimit == 0, the limit is not changed. | /// If new_memlimit == 0, the limit is not changed. | |||
lzma_ret (*memconfig)(lzma_coder *coder, uint64_t *memusage, | lzma_ret (*memconfig)(lzma_coder *coder, uint64_t *memusage, | |||
uint64_t *old_memlimit, uint64_t new_memlimit); | uint64_t *old_memlimit, uint64_t new_memlimit); | |||
/// Update the filter-specific options or the whole filter chain | /// Update the filter-specific options or the whole filter chain | |||
/// in the encoder. | /// in the encoder. | |||
lzma_ret (*update)(lzma_coder *coder, lzma_allocator *allocator, | lzma_ret (*update)(lzma_coder *coder, const lzma_allocator *allocato r, | |||
const lzma_filter *filters, | const lzma_filter *filters, | |||
const lzma_filter *reversed_filters); | const lzma_filter *reversed_filters); | |||
}; | }; | |||
/// Macro to initialize lzma_next_coder structure | /// Macro to initialize lzma_next_coder structure | |||
#define LZMA_NEXT_CODER_INIT \ | #define LZMA_NEXT_CODER_INIT \ | |||
(lzma_next_coder){ \ | (lzma_next_coder){ \ | |||
.coder = NULL, \ | .coder = NULL, \ | |||
.init = (uintptr_t)(NULL), \ | .init = (uintptr_t)(NULL), \ | |||
.id = LZMA_VLI_UNKNOWN, \ | .id = LZMA_VLI_UNKNOWN, \ | |||
.code = NULL, \ | .code = NULL, \ | |||
.end = NULL, \ | .end = NULL, \ | |||
.get_progress = NULL, \ | ||||
.get_check = NULL, \ | .get_check = NULL, \ | |||
.memconfig = NULL, \ | .memconfig = NULL, \ | |||
.update = NULL, \ | .update = NULL, \ | |||
} | } | |||
/// Internal data for lzma_strm_init, lzma_code, and lzma_end. A pointer to | /// Internal data for lzma_strm_init, lzma_code, and lzma_end. A pointer to | |||
/// this is stored in lzma_stream. | /// this is stored in lzma_stream. | |||
struct lzma_internal_s { | struct lzma_internal_s { | |||
/// The actual coder that should do something useful | /// The actual coder that should do something useful | |||
lzma_next_coder next; | lzma_next_coder next; | |||
/// Track the state of the coder. This is used to validate arguments | /// Track the state of the coder. This is used to validate arguments | |||
/// so that the actual coders can rely on e.g. that LZMA_SYNC_FLUSH | /// so that the actual coders can rely on e.g. that LZMA_SYNC_FLUSH | |||
/// is used on every call to lzma_code until next.code has returned | /// is used on every call to lzma_code until next.code has returned | |||
/// LZMA_STREAM_END. | /// LZMA_STREAM_END. | |||
enum { | enum { | |||
ISEQ_RUN, | ISEQ_RUN, | |||
ISEQ_SYNC_FLUSH, | ISEQ_SYNC_FLUSH, | |||
ISEQ_FULL_FLUSH, | ISEQ_FULL_FLUSH, | |||
ISEQ_FINISH, | ISEQ_FINISH, | |||
ISEQ_FULL_BARRIER, | ||||
ISEQ_END, | ISEQ_END, | |||
ISEQ_ERROR, | ISEQ_ERROR, | |||
} sequence; | } sequence; | |||
/// A copy of lzma_stream avail_in. This is used to verify that the | /// A copy of lzma_stream avail_in. This is used to verify that the | |||
/// amount of input doesn't change once e.g. LZMA_FINISH has been | /// amount of input doesn't change once e.g. LZMA_FINISH has been | |||
/// used. | /// used. | |||
size_t avail_in; | size_t avail_in; | |||
/// Indicates which lzma_action values are allowed by next.code. | /// Indicates which lzma_action values are allowed by next.code. | |||
bool supported_actions[4]; | bool supported_actions[LZMA_ACTION_MAX + 1]; | |||
/// If true, lzma_code will return LZMA_BUF_ERROR if no progress was | /// If true, lzma_code will return LZMA_BUF_ERROR if no progress was | |||
/// made (no input consumed and no output produced by next.code). | /// made (no input consumed and no output produced by next.code). | |||
bool allow_buf_error; | bool allow_buf_error; | |||
}; | }; | |||
/// Allocates memory | /// Allocates memory | |||
extern void *lzma_alloc(size_t size, lzma_allocator *allocator) | extern void *lzma_alloc(size_t size, const lzma_allocator *allocator) | |||
lzma_attribute((__malloc__)) lzma_attr_alloc_size(1); | lzma_attribute((__malloc__)) lzma_attr_alloc_size(1); | |||
/// Allocates memory and zeroes it (like calloc()). This can be faster | ||||
/// than lzma_alloc() + memzero() while being backward compatible with | ||||
/// custom allocators. | ||||
extern void * lzma_attribute((__malloc__)) lzma_attr_alloc_size(1) | ||||
lzma_alloc_zero(size_t size, const lzma_allocator *allocator | ||||
); | ||||
/// Frees memory | /// Frees memory | |||
extern void lzma_free(void *ptr, lzma_allocator *allocator); | extern void lzma_free(void *ptr, const lzma_allocator *allocator); | |||
/// Allocates strm->internal if it is NULL, and initializes *strm and | /// Allocates strm->internal if it is NULL, and initializes *strm and | |||
/// strm->internal. This function is only called via lzma_next_strm_init ma cro. | /// strm->internal. This function is only called via lzma_next_strm_init ma cro. | |||
extern lzma_ret lzma_strm_init(lzma_stream *strm); | extern lzma_ret lzma_strm_init(lzma_stream *strm); | |||
/// Initializes the next filter in the chain, if any. This takes care of | /// Initializes the next filter in the chain, if any. This takes care of | |||
/// freeing the memory of previously initialized filter if it is different | /// freeing the memory of previously initialized filter if it is different | |||
/// than the filter being initialized now. This way the actual filter | /// than the filter being initialized now. This way the actual filter | |||
/// initialization functions don't need to use lzma_next_coder_init macro. | /// initialization functions don't need to use lzma_next_coder_init macro. | |||
extern lzma_ret lzma_next_filter_init(lzma_next_coder *next, | extern lzma_ret lzma_next_filter_init(lzma_next_coder *next, | |||
lzma_allocator *allocator, const lzma_filter_info *filters); | const lzma_allocator *allocator, | |||
const lzma_filter_info *filters); | ||||
/// Update the next filter in the chain, if any. This checks that | /// Update the next filter in the chain, if any. This checks that | |||
/// the application is not trying to change the Filter IDs. | /// the application is not trying to change the Filter IDs. | |||
extern lzma_ret lzma_next_filter_update( | extern lzma_ret lzma_next_filter_update( | |||
lzma_next_coder *next, lzma_allocator *allocator, | lzma_next_coder *next, const lzma_allocator *allocator, | |||
const lzma_filter *reversed_filters); | const lzma_filter *reversed_filters); | |||
/// Frees the memory allocated for next->coder either using next->end or, | /// Frees the memory allocated for next->coder either using next->end or, | |||
/// if next->end is NULL, using lzma_free. | /// if next->end is NULL, using lzma_free. | |||
extern void lzma_next_end(lzma_next_coder *next, lzma_allocator *allocator) | extern void lzma_next_end(lzma_next_coder *next, | |||
; | const lzma_allocator *allocator); | |||
/// Copy as much data as possible from in[] to out[] and update *in_pos | /// Copy as much data as possible from in[] to out[] and update *in_pos | |||
/// and *out_pos accordingly. Returns the number of bytes copied. | /// and *out_pos accordingly. Returns the number of bytes copied. | |||
extern size_t lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_p os, | extern size_t lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_p os, | |||
size_t in_size, uint8_t *restrict out, | size_t in_size, uint8_t *restrict out, | |||
size_t *restrict out_pos, size_t out_size); | size_t *restrict out_pos, size_t out_size); | |||
/// \brief Return if expression doesn't evaluate to LZMA_OK | /// \brief Return if expression doesn't evaluate to LZMA_OK | |||
/// | /// | |||
/// There are several situations where we want to return immediately | /// There are several situations where we want to return immediately | |||
End of changes. 17 change blocks. | ||||
13 lines changed or deleted | 31 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |