1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* The Universal Permissive License (UPL), Version 1.0
56
56
57
57
typedef char Byte ; /* 8 bits */
58
58
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
+
59
67
// Integer.MAX_INT
60
68
#define GRAALPYTHON_MAX_SIZE (INT_MAX)
61
69
@@ -216,7 +224,7 @@ static void bz_release_buffer(off_heap_buffer *o) {
216
224
}
217
225
218
226
// nfi_function: name('createStream') map('bzst_stream*', 'POINTER')
219
- bzst_stream * bz_create_bzst_stream () {
227
+ API_FUNC bzst_stream * bz_create_bzst_stream () {
220
228
bzst_stream * bzst = (bzst_stream * ) malloc (sizeof (bzst_stream ));
221
229
bzst -> bzs .opaque = NULL ;
222
230
bzst -> bzs .bzalloc = BZ2_Malloc ;
@@ -236,7 +244,7 @@ bzst_stream *bz_create_bzst_stream() {
236
244
}
237
245
238
246
// 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 ) {
240
248
#ifdef BENCHMARK
241
249
double t = bzst -> timeElapsed ;
242
250
LOG_FINEST ("time Elapsed: %.2f\n" , t );
@@ -248,7 +256,7 @@ double bz_get_timeElapsed(bzst_stream* zst) {
248
256
}
249
257
250
258
// 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 ) {
252
260
if (!bzst ) {
253
261
return ;
254
262
}
@@ -265,27 +273,27 @@ void bz_free_stream(bzst_stream* bzst) {
265
273
}
266
274
267
275
// 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 ) {
269
277
bz_free_stream (bzst );
270
278
}
271
279
272
280
// 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 ) {
274
282
return bzst -> next_in_index ;
275
283
}
276
284
277
285
// 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 ) {
279
287
return bzst -> bzs_avail_in_real ;
280
288
}
281
289
282
290
// 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 ) {
284
292
bzst -> bzs_avail_in_real = v ;
285
293
}
286
294
287
295
// 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 ) {
289
297
LOG_INFO ("bz_get_output_buffer_size(%p)\n" , bzst );
290
298
size_t size = bzst -> output_size ;
291
299
if (size > GRAALPYTHON_MAX_SIZE ) {
@@ -303,7 +311,7 @@ static void clear_output(bzst_stream *bzst) {
303
311
}
304
312
305
313
// 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 ) {
307
315
LOG_INFO ("bz_get_off_heap_buffer(%p)\n" , bzst );
308
316
off_heap_buffer * buffer = bzst -> output ;
309
317
size_t size = bzst -> output_size ;
@@ -376,7 +384,7 @@ grow_buffer(bzst_stream *bzst, ssize_t max_length) {
376
384
377
385
378
386
// 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 ) {
380
388
LOG_INFO ("bz_compressor_init(%p, %d)\n" , bzst , compresslevel );
381
389
int bzerror = BZ2_bzCompressInit (& bzst -> bzs , compresslevel , 0 , 0 );
382
390
if (!isOK (bzerror )) {
@@ -387,7 +395,7 @@ int bz_compressor_init(bzst_stream *bzst, int compresslevel) {
387
395
}
388
396
389
397
// 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 ) {
391
399
LOG_INFO ("bz_compress(%p, %zd, %d, %zd)\n" , bzst , len , action , bufsize );
392
400
size_t data_size = 0 ;
393
401
@@ -462,7 +470,7 @@ int bz_compress(bzst_stream *bzst, Byte *data, ssize_t len, int action, ssize_t
462
470
************************************************/
463
471
464
472
// 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 ) {
466
474
LOG_INFO ("bz_decompress_init(%p)\n" , bzst );
467
475
int bzerror = BZ2_bzDecompressInit (& bzst -> bzs , 0 , 0 );
468
476
if (!isOK (bzerror )) {
@@ -479,7 +487,7 @@ int bz_decompress_init(bzst_stream *bzst) {
479
487
returned, so some of the input may not be consumed. d->bzs.next_in and
480
488
d->bzs_avail_in_real are updated to reflect the consumed input. */
481
489
// nfi_function: name('decompress') map('bzst_stream*', 'POINTER')
482
- int bz_decompress (bzst_stream * bzst ,
490
+ API_FUNC int bz_decompress (bzst_stream * bzst ,
483
491
Byte * input_buffer , ssize_t offset ,
484
492
ssize_t max_length ,
485
493
ssize_t bufsize , ssize_t bzs_avail_in_real ) {
0 commit comments