Skip to content

Commit 63946ab

Browse files
committed
Get lzma.c to compile on musl toolchain
1 parent 139e632 commit 63946ab

File tree

1 file changed

+19
-19
lines changed
  • graalpython/python-liblzma/src

1 file changed

+19
-19
lines changed

graalpython/python-liblzma/src/lzma.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#include <limits.h>
5151
#include <stdlib.h>
5252
#include <string.h>
53-
53+
#include <sys/types.h>
5454

5555
#include <lzma.h>
5656

@@ -196,7 +196,7 @@ enum {
196196
FORMAT_RAW,
197197
};
198198

199-
// The ref_count is important for `copy` as we
199+
// The ref_count is important for `copy` as we
200200
// share off heap storage between native objects.
201201
typedef struct
202202
{
@@ -239,7 +239,7 @@ void get_macros(int* formats, int* checks, uint64_t* filters, int* mfs, int* mod
239239
checks[CHECK_SHA256_INDEX] = LZMA_CHECK_SHA256;
240240
checks[CHECK_ID_MAX_INDEX] = LZMA_CHECK_ID_MAX;
241241
checks[CHECK_UNKNOWN_INDEX] = LZMA_CHECK_UNKNOWN;
242-
242+
243243
filters[FILTER_LZMA1_INDEX] = LZMA_FILTER_LZMA1;
244244
filters[FILTER_LZMA2_INDEX] = LZMA_FILTER_LZMA2;
245245
filters[FILTER_DELTA_INDEX] = LZMA_FILTER_DELTA;
@@ -249,7 +249,7 @@ void get_macros(int* formats, int* checks, uint64_t* filters, int* mfs, int* mod
249249
filters[FILTER_ARM_INDEX] = LZMA_FILTER_ARM;
250250
filters[FILTER_ARMTHUMB_INDEX] = LZMA_FILTER_ARMTHUMB;
251251
filters[FILTER_SPARC_INDEX] = LZMA_FILTER_SPARC;
252-
252+
253253
mfs[MF_HC3_INDEX] = LZMA_MF_HC3;
254254
mfs[MF_HC4_INDEX] = LZMA_MF_HC4;
255255
mfs[MF_BT2_INDEX] = LZMA_MF_BT2;
@@ -258,7 +258,7 @@ void get_macros(int* formats, int* checks, uint64_t* filters, int* mfs, int* mod
258258

259259
modes[MODE_FAST_INDEX] = LZMA_MODE_FAST;
260260
modes[MODE_NORMAL_INDEX] = LZMA_MODE_NORMAL;
261-
261+
262262
preset[PRESET_DEFAULT_INDEX] = LZMA_PRESET_DEFAULT;
263263
preset[PRESET_EXTREME_INDEX] = LZMA_PRESET_EXTREME;
264264
}
@@ -267,7 +267,7 @@ static void* LZMA_Malloc(void* ctx, size_t items, size_t size)
267267
{
268268
void *m = malloc((size_t)items * (size_t)size);
269269
LOG_FINER("malloc(address: %p, items: %u, size: %u)\n", m, items, size);
270-
return m;
270+
return m;
271271
}
272272

273273
static void LZMA_Free(void* ctx, void *ptr)
@@ -524,7 +524,7 @@ int lzma_set_filter_spec_lzma(lzmast_stream *lzmast, int fidx, int64_t* opts) {
524524
initFilters(lzmast);
525525
lzma_options_lzma *options;
526526
lzmast->filters[fidx].id = (uint64_t) opts[ID_INDEX];
527-
527+
528528
options = (lzma_options_lzma *)calloc(1, sizeof *options);
529529
if (options == NULL) {
530530
return LZMA_MEM_ERROR;
@@ -538,31 +538,31 @@ int lzma_set_filter_spec_lzma(lzmast_stream *lzmast, int fidx, int64_t* opts) {
538538
}
539539

540540
if (opts[LC_INDEX] != -1) {
541-
options->lc = (uint32_t) opts[LC_INDEX];
541+
options->lc = (uint32_t) opts[LC_INDEX];
542542
}
543543

544544
if (opts[LP_INDEX] != -1) {
545-
options->lp = (uint32_t) opts[LP_INDEX];
545+
options->lp = (uint32_t) opts[LP_INDEX];
546546
}
547547

548548
if (opts[PB_INDEX] != -1) {
549-
options->pb = (uint32_t) opts[PB_INDEX];
549+
options->pb = (uint32_t) opts[PB_INDEX];
550550
}
551551

552552
if (opts[MODE_INDEX] != -1) {
553-
options->mode = (lzma_mode) opts[MODE_INDEX];
553+
options->mode = (lzma_mode) opts[MODE_INDEX];
554554
}
555555

556556
if (opts[NICE_LEN_INDEX] != -1) {
557-
options->nice_len = (uint32_t) opts[NICE_LEN_INDEX];
557+
options->nice_len = (uint32_t) opts[NICE_LEN_INDEX];
558558
}
559559

560560
if (opts[MF_INDEX] != -1) {
561-
options->mf = (lzma_match_finder) opts[MF_INDEX];
561+
options->mf = (lzma_match_finder) opts[MF_INDEX];
562562
}
563563

564564
if (opts[DEPTH_INDEX] != -1) {
565-
options->depth = (uint32_t) opts[DEPTH_INDEX];
565+
options->depth = (uint32_t) opts[DEPTH_INDEX];
566566
}
567567

568568
lzmast->filters[fidx].options = options;
@@ -662,7 +662,7 @@ int lzma_decode_filter_spec(int64_t filter_id, Byte* encoded_props, int len, int
662662
lzma_filter filter;
663663

664664
filter.id = (lzma_vli) filter_id;
665-
665+
666666
lzret = lzma_properties_decode(&filter, NULL, encoded_props, len);
667667
if (!isOK(lzret)) {
668668
return lzret;
@@ -879,8 +879,8 @@ int lzma_lzma_alone_decoder(lzmast_stream *lzmast, uint64_t memlimit) {
879879
d->lzs.avail_in are updated to reflect the consumed input. */
880880

881881
// nfi_function: name('decompress') map('lzmast_stream*', 'POINTER')
882-
int lzma_decompress(lzmast_stream *lzmast,
883-
Byte *input_buffer, ssize_t offset,
882+
int lzma_decompress(lzmast_stream *lzmast,
883+
Byte *input_buffer, ssize_t offset,
884884
ssize_t max_length,
885885
ssize_t bufsize, size_t lzs_avail_in) {
886886
LOG_INFO("lzma_decompress(%p, %p, %zd, %zd, %zd, %zd)\n", lzmast, input_buffer, offset, bufsize, lzs_avail_in);
@@ -919,11 +919,11 @@ int lzma_decompress(lzmast_stream *lzmast,
919919
if (!isOK(lzret)) {
920920
clear_output(lzmast);
921921
return lzret;
922-
}
922+
}
923923
if (lzret == LZMA_GET_CHECK || lzret == LZMA_NO_CHECK) {
924924
lzmast->check = lzma_get_check(&lzmast->lzs);
925925
lzret = LZMA_OK;
926-
}
926+
}
927927
if (lzret == LZMA_STREAM_END) {
928928
// lzmast->eof = 1;
929929
// we'll return LZMA_STREAM_END to the java side and process EOF.

0 commit comments

Comments
 (0)