--- a/include/common.h +++ b/include/common.h @@ -46,10 +46,6 @@ static void write_neutral_s32(u8 * data, s32 value) { data[3] = (value >> 24) & 0xFF; } -#ifdef __MINGW32__ - #define PUBLIC_API __declspec(dllexport) -#else - #define PUBLIC_API -#endif +#define PUBLIC_API #endif --- a/include/libbz3.h +++ b/include/libbz3.h @@ -22,6 +22,16 @@ #include +#ifdef bzip3_EXPORTS +#ifdef _WIN32 + #define BZIP3_API __declspec(dllexport) +#else + #define BZIP3_API __attribute__((visibility("default"))) +#endif +#else + #define BZIP3_API +#endif + #define BZ3_OK 0 #define BZ3_ERR_OUT_OF_BOUNDS -1 #define BZ3_ERR_BWT -2 @@ -35,31 +45,31 @@ struct bz3_state; /** * @brief Get the last error number associated with a given state. */ -int8_t bz3_last_error(struct bz3_state * state); +BZIP3_API int8_t bz3_last_error(struct bz3_state * state); /** * @brief Return a user-readable message explaining the cause of the last error. */ -const char * bz3_strerror(struct bz3_state * state); +BZIP3_API const char * bz3_strerror(struct bz3_state * state); /** * @brief Construct a new block encoder state, which will encode blocks as big as the given block size. * The decoder will be able to decode blocks at most as big as the given block size. * Returns NULL in case allocation fails or the block size is not between 65K and 511M */ -struct bz3_state * bz3_new(int32_t block_size); +BZIP3_API struct bz3_state * bz3_new(int32_t block_size); /** * @brief Free the memory occupied by a block encoder state. */ -void bz3_free(struct bz3_state * state); +BZIP3_API void bz3_free(struct bz3_state * state); /** * @brief Encode a single block. Returns the amount of bytes written to `buffer'. * `buffer' must be able to hold at least `size + size / 50 + 32' bytes. The size must not * exceed the block size associated with the state. */ -int32_t bz3_encode_block(struct bz3_state * state, uint8_t * buffer, int32_t size); +BZIP3_API int32_t bz3_encode_block(struct bz3_state * state, uint8_t * buffer, int32_t size); /** * @brief Decode a single block. @@ -68,7 +78,7 @@ int32_t bz3_encode_block(struct bz3_state * state, uint8_t * buffer, int32_t siz * @param size The size of the compressed data in `buffer' * @param orig_size The original size of the data before compression. */ -int32_t bz3_decode_block(struct bz3_state * state, uint8_t * buffer, int32_t size, int32_t orig_size); +BZIP3_API int32_t bz3_decode_block(struct bz3_state * state, uint8_t * buffer, int32_t size, int32_t orig_size); /** * @brief Encode `n' blocks, all in parallel. @@ -80,13 +90,13 @@ int32_t bz3_decode_block(struct bz3_state * state, uint8_t * buffer, int32_t siz * * Present in the shared library only if -lpthread was present during building. */ -void bz3_encode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t n); +BZIP3_API void bz3_encode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t n); /** * @brief Decode `n' blocks, all in parallel. * Same specifics as `bz3_encode_blocks', but doesn't overwrite `sizes'. */ -void bz3_decode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t orig_sizes[], +BZIP3_API void bz3_decode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t orig_sizes[], int32_t n); #endif