libtool: export only symbols starting with `bz3_`
diff --git a/Makefile.am b/Makefile.am
index e053070..8b9ae33 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,6 +24,8 @@ libbzip3_la_SOURCES = src/cm.c \
src/lzp.c \
src/rle.c
+libbzip3_la_LDFLAGS = -export-symbols-regex '^bz3_'
+
bin_PROGRAMS = bzip3
bzip3_CFLAGS = $(AM_CFLAGS)
bzip3_LDDADD = libbzip3.la
diff --git a/include/common.h b/include/common.h
index 04b5649..7217d3e 100644
--- a/include/common.h
+++ b/include/common.h
@@ -46,12 +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
-
#if defined(__GNUC__) || defined(__clang__)
#define RESTRICT __restrict__
#elif defined(_MSC_VER) || defined(__INTEL_COMPILER)
diff --git a/src/libbz3.c b/src/libbz3.c
index 487274d..6006a21 100644
--- a/src/libbz3.c
+++ b/src/libbz3.c
@@ -40,9 +40,9 @@ struct bz3_state {
s8 last_error;
};
-PUBLIC_API s8 bz3_last_error(struct bz3_state * state) { return state->last_error; }
+s8 bz3_last_error(struct bz3_state * state) { return state->last_error; }
-PUBLIC_API const char * bz3_strerror(struct bz3_state * state) {
+const char * bz3_strerror(struct bz3_state * state) {
switch (state->last_error) {
case BZ3_OK:
return "No error";
@@ -63,7 +63,7 @@ PUBLIC_API const char * bz3_strerror(struct bz3_state * state) {
}
}
-PUBLIC_API struct bz3_state * bz3_new(s32 block_size) {
+struct bz3_state * bz3_new(s32 block_size) {
if (block_size < KiB(65) || block_size > MiB(511)) {
return NULL;
}
@@ -98,7 +98,7 @@ PUBLIC_API struct bz3_state * bz3_new(s32 block_size) {
return bz3_state;
}
-PUBLIC_API void bz3_free(struct bz3_state * state) {
+void bz3_free(struct bz3_state * state) {
free(state->swap_buffer);
free(state->sais_array);
free(state->cm_state);
@@ -113,7 +113,7 @@ PUBLIC_API void bz3_free(struct bz3_state * state) {
y = tmp; \
}
-PUBLIC_API s32 bz3_encode_block(struct bz3_state * state, u8 * buffer, s32 data_size) {
+s32 bz3_encode_block(struct bz3_state * state, u8 * buffer, s32 data_size) {
u8 *b1 = buffer, *b2 = state->swap_buffer;
if (data_size > state->block_size) {
@@ -184,7 +184,7 @@ PUBLIC_API s32 bz3_encode_block(struct bz3_state * state, u8 * buffer, s32 data_
return data_size + overhead * 4 + 1;
}
-PUBLIC_API s32 bz3_decode_block(struct bz3_state * state, u8 * buffer, s32 data_size, s32 orig_size) {
+s32 bz3_decode_block(struct bz3_state * state, u8 * buffer, s32 data_size, s32 orig_size) {
// Read the header.
u32 crc32 = read_neutral_s32(buffer);
s32 bwt_idx = read_neutral_s32(buffer + 4);
@@ -325,7 +325,7 @@ static void * bz3_init_decode_thread(void * _msg) {
return NULL; // unreachable
}
-PUBLIC_API void bz3_encode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t n) {
+void bz3_encode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t n) {
encode_thread_msg messages[n];
pthread_t threads[n];
for (int32_t i = 0; i < n; i++) {
@@ -338,7 +338,7 @@ PUBLIC_API void bz3_encode_blocks(struct bz3_state * states[], uint8_t * buffers
for (int32_t i = 0; i < n; i++) sizes[i] = messages[i].size;
}
-PUBLIC_API void bz3_decode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[],
+void bz3_decode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[],
int32_t orig_sizes[], int32_t n) {
decode_thread_msg messages[n];
pthread_t threads[n];
