11/*
2- * Copyright (c) 2020, 2023 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2020, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * The Universal Permissive License (UPL), Version 1.0
5656
5757typedef char Byte ; /* 8 bits */
5858
59+ #if defined(_MSC_VER )
60+ #include <BaseTsd.h>
61+ typedef SSIZE_T ssize_t ;
62+ #define API_FUNC __declspec(dllexport)
63+ #else
64+ #define API_FUNC
65+ #endif
66+
5967// Integer.MAX_INT
6068#define GRAALPYTHON_MAX_SIZE (INT_MAX)
6169
@@ -216,7 +224,7 @@ static void bz_release_buffer(off_heap_buffer *o) {
216224}
217225
218226// nfi_function: name('createStream') map('bzst_stream*', 'POINTER')
219- bzst_stream * bz_create_bzst_stream () {
227+ API_FUNC bzst_stream * bz_create_bzst_stream () {
220228 bzst_stream * bzst = (bzst_stream * ) malloc (sizeof (bzst_stream ));
221229 bzst -> bzs .opaque = NULL ;
222230 bzst -> bzs .bzalloc = BZ2_Malloc ;
@@ -236,7 +244,7 @@ bzst_stream *bz_create_bzst_stream() {
236244}
237245
238246// nfi_function: name('getTimeElapsed') map('bzst_stream*', 'POINTER') static(true)
239- double bz_get_timeElapsed (bzst_stream * zst ) {
247+ API_FUNC double bz_get_timeElapsed (bzst_stream * zst ) {
240248#ifdef BENCHMARK
241249 double t = bzst -> timeElapsed ;
242250 LOG_FINEST ("time Elapsed: %.2f\n" , t );
@@ -248,7 +256,7 @@ double bz_get_timeElapsed(bzst_stream* zst) {
248256}
249257
250258// nfi_function: name('deallocateStream') map('bzst_stream*', 'POINTER')
251- void bz_free_stream (bzst_stream * bzst ) {
259+ API_FUNC void bz_free_stream (bzst_stream * bzst ) {
252260 if (!bzst ) {
253261 return ;
254262 }
@@ -265,27 +273,27 @@ void bz_free_stream(bzst_stream* bzst) {
265273}
266274
267275// nfi_function: name('gcReleaseHelper') map('bzst_stream*', 'POINTER') release(true)
268- void bz_gc_helper (bzst_stream * bzst ) {
276+ API_FUNC void bz_gc_helper (bzst_stream * bzst ) {
269277 bz_free_stream (bzst );
270278}
271279
272280// nfi_function: name('getNextInIndex') map('bzst_stream*', 'POINTER')
273- ssize_t bz_get_next_in_index (bzst_stream * bzst ) {
281+ API_FUNC ssize_t bz_get_next_in_index (bzst_stream * bzst ) {
274282 return bzst -> next_in_index ;
275283}
276284
277285// nfi_function: name('getBzsAvailInReal') map('bzst_stream*', 'POINTER')
278- ssize_t bz_get_bzs_avail_in_real (bzst_stream * bzst ) {
286+ API_FUNC ssize_t bz_get_bzs_avail_in_real (bzst_stream * bzst ) {
279287 return bzst -> bzs_avail_in_real ;
280288}
281289
282290// nfi_function: name('setBzsAvailInReal') map('bzst_stream*', 'POINTER')
283- void bz_set_bzs_avail_in_real (bzst_stream * bzst , ssize_t v ) {
291+ API_FUNC void bz_set_bzs_avail_in_real (bzst_stream * bzst , ssize_t v ) {
284292 bzst -> bzs_avail_in_real = v ;
285293}
286294
287295// nfi_function: name('getOutputBufferSize') map('bzst_stream*', 'POINTER')
288- size_t bz_get_output_buffer_size (bzst_stream * bzst ) {
296+ API_FUNC size_t bz_get_output_buffer_size (bzst_stream * bzst ) {
289297 LOG_INFO ("bz_get_output_buffer_size(%p)\n" , bzst );
290298 size_t size = bzst -> output_size ;
291299 if (size > GRAALPYTHON_MAX_SIZE ) {
@@ -303,7 +311,7 @@ static void clear_output(bzst_stream *bzst) {
303311}
304312
305313// nfi_function: name('getOutputBuffer') map('bzst_stream*', 'POINTER')
306- void bz_get_output_buffer (bzst_stream * bzst , Byte * dest ) {
314+ API_FUNC void bz_get_output_buffer (bzst_stream * bzst , Byte * dest ) {
307315 LOG_INFO ("bz_get_off_heap_buffer(%p)\n" , bzst );
308316 off_heap_buffer * buffer = bzst -> output ;
309317 size_t size = bzst -> output_size ;
@@ -376,7 +384,7 @@ grow_buffer(bzst_stream *bzst, ssize_t max_length) {
376384
377385
378386// nfi_function: name('compressInit') map('bzst_stream*', 'POINTER')
379- int bz_compressor_init (bzst_stream * bzst , int compresslevel ) {
387+ API_FUNC int bz_compressor_init (bzst_stream * bzst , int compresslevel ) {
380388 LOG_INFO ("bz_compressor_init(%p, %d)\n" , bzst , compresslevel );
381389 int bzerror = BZ2_bzCompressInit (& bzst -> bzs , compresslevel , 0 , 0 );
382390 if (!isOK (bzerror )) {
@@ -387,7 +395,7 @@ int bz_compressor_init(bzst_stream *bzst, int compresslevel) {
387395}
388396
389397// nfi_function: name('compress') map('bzst_stream*', 'POINTER')
390- int bz_compress (bzst_stream * bzst , Byte * data , ssize_t len , int action , ssize_t bufsize ) {
398+ API_FUNC int bz_compress (bzst_stream * bzst , Byte * data , ssize_t len , int action , ssize_t bufsize ) {
391399 LOG_INFO ("bz_compress(%p, %zd, %d, %zd)\n" , bzst , len , action , bufsize );
392400 size_t data_size = 0 ;
393401
@@ -462,7 +470,7 @@ int bz_compress(bzst_stream *bzst, Byte *data, ssize_t len, int action, ssize_t
462470 ************************************************/
463471
464472// nfi_function: name('decompressInit') map('bzst_stream*', 'POINTER')
465- int bz_decompress_init (bzst_stream * bzst ) {
473+ API_FUNC int bz_decompress_init (bzst_stream * bzst ) {
466474 LOG_INFO ("bz_decompress_init(%p)\n" , bzst );
467475 int bzerror = BZ2_bzDecompressInit (& bzst -> bzs , 0 , 0 );
468476 if (!isOK (bzerror )) {
@@ -479,7 +487,7 @@ int bz_decompress_init(bzst_stream *bzst) {
479487 returned, so some of the input may not be consumed. d->bzs.next_in and
480488 d->bzs_avail_in_real are updated to reflect the consumed input. */
481489// nfi_function: name('decompress') map('bzst_stream*', 'POINTER')
482- int bz_decompress (bzst_stream * bzst ,
490+ API_FUNC int bz_decompress (bzst_stream * bzst ,
483491 Byte * input_buffer , ssize_t offset ,
484492 ssize_t max_length ,
485493 ssize_t bufsize , ssize_t bzs_avail_in_real ) {
0 commit comments