:: commit acc8d85b0a909aaa912e7defffe1ef735f7adc0c

Kamila Szewczyk <kspalaiologos@gmail.com> — 2022-05-07 17:53

parents: ce8b3e6c5d

PUBLIC_API specifier

diff --git a/include/common.h b/include/common.h
index 4bb392b..b77f880 100644
--- a/include/common.h
+++ b/include/common.h
@@ -47,4 +47,6 @@ static void write_neutral_s32(u8 * data, s32 value) {
 
 }
 
+#define PUBLIC_API
+
 #endif
diff --git a/src/libbz3.c b/src/libbz3.c
index 7bdb3cf..8394a7e 100644
--- a/src/libbz3.c
+++ b/src/libbz3.c
@@ -40,9 +40,9 @@ struct bz3_state {
     s8 last_error;
 };
 
-s8 bz3_last_error(struct bz3_state * state) { return state->last_error; }
+PUBLIC_API s8 bz3_last_error(struct bz3_state * state) { return state->last_error; }
 
-const char * bz3_strerror(struct bz3_state * state) {
+PUBLIC_API const char * bz3_strerror(struct bz3_state * state) {
     switch (state->last_error) {
         case BZ3_OK:
             return "No error";
@@ -63,7 +63,7 @@ const char * bz3_strerror(struct bz3_state * state) {
     }
 }
 
-struct bz3_state * bz3_new(s32 block_size) {
+PUBLIC_API struct bz3_state * bz3_new(s32 block_size) {
     struct bz3_state * bz3_state = malloc(sizeof(struct bz3_state));
 
     if (!bz3_state) {
@@ -88,7 +88,7 @@ struct bz3_state * bz3_new(s32 block_size) {
     return bz3_state;
 }
 
-void bz3_free(struct bz3_state * state) {
+PUBLIC_API void bz3_free(struct bz3_state * state) {
     free(state->swap_buffer);
     free(state->sais_array);
     free(state->cm_state);
@@ -103,7 +103,7 @@ void bz3_free(struct bz3_state * state) {
         y = tmp;      \
     }
 
-s32 bz3_encode_block(struct bz3_state * state, u8 * buffer, s32 data_size) {
+PUBLIC_API 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) {
@@ -176,7 +176,7 @@ s32 bz3_encode_block(struct bz3_state * state, u8 * buffer, s32 data_size) {
     return data_size + overhead * 4 + 1;
 }
 
-s32 bz3_decode_block(struct bz3_state * state, u8 * buffer, s32 data_size, s32 orig_size) {
+PUBLIC_API 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);
@@ -281,7 +281,7 @@ static void bz3_init_decode_thread(decode_thread_msg * msg) {
     pthread_exit(NULL);
 }
 
-void bz3_encode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t n) {
+PUBLIC_API 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++) {
@@ -296,7 +296,7 @@ void bz3_encode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t
         sizes[i] = messages[i].size;
 }
 
-void bz3_decode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t orig_sizes[], int32_t n) {
+PUBLIC_API 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];
     for(int32_t i = 0; i < n; i++) {
tab: 248 wrap: offon