diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2009-05-25 18:42:22 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2009-05-25 18:42:22 +0300 |
commit | f88bf0850d6eace21ecdfc43d079093d205599e2 (patch) | |
tree | b5b2cb6bade13788daa961f3e3e83ba6d9e69584 | |
parent | a052d9261c1c8bda7f975c43415ac1f6164751aa (diff) | |
download | xz-embedded-f88bf0850d6eace21ecdfc43d079093d205599e2.tar.gz |
Add XZ_EXTERN macro and use it to mark all functions with
external linkage. This is needed to support marking those
functions as static in some situations in the Linux kernel.
XZ_EXTERN may be used for dllimport/dllexport too on some
other operating systems.
-rw-r--r-- | linux/include/linux/xz.h | 17 | ||||
-rw-r--r-- | linux/lib/xz/xz_crc32.c | 5 | ||||
-rw-r--r-- | linux/lib/xz/xz_dec_bcj.c | 7 | ||||
-rw-r--r-- | linux/lib/xz/xz_dec_lzma2.c | 10 | ||||
-rw-r--r-- | linux/lib/xz/xz_dec_stream.c | 8 | ||||
-rw-r--r-- | linux/lib/xz/xz_private.h | 16 |
6 files changed, 37 insertions, 26 deletions
diff --git a/linux/include/linux/xz.h b/linux/include/linux/xz.h index f851bde..c825b10 100644 --- a/linux/include/linux/xz.h +++ b/linux/include/linux/xz.h @@ -19,6 +19,11 @@ # include <stdint.h> #endif +/* In Linux, this is used to make extern functions static when needed. */ +#ifndef XZ_EXTERN +# define XZ_EXTERN extern +#endif + /* In Linux, this is used to mark the functions with __init when needed. */ #ifndef XZ_FUNC # define XZ_FUNC @@ -130,7 +135,7 @@ struct xz_dec; * On success, xz_dec_init() returns a pointer to struct xz_dec, which is * ready to be used with xz_dec_run(). On error, xz_dec_init() returns NULL. */ -extern struct xz_dec * XZ_FUNC xz_dec_init(uint32_t dict_max); +XZ_EXTERN struct xz_dec * XZ_FUNC xz_dec_init(uint32_t dict_max); /** * xz_dec_run() - Run the XZ decoder @@ -153,7 +158,7 @@ extern struct xz_dec * XZ_FUNC xz_dec_init(uint32_t dict_max); * amount valid data from the beginning of the stream. You must use the * multi-call decoder if you don't want to uncompress the whole stream. */ -extern enum xz_ret XZ_FUNC xz_dec_run(struct xz_dec *s, struct xz_buf *b); +XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_run(struct xz_dec *s, struct xz_buf *b); /** * xz_dec_reset() - Reset an already allocated decoder state @@ -166,14 +171,14 @@ extern enum xz_ret XZ_FUNC xz_dec_run(struct xz_dec *s, struct xz_buf *b); * xz_dec_run(). Thus, explicit call to xz_dec_reset() is useful only in * multi-call mode. */ -extern void XZ_FUNC xz_dec_reset(struct xz_dec *s); +XZ_EXTERN void XZ_FUNC xz_dec_reset(struct xz_dec *s); /** * xz_dec_end() - Free the memory allocated for the decoder state * @s: Decoder state allocated using xz_dec_init(). If s is NULL, * this function does nothing. */ -extern void XZ_FUNC xz_dec_end(struct xz_dec *s); +XZ_EXTERN void XZ_FUNC xz_dec_end(struct xz_dec *s); /* * Standalone build (userspace build or in-kernel build for boot time use) @@ -186,14 +191,14 @@ extern void XZ_FUNC xz_dec_end(struct xz_dec *s); * This must be called before any other xz_* function to initialize * the CRC32 lookup table. */ -extern void XZ_FUNC xz_crc32_init(void); +XZ_EXTERN void XZ_FUNC xz_crc32_init(void); /* * Update CRC32 value using the polynomial from IEEE-802.3. To start a new * calculation, the third argument must be zero. To continue the calculation, * the previously returned value is passed as the third argument. */ -extern uint32_t XZ_FUNC xz_crc32( +XZ_EXTERN uint32_t XZ_FUNC xz_crc32( const uint8_t *buf, size_t size, uint32_t crc); #endif #endif diff --git a/linux/lib/xz/xz_crc32.c b/linux/lib/xz/xz_crc32.c index 83d15fb..eea7b33 100644 --- a/linux/lib/xz/xz_crc32.c +++ b/linux/lib/xz/xz_crc32.c @@ -19,7 +19,7 @@ static uint32_t xz_crc32_table[256]; -void XZ_FUNC xz_crc32_init(void) +XZ_EXTERN void XZ_FUNC xz_crc32_init(void) { const uint32_t poly = 0xEDB88320; @@ -38,7 +38,8 @@ void XZ_FUNC xz_crc32_init(void) return; } -uint32_t XZ_FUNC xz_crc32(const uint8_t *buf, size_t size, uint32_t crc) +XZ_EXTERN uint32_t XZ_FUNC xz_crc32( + const uint8_t *buf, size_t size, uint32_t crc) { crc = ~crc; diff --git a/linux/lib/xz/xz_dec_bcj.c b/linux/lib/xz/xz_dec_bcj.c index d154ec4..f053cfd 100644 --- a/linux/lib/xz/xz_dec_bcj.c +++ b/linux/lib/xz/xz_dec_bcj.c @@ -408,7 +408,7 @@ static void XZ_FUNC bcj_flush(struct xz_dec_bcj *s, struct xz_buf *b) * data in chunks of 1-16 bytes. To hide this issue, this function does * some buffering. */ -enum xz_ret XZ_FUNC xz_dec_bcj_run(struct xz_dec_bcj *s, +XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_bcj_run(struct xz_dec_bcj *s, struct xz_dec_lzma2 *lzma2, struct xz_buf *b) { size_t out_start; @@ -503,13 +503,14 @@ enum xz_ret XZ_FUNC xz_dec_bcj_run(struct xz_dec_bcj *s, return s->ret; } -struct xz_dec_bcj * XZ_FUNC xz_dec_bcj_create(void) +XZ_EXTERN struct xz_dec_bcj * XZ_FUNC xz_dec_bcj_create(void) { struct xz_dec_bcj *s = kmalloc(sizeof(*s), GFP_KERNEL); return s; } -enum xz_ret XZ_FUNC xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id) +XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_bcj_reset( + struct xz_dec_bcj *s, uint8_t id) { switch (id) { #ifdef XZ_DEC_X86 diff --git a/linux/lib/xz/xz_dec_lzma2.c b/linux/lib/xz/xz_dec_lzma2.c index b98d062..d0d5d0c 100644 --- a/linux/lib/xz/xz_dec_lzma2.c +++ b/linux/lib/xz/xz_dec_lzma2.c @@ -906,7 +906,8 @@ static bool XZ_FUNC lzma2_lzma(struct xz_dec_lzma2 *s, struct xz_buf *b) * Take care of the LZMA2 control layer, and forward the job of actual LZMA * decoding or copying of uncompressed chunks to other functions. */ -enum xz_ret XZ_FUNC xz_dec_lzma2_run(struct xz_dec_lzma2 *s, struct xz_buf *b) +XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_lzma2_run( + struct xz_dec_lzma2 *s, struct xz_buf *b) { uint32_t tmp; @@ -1078,7 +1079,7 @@ enum xz_ret XZ_FUNC xz_dec_lzma2_run(struct xz_dec_lzma2 *s, struct xz_buf *b) return XZ_OK; } -struct xz_dec_lzma2 * XZ_FUNC xz_dec_lzma2_create(uint32_t dict_max) +XZ_EXTERN struct xz_dec_lzma2 * XZ_FUNC xz_dec_lzma2_create(uint32_t dict_max) { struct xz_dec_lzma2 *s; @@ -1103,7 +1104,8 @@ struct xz_dec_lzma2 * XZ_FUNC xz_dec_lzma2_create(uint32_t dict_max) return s; } -enum xz_ret XZ_FUNC xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props) +XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_lzma2_reset( + struct xz_dec_lzma2 *s, uint8_t props) { /* This limits dictionary size to 3 GiB to keep parsing simpler. */ if (props > 39) @@ -1127,7 +1129,7 @@ enum xz_ret XZ_FUNC xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props) return XZ_OK; } -void XZ_FUNC xz_dec_lzma2_end(struct xz_dec_lzma2 *s) +XZ_EXTERN void XZ_FUNC xz_dec_lzma2_end(struct xz_dec_lzma2 *s) { if (s->dict.allocated > 0) vfree(s->dict.buf); diff --git a/linux/lib/xz/xz_dec_stream.c b/linux/lib/xz/xz_dec_stream.c index 69c7c3b..c8387b4 100644 --- a/linux/lib/xz/xz_dec_stream.c +++ b/linux/lib/xz/xz_dec_stream.c @@ -669,7 +669,7 @@ static enum xz_ret XZ_FUNC dec_main(struct xz_dec *s, struct xz_buf *b) * actually succeeds (that's the price to pay of using the output buffer as * the workspace). */ -enum xz_ret XZ_FUNC xz_dec_run(struct xz_dec *s, struct xz_buf *b) +XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_run(struct xz_dec *s, struct xz_buf *b) { size_t in_start; size_t out_start; @@ -705,7 +705,7 @@ enum xz_ret XZ_FUNC xz_dec_run(struct xz_dec *s, struct xz_buf *b) return ret; } -struct xz_dec * XZ_FUNC xz_dec_init(uint32_t dict_max) +XZ_EXTERN struct xz_dec * XZ_FUNC xz_dec_init(uint32_t dict_max) { struct xz_dec *s = kmalloc(sizeof(*s), GFP_KERNEL); if (s == NULL) @@ -734,7 +734,7 @@ error_bcj: return NULL; } -void XZ_FUNC xz_dec_reset(struct xz_dec *s) +XZ_EXTERN void XZ_FUNC xz_dec_reset(struct xz_dec *s) { s->sequence = SEQ_STREAM_HEADER; s->allow_buf_error = false; @@ -746,7 +746,7 @@ void XZ_FUNC xz_dec_reset(struct xz_dec *s) s->temp.size = STREAM_HEADER_SIZE; } -void XZ_FUNC xz_dec_end(struct xz_dec *s) +XZ_EXTERN void XZ_FUNC xz_dec_end(struct xz_dec *s) { if (s != NULL) { xz_dec_lzma2_end(s->lzma2); diff --git a/linux/lib/xz/xz_private.h b/linux/lib/xz/xz_private.h index 25b5b41..866954b 100644 --- a/linux/lib/xz/xz_private.h +++ b/linux/lib/xz/xz_private.h @@ -68,7 +68,8 @@ * Allocate memory for LZMA2 decoder. xz_dec_lzma2_reset() must be used * before calling xz_dec_lzma2_run(). */ -extern struct xz_dec_lzma2 * XZ_FUNC xz_dec_lzma2_create(uint32_t dict_max); +XZ_EXTERN struct xz_dec_lzma2 * XZ_FUNC xz_dec_lzma2_create( + uint32_t dict_max); /* * Decode the LZMA2 properties (one byte) and reset the decoder. Return @@ -76,21 +77,21 @@ extern struct xz_dec_lzma2 * XZ_FUNC xz_dec_lzma2_create(uint32_t dict_max); * big enough, and XZ_OPTIONS_ERROR if props indicates something that this * decoder doesn't support. */ -extern enum xz_ret XZ_FUNC xz_dec_lzma2_reset( +XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_lzma2_reset( struct xz_dec_lzma2 *s, uint8_t props); /* Decode raw LZMA2 stream from b->in to b->out. */ -extern enum xz_ret XZ_FUNC xz_dec_lzma2_run( +XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_lzma2_run( struct xz_dec_lzma2 *s, struct xz_buf *b); /* Free the memory allocated for the LZMA2 decoder. */ -extern void XZ_FUNC xz_dec_lzma2_end(struct xz_dec_lzma2 *s); +XZ_EXTERN void XZ_FUNC xz_dec_lzma2_end(struct xz_dec_lzma2 *s); /* * Allocate memory for BCJ decoders. xz_dec_bcj_reset() must be used before * calling xz_dec_bcj_run(). */ -extern struct xz_dec_bcj * XZ_FUNC xz_dec_bcj_create(void); +XZ_EXTERN struct xz_dec_bcj * XZ_FUNC xz_dec_bcj_create(void); /* * Decode the Filter ID of a BCJ filter. This implementation doesn't @@ -98,14 +99,15 @@ extern struct xz_dec_bcj * XZ_FUNC xz_dec_bcj_create(void); * is needed. Returns XZ_OK if the given Filter ID is supported. * Otherwise XZ_OPTIONS_ERROR is returned. */ -extern enum xz_ret XZ_FUNC xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id); +XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_bcj_reset( + struct xz_dec_bcj *s, uint8_t id); /* * Decode raw BCJ + LZMA2 stream. This must be used only if there actually is * a BCJ filter in the chain. If the chain has only LZMA2, xz_dec_lzma2_run() * must be called directly. */ -extern enum xz_ret XZ_FUNC xz_dec_bcj_run(struct xz_dec_bcj *s, +XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_bcj_run(struct xz_dec_bcj *s, struct xz_dec_lzma2 *lzma2, struct xz_buf *b); /* Free the memory allocated for the BCJ filters. */ |