Coverage Report

Created: 2025-07-11 06:49

/src/c-blosc2/include/blosc2.h
Line
Count
Source (jump to first uncovered line)
1
/*********************************************************************
2
  Blosc - Blocked Shuffling and Compression Library
3
4
  Copyright (c) 2021  Blosc Development Team <blosc@blosc.org>
5
  https://blosc.org
6
  License: BSD 3-Clause (see LICENSE.txt)
7
8
  See LICENSE.txt for details about copyright and rights to use.
9
**********************************************************************/
10
11
/*********************************************************************
12
  @file blosc2.h
13
  @brief Blosc2 header file.
14
15
  This file contains Blosc2 public API and the structures needed to use it.
16
  @author Blosc Development Team <blosc@blosc.org>
17
**********************************************************************/
18
19
#ifndef BLOSC_BLOSC2_H
20
#define BLOSC_BLOSC2_H
21
22
#include "blosc2/blosc2-export.h"
23
#include "blosc2/blosc2-common.h"
24
#include "blosc2/blosc2-stdio.h"
25
26
#if defined(_WIN32) && !defined(__MINGW32__)
27
#include <windows.h>
28
#include <malloc.h>
29
#include <process.h>
30
#define getpid _getpid
31
#endif
32
33
#include <limits.h>
34
#include <stdlib.h>
35
#include <stdint.h>
36
#include <stdbool.h>
37
#include <stdio.h>
38
39
#ifdef __cplusplus
40
extern "C" {
41
#endif
42
43
// For compatibility with the Blosc 1.x series
44
#ifdef BLOSC1_COMPAT
45
  // Blosc2 symbols that should be accessible from Blosc 1.x API
46
  #define BLOSC_VERSION_MAJOR BLOSC2_VERSION_MAJOR
47
  #define BLOSC_VERSION_MINOR BLOSC2_VERSION_MINOR
48
  #define BLOSC_VERSION_RELEASE BLOSC2_VERSION_RELEASE
49
  #define BLOSC_VERSION_STRING BLOSC2_VERSION_STRING
50
  #define BLOSC_VERSION_DATE BLOSC2_VERSION_DATE
51
  #define BLOSC_MAX_OVERHEAD BLOSC2_MAX_OVERHEAD
52
  #define BLOSC_MAX_BUFFERSIZE BLOSC2_MAX_BUFFERSIZE
53
54
  // API that changed to blosc1_ prefix
55
  #define blosc_compress blosc1_compress
56
  #define blosc_decompress blosc1_decompress
57
  #define blosc_getitem blosc1_getitem
58
  #define blosc_get_compressor blosc1_get_compressor
59
  #define blosc_set_compressor blosc1_set_compressor
60
  #define blosc_cbuffer_sizes blosc1_cbuffer_sizes
61
  #define blosc_cbuffer_validate blosc1_cbuffer_validate
62
  #define blosc_cbuffer_metainfo blosc1_cbuffer_metainfo
63
  #define blosc_get_blocksize blosc1_get_blocksize
64
  #define blosc_set_blocksize blosc1_set_blocksize
65
  #define blosc_set_splitmode blosc1_set_splitmode
66
67
  // API that changed to blosc2_ prefix
68
  #define blosc_init blosc2_init
69
  #define blosc_destroy blosc2_destroy
70
  #define blosc_free_resources blosc2_free_resources
71
  #define blosc_get_nthreads blosc2_get_nthreads
72
  #define blosc_set_nthreads blosc2_set_nthreads
73
  #define blosc_compcode_to_compname blosc2_compcode_to_compname
74
  #define blosc_compname_to_compcode blosc2_compname_to_compcode
75
  #define blosc_list_compressors blosc2_list_compressors
76
  #define blosc_get_version_string blosc2_get_version_string
77
  #define blosc_get_complib_info blosc2_get_complib_info
78
  #define blosc_cbuffer_versions blosc2_cbuffer_versions
79
  #define blosc_cbuffer_complib blosc2_cbuffer_complib
80
#endif
81
82
83
/* Version numbers */
84
#define BLOSC2_VERSION_MAJOR    2    /* for major interface/format changes  */
85
#define BLOSC2_VERSION_MINOR    19   /* for minor interface/format changes  */
86
#define BLOSC2_VERSION_RELEASE  1    /* for tweaks, bug-fixes, or development */
87
88
0
#define BLOSC2_VERSION_STRING   "2.19.1.dev"  /* string version.  Sync with above! */
89
#define BLOSC2_VERSION_DATE     "$Date:: 2025-06-24 #$"    /* date version year-month-day */
90
91
92
/* The maximum number of dimensions for Blosc2 NDim arrays */
93
#define BLOSC2_MAX_DIM 8
94
95
96
/* Tracing macros */
97
23
#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
98
0
#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
99
0
#define BLOSC_TRACE_INFO(msg, ...) BLOSC_TRACE(info, msg, ##__VA_ARGS__)
100
#define BLOSC_TRACE(cat, msg, ...)                  \
101
23
    do {                                            \
102
23
        const char *__e = getenv("BLOSC_TRACE");    \
103
23
        if (!__e) { break; }                        \
104
23
        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
105
0
    } while(0)
106
107
#define BLOSC_ERROR_NULL(pointer, rc)               \
108
46.3k
    do {                                            \
109
46.3k
        if ((pointer) == NULL) {                    \
110
0
            BLOSC_TRACE_ERROR("Pointer is null");   \
111
0
            return (rc);                            \
112
0
        }                                           \
113
46.3k
    } while (0)
114
#define BLOSC_ERROR(rc)                             \
115
0
    do {                                            \
116
0
        int rc_ = (rc);                             \
117
0
        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
118
0
            char *error_msg = print_error(rc_);     \
119
0
            BLOSC_TRACE_ERROR("%s", error_msg);     \
120
0
            return rc_;                             \
121
0
        }                                           \
122
0
    } while (0)
123
124
#define BLOSC_INFO(msg, ...)                        \
125
14.0k
    do {                                            \
126
14.0k
        const char *__e = getenv("BLOSC_INFO");     \
127
14.0k
        if (!__e) { break; }                        \
128
14.0k
        fprintf(stderr, "[INFO] - " msg "\n", ##__VA_ARGS__); \
129
0
    } while(0)
130
131
132
/* The VERSION_FORMAT symbols below should be just 1-byte long */
133
enum {
134
  /* Blosc format version, starting at 1
135
     1 -> Blosc pre-1.0
136
     2 -> Blosc 1.x stable series
137
     3 -> Blosc 2-alpha.x series
138
     4 -> Blosc 2.x beta.1 series
139
     5 -> Blosc 2.x stable series
140
     */
141
  BLOSC1_VERSION_FORMAT_PRE1 = 1,
142
  BLOSC1_VERSION_FORMAT = 2,
143
  BLOSC2_VERSION_FORMAT_ALPHA = 3,
144
  BLOSC2_VERSION_FORMAT_BETA1 = 4,
145
  BLOSC2_VERSION_FORMAT_STABLE = 5,
146
  BLOSC2_VERSION_FORMAT = BLOSC2_VERSION_FORMAT_STABLE,
147
};
148
149
150
/* The FRAME_FORMAT_VERSION symbols below should be just 4-bit long */
151
enum {
152
  /* Blosc format version
153
   *  1 -> First version (introduced in beta.2)
154
   *  2 -> Second version (introduced in rc.1)
155
   *
156
   */
157
  BLOSC2_VERSION_FRAME_FORMAT_BETA2 = 1,  // for 2.0.0-beta2 and after
158
  BLOSC2_VERSION_FRAME_FORMAT_RC1 = 2,    // for 2.0.0-rc1 and after
159
  BLOSC2_VERSION_FRAME_FORMAT = BLOSC2_VERSION_FRAME_FORMAT_RC1,
160
};
161
162
163
//!< Struct for storing data from instrumentation of codecs
164
// This can be flexible because it is typically used mainly for development
165
typedef struct {
166
  float cratio;
167
  float cspeed;
168
  float filter_speed;
169
  //float memory;
170
  //float power;
171
  uint8_t flags[4];
172
} blosc2_instr;
173
174
175
enum {
176
#ifndef BLOSC_H
177
  BLOSC_MIN_HEADER_LENGTH = 16,
178
  //!< Minimum header length (Blosc1)
179
#endif // BLOSC_H
180
  BLOSC_EXTENDED_HEADER_LENGTH = 32,
181
  //!< Extended header length (Blosc2, see README_HEADER)
182
  BLOSC2_MAX_OVERHEAD = BLOSC_EXTENDED_HEADER_LENGTH,
183
  //!< The maximum overhead during compression in bytes. This equals
184
  //!< to @ref BLOSC_EXTENDED_HEADER_LENGTH now, but can be higher in future
185
  //!< implementations.
186
  BLOSC2_MAX_BUFFERSIZE = (INT_MAX - BLOSC2_MAX_OVERHEAD),
187
  //!< Maximum source buffer size to be compressed
188
#ifndef BLOSC_H
189
  BLOSC_MAX_TYPESIZE = UINT8_MAX,
190
  //!< Maximum typesize before considering source buffer as a stream of bytes.
191
  //!< Cannot be larger than 255.
192
#endif // BLOSC_H
193
  BLOSC_MIN_BUFFERSIZE = 32,
194
  //!< Minimum buffer size to be compressed.
195
};
196
197
enum {
198
    BLOSC2_DEFINED_TUNER_START = 0,
199
    BLOSC2_DEFINED_TUNER_STOP = 31,
200
    //!< Blosc-defined tuners must be between 0 - 31.
201
    BLOSC2_GLOBAL_REGISTERED_TUNER_START = 32,
202
    BLOSC2_GLOBAL_REGISTERED_TUNER_STOP = 159,
203
    //!< Blosc-registered tuners must be between 31 - 159.
204
    BLOSC2_GLOBAL_REGISTERED_TUNERS = 0,
205
    //!< Number of Blosc-registered tuners at the moment.
206
    BLOSC2_USER_REGISTERED_TUNER_START = 160,
207
    BLOSC2_USER_REGISTERED_TUNER_STOP = 255,
208
    //!< User-defined tuners must be between 160 - 255.
209
};
210
211
/**
212
 * @brief Codes for the different tuners shipped with Blosc
213
 */
214
enum {
215
    BLOSC_STUNE = 0,
216
    BLOSC_LAST_TUNER = 1,
217
    //!< Determine the last tuner defined by Blosc.
218
    BLOSC_LAST_REGISTERED_TUNE = BLOSC2_GLOBAL_REGISTERED_TUNER_START + BLOSC2_GLOBAL_REGISTERED_TUNERS - 1,
219
    //!< Determine the last registered tuner. It is used to check if a tuner is registered or not.
220
};
221
222
enum {
223
  BLOSC2_DEFINED_FILTERS_START = 0,
224
  BLOSC2_DEFINED_FILTERS_STOP = 31,
225
  //!< Blosc-defined filters must be between 0 - 31.
226
  BLOSC2_GLOBAL_REGISTERED_FILTERS_START = 32,
227
  BLOSC2_GLOBAL_REGISTERED_FILTERS_STOP = 159,
228
  //!< Blosc-registered filters must be between 32 - 159.
229
  BLOSC2_GLOBAL_REGISTERED_FILTERS = 5,
230
  //!< Number of Blosc-registered filters at the moment.
231
  BLOSC2_USER_REGISTERED_FILTERS_START = 160,
232
  BLOSC2_USER_REGISTERED_FILTERS_STOP = 255,
233
  //!< User-defined filters must be between 128 - 255.
234
  BLOSC2_MAX_FILTERS = 6,
235
  //!< Maximum number of filters in the filter pipeline
236
  BLOSC2_MAX_UDFILTERS = 16,
237
  //!< Maximum number of filters that a user can register.
238
};
239
240
241
/**
242
 * @brief Codes for filters.
243
 *
244
 * @sa #blosc1_compress
245
 */
246
enum {
247
#ifndef BLOSC_H
248
  BLOSC_NOSHUFFLE = 0,
249
  //!< No shuffle (for compatibility with Blosc1).
250
  BLOSC_NOFILTER = 0,
251
  //!< No filter.
252
  BLOSC_SHUFFLE = 1,
253
  //!< Byte-wise shuffle. `filters_meta` does not have any effect here.
254
  BLOSC_BITSHUFFLE = 2,
255
  //!< Bit-wise shuffle. `filters_meta` does not have any effect here.
256
#endif // BLOSC_H
257
  BLOSC_DELTA = 3,
258
  //!< Delta filter. `filters_meta` does not have any effect here.
259
  BLOSC_TRUNC_PREC = 4,
260
  //!< Truncate mantissa precision.
261
  //!< Positive values in `filters_meta` will keep bits; negative values will zero bits.
262
  BLOSC_LAST_FILTER = 5,
263
  //!< sentinel
264
  BLOSC_LAST_REGISTERED_FILTER = BLOSC2_GLOBAL_REGISTERED_FILTERS_START + BLOSC2_GLOBAL_REGISTERED_FILTERS - 1,
265
  //!< Determine the last registered filter. It is used to check if a filter is registered or not.
266
};
267
268
/**
269
 * @brief Codes for internal flags (see blosc1_cbuffer_metainfo)
270
 */
271
enum {
272
#ifndef BLOSC_H
273
  BLOSC_DOSHUFFLE = 0x1,     //!< byte-wise shuffle
274
  BLOSC_MEMCPYED = 0x2,      //!< plain copy
275
  BLOSC_DOBITSHUFFLE = 0x4,  //!< bit-wise shuffle
276
#endif // BLOSC_H
277
  BLOSC_DODELTA = 0x8,       //!< delta coding
278
};
279
280
/**
281
 * @brief Codes for new internal flags in Blosc2
282
 */
283
enum {
284
  BLOSC2_USEDICT = 0x1,          //!< use dictionaries with codec
285
  BLOSC2_BIGENDIAN = 0x2,        //!< data is in big-endian ordering
286
  BLOSC2_INSTR_CODEC = 0x80,     //!< codec is instrumented (mainly for development)
287
};
288
289
/**
290
 * @brief Values for different Blosc2 capabilities
291
 */
292
enum {
293
  BLOSC2_MAXDICTSIZE = 128 * 1024, //!< maximum size for compression dicts
294
  BLOSC2_MAXBLOCKSIZE = 536866816, //!< maximum size for blocks
295
  BLOSC2_MAXTYPESIZE = BLOSC2_MAXBLOCKSIZE, //!< maximum size for types
296
};
297
298
299
enum {
300
  BLOSC2_DEFINED_CODECS_START = 0,
301
  BLOSC2_DEFINED_CODECS_STOP = 31,
302
  //!< Blosc-defined codecs must be between 0 - 31.
303
  BLOSC2_GLOBAL_REGISTERED_CODECS_START = 32,
304
  BLOSC2_GLOBAL_REGISTERED_CODECS_STOP = 159,
305
  //!< Blosc-registered codecs must be between 31 - 159.
306
  BLOSC2_GLOBAL_REGISTERED_CODECS = 5,
307
    //!< Number of Blosc-registered codecs at the moment.
308
  BLOSC2_USER_REGISTERED_CODECS_START = 160,
309
  BLOSC2_USER_REGISTERED_CODECS_STOP = 255,
310
  //!< User-defined codecs must be between 160 - 255.
311
};
312
313
/**
314
 * @brief Codes for the different compressors shipped with Blosc
315
 */
316
enum {
317
#ifndef BLOSC_H
318
  BLOSC_BLOSCLZ = 0,
319
  BLOSC_LZ4 = 1,
320
  BLOSC_LZ4HC = 2,
321
  BLOSC_ZLIB = 4,
322
  BLOSC_ZSTD = 5,
323
#endif // BLOSC_H
324
  BLOSC_LAST_CODEC = 6,
325
  //!< Determine the last codec defined by Blosc.
326
  BLOSC_LAST_REGISTERED_CODEC = BLOSC2_GLOBAL_REGISTERED_CODECS_START + BLOSC2_GLOBAL_REGISTERED_CODECS - 1,
327
  //!< Determine the last registered codec. It is used to check if a codec is registered or not.
328
};
329
330
331
// Names for the different compressors shipped with Blosc
332
333
#ifndef BLOSC_H
334
14.0k
#define BLOSC_BLOSCLZ_COMPNAME   "blosclz"
335
13.6k
#define BLOSC_LZ4_COMPNAME       "lz4"
336
13.0k
#define BLOSC_LZ4HC_COMPNAME     "lz4hc"
337
9.82k
#define BLOSC_ZLIB_COMPNAME      "zlib"
338
7.54k
#define BLOSC_ZSTD_COMPNAME      "zstd"
339
#endif // BLOSC_H
340
341
/**
342
 * @brief Codes for compression libraries shipped with Blosc (code must be < 8)
343
 */
344
enum {
345
#ifndef BLOSC_H
346
  BLOSC_BLOSCLZ_LIB = 0,
347
  BLOSC_LZ4_LIB = 1,
348
  BLOSC_ZLIB_LIB = 3,
349
  BLOSC_ZSTD_LIB = 4,
350
#endif // BLOSC_H
351
  BLOSC_UDCODEC_LIB = 6,
352
  BLOSC_SCHUNK_LIB = 7,   //!< compressor library in super-chunk header
353
};
354
355
/**
356
 * @brief Names for the different compression libraries shipped with Blosc
357
 */
358
#ifndef BLOSC_H
359
0
#define BLOSC_BLOSCLZ_LIBNAME   "BloscLZ"
360
0
#define BLOSC_LZ4_LIBNAME       "LZ4"
361
0
#define BLOSC_ZLIB_LIBNAME      "Zlib"
362
0
#define BLOSC_ZSTD_LIBNAME      "Zstd"
363
#endif // BLOSC_H
364
365
/**
366
 * @brief The codes for compressor formats shipped with Blosc
367
 */
368
enum {
369
#ifndef BLOSC_H
370
  BLOSC_BLOSCLZ_FORMAT = BLOSC_BLOSCLZ_LIB,
371
  BLOSC_LZ4_FORMAT = BLOSC_LZ4_LIB,
372
  //!< LZ4HC and LZ4 share the same format
373
  BLOSC_LZ4HC_FORMAT = BLOSC_LZ4_LIB,
374
  BLOSC_ZLIB_FORMAT = BLOSC_ZLIB_LIB,
375
  BLOSC_ZSTD_FORMAT = BLOSC_ZSTD_LIB,
376
#endif // BLOSC_H
377
  BLOSC_UDCODEC_FORMAT = BLOSC_UDCODEC_LIB,
378
};
379
380
/**
381
 * @brief The version formats for compressors shipped with Blosc.
382
 * All versions here starts at 1
383
 */
384
enum {
385
#ifndef BLOSC_H
386
  BLOSC_BLOSCLZ_VERSION_FORMAT = 1,
387
  BLOSC_LZ4_VERSION_FORMAT = 1,
388
  BLOSC_LZ4HC_VERSION_FORMAT = 1,  /* LZ4HC and LZ4 share the same format */
389
  BLOSC_ZLIB_VERSION_FORMAT = 1,
390
  BLOSC_ZSTD_VERSION_FORMAT = 1,
391
#endif // BLOSC_H
392
  BLOSC_UDCODEC_VERSION_FORMAT = 1,
393
};
394
395
/**
396
 * @brief Split mode for blocks.
397
 * NEVER and ALWAYS are for experimenting with compression ratio.
398
 * AUTO for nearly optimal behaviour (based on heuristics).
399
 * FORWARD_COMPAT provides best forward compatibility (default).
400
 */
401
#ifndef BLOSC_H
402
enum {
403
  BLOSC_ALWAYS_SPLIT = 1,
404
  BLOSC_NEVER_SPLIT = 2,
405
  BLOSC_AUTO_SPLIT = 3,
406
  BLOSC_FORWARD_COMPAT_SPLIT = 4,
407
};
408
#endif // BLOSC_H
409
410
/**
411
 * @brief Offsets for fields in Blosc2 chunk header.
412
 */
413
enum {
414
  BLOSC2_CHUNK_VERSION = 0x0,       //!< the version for the chunk format
415
  BLOSC2_CHUNK_VERSIONLZ = 0x1,     //!< the version for the format of internal codec
416
  BLOSC2_CHUNK_FLAGS = 0x2,         //!< flags and codec info
417
  BLOSC2_CHUNK_TYPESIZE = 0x3,      //!< (uint8) the number of bytes of the atomic type
418
  BLOSC2_CHUNK_NBYTES = 0x4,        //!< (int32) uncompressed size of the buffer (this header is not included)
419
  BLOSC2_CHUNK_BLOCKSIZE = 0x8,     //!< (int32) size of internal blocks
420
  BLOSC2_CHUNK_CBYTES = 0xc,        //!< (int32) compressed size of the buffer (including this header)
421
  BLOSC2_CHUNK_FILTER_CODES = 0x10, //!< the codecs for the filter pipeline (1 byte per code)
422
  BLOSC2_CHUNK_FILTER_META = 0x18,  //!< meta info for the filter pipeline (1 byte per code)
423
  BLOSC2_CHUNK_BLOSC2_FLAGS = 0x1F, //!< flags specific for Blosc2 functionality
424
};
425
426
/**
427
 * @brief Run lengths for special values for chunks/frames
428
 */
429
enum {
430
  BLOSC2_NO_SPECIAL = 0x0,       //!< no special value
431
  BLOSC2_SPECIAL_ZERO = 0x1,     //!< zero special value
432
  BLOSC2_SPECIAL_NAN = 0x2,      //!< NaN special value
433
  BLOSC2_SPECIAL_VALUE = 0x3,    //!< repeated special value
434
  BLOSC2_SPECIAL_UNINIT = 0x4,   //!< non initialized values
435
  BLOSC2_SPECIAL_LASTID = 0x4,   //!< last valid ID for special value (update this adequately)
436
  BLOSC2_SPECIAL_MASK = 0x7      //!< special value mask (prev IDs cannot be larger than this)
437
};
438
439
/**
440
 * @brief Error codes
441
 * Each time an error code is added here, its corresponding message error should be added in
442
 * print_error()
443
 */
444
enum {
445
  BLOSC2_ERROR_SUCCESS = 0,           //<! Success
446
  BLOSC2_ERROR_FAILURE = -1,          //<! Generic failure
447
  BLOSC2_ERROR_STREAM = -2,           //<! Bad stream
448
  BLOSC2_ERROR_DATA = -3,             //<! Invalid data
449
  BLOSC2_ERROR_MEMORY_ALLOC = -4,     //<! Memory alloc/realloc failure
450
  BLOSC2_ERROR_READ_BUFFER = -5,      //!< Not enough space to read
451
  BLOSC2_ERROR_WRITE_BUFFER = -6,     //!< Not enough space to write
452
  BLOSC2_ERROR_CODEC_SUPPORT = -7,    //!< Codec not supported
453
  BLOSC2_ERROR_CODEC_PARAM = -8,      //!< Invalid parameter supplied to codec
454
  BLOSC2_ERROR_CODEC_DICT = -9,       //!< Codec dictionary error
455
  BLOSC2_ERROR_VERSION_SUPPORT = -10, //!< Version not supported
456
  BLOSC2_ERROR_INVALID_HEADER = -11,  //!< Invalid value in header
457
  BLOSC2_ERROR_INVALID_PARAM = -12,   //!< Invalid parameter supplied to function
458
  BLOSC2_ERROR_FILE_READ = -13,       //!< File read failure
459
  BLOSC2_ERROR_FILE_WRITE = -14,      //!< File write failure
460
  BLOSC2_ERROR_FILE_OPEN = -15,       //!< File open failure
461
  BLOSC2_ERROR_NOT_FOUND = -16,       //!< Not found
462
  BLOSC2_ERROR_RUN_LENGTH = -17,      //!< Bad run length encoding
463
  BLOSC2_ERROR_FILTER_PIPELINE = -18, //!< Filter pipeline error
464
  BLOSC2_ERROR_CHUNK_INSERT = -19,    //!< Chunk insert failure
465
  BLOSC2_ERROR_CHUNK_APPEND = -20,    //!< Chunk append failure
466
  BLOSC2_ERROR_CHUNK_UPDATE = -21,    //!< Chunk update failure
467
  BLOSC2_ERROR_2GB_LIMIT = -22,       //!< Sizes larger than 2gb not supported
468
  BLOSC2_ERROR_SCHUNK_COPY = -23,     //!< Super-chunk copy failure
469
  BLOSC2_ERROR_FRAME_TYPE = -24,      //!< Wrong type for frame
470
  BLOSC2_ERROR_FILE_TRUNCATE = -25,   //!< File truncate failure
471
  BLOSC2_ERROR_THREAD_CREATE = -26,   //!< Thread or thread context creation failure
472
  BLOSC2_ERROR_POSTFILTER = -27,      //!< Postfilter failure
473
  BLOSC2_ERROR_FRAME_SPECIAL = -28,   //!< Special frame failure
474
  BLOSC2_ERROR_SCHUNK_SPECIAL = -29,  //!< Special super-chunk failure
475
  BLOSC2_ERROR_PLUGIN_IO = -30,       //!< IO plugin error
476
  BLOSC2_ERROR_FILE_REMOVE = -31,     //!< Remove file failure
477
  BLOSC2_ERROR_NULL_POINTER = -32,    //!< Pointer is null
478
  BLOSC2_ERROR_INVALID_INDEX = -33,   //!< Invalid index
479
  BLOSC2_ERROR_METALAYER_NOT_FOUND = -34,   //!< Metalayer has not been found
480
  BLOSC2_ERROR_MAX_BUFSIZE_EXCEEDED = -35,  //!< Max buffer size exceeded
481
  BLOSC2_ERROR_TUNER = -36,           //!< Tuner failure
482
};
483
484
485
#ifdef __GNUC__
486
#define BLOSC_ATTRIBUTE_UNUSED __attribute__((unused))
487
#else
488
#define BLOSC_ATTRIBUTE_UNUSED
489
#endif
490
491
/**
492
 * @brief Get the string representation of an error code.
493
 *
494
 * The returned string is a static string, so it should not be modified or freed.
495
 * For unknown error codes, it returns "Unknown error".
496
 *
497
 * @param error_code The error code to get the string representation for.
498
 * @return A pointer to a static string representing the error code.
499
 */
500
BLOSC_EXPORT const char *blosc2_error_string(int error_code);
501
502
/**
503
 * @brief Get the string representation of an error code.
504
 *
505
 * This function is identical to #blosc2_error_string, but with a legacy interface.
506
 * The returned string is a static read only string, so it should not be modified or freed,
507
 * although it is not const.
508
 *
509
 * Prefer using #blosc2_error_string instead.
510
 *
511
 * @param rc The error code to get the string representation for.
512
 * @return A pointer to a static string representing the error code.
513
 */
514
static char *print_error(int rc) BLOSC_ATTRIBUTE_UNUSED;
515
0
static char *print_error(int rc) {
516
  // TODO: remove this function, use blosc2_error_string only
517
0
  return (char *) blosc2_error_string(rc);
518
0
}
Unexecuted instantiation: fuzz_compress_chunk.c:print_error
Unexecuted instantiation: blosc2.c:print_error
Unexecuted instantiation: blosclz.c:print_error
Unexecuted instantiation: schunk.c:print_error
Unexecuted instantiation: frame.c:print_error
Unexecuted instantiation: stune.c:print_error
Unexecuted instantiation: trunc-prec.c:print_error
Unexecuted instantiation: timestamp.c:print_error
Unexecuted instantiation: sframe.c:print_error
Unexecuted instantiation: blosc2-stdio.c:print_error
Unexecuted instantiation: b2nd.c:print_error
Unexecuted instantiation: b2nd_utils.c:print_error
Unexecuted instantiation: shuffle.c:print_error
Unexecuted instantiation: blosc2-zfp.c:print_error
Unexecuted instantiation: codecs-registry.c:print_error
Unexecuted instantiation: tuners-registry.c:print_error
Unexecuted instantiation: filters-registry.c:print_error
Unexecuted instantiation: ndlz.c:print_error
Unexecuted instantiation: ndlz4x4.c:print_error
Unexecuted instantiation: ndlz8x8.c:print_error
Unexecuted instantiation: ndcell.c:print_error
Unexecuted instantiation: ndmean.c:print_error
Unexecuted instantiation: bytedelta.c:print_error
Unexecuted instantiation: int_trunc.c:print_error
519
520
521
/**
522
 * @brief Initialize the Blosc library environment.
523
 *
524
 * You must call this previous to any other Blosc call, unless you want
525
 * Blosc to be used simultaneously in a multi-threaded environment, in
526
 * which case you can use the #blosc2_compress_ctx #blosc2_decompress_ctx pair.
527
 *
528
 * @sa #blosc2_destroy
529
 */
530
BLOSC_EXPORT void blosc2_init(void);
531
532
533
/**
534
 * @brief Destroy the Blosc library environment.
535
 *
536
 * You must call this after to you are done with all the Blosc calls,
537
 * unless you have not used blosc2_init() before.
538
 *
539
 * @sa #blosc2_init
540
 */
541
BLOSC_EXPORT void blosc2_destroy(void);
542
543
544
/**
545
 * @brief Compress a block of data in the @p src buffer and returns the size of
546
 * compressed block.
547
 *
548
 * @remark Compression is memory safe and guaranteed not to write @p dest
549
 * more than what is specified in @p destsize.
550
 * There is not a minimum for @p src buffer size @p nbytes.
551
 * Equivalent to #blosc2_compress.
552
 *
553
 * @warning The @p src buffer and the @p dest buffer can not overlap.
554
 *
555
 * @param clevel The desired compression level and must be a number
556
 * between 0 (no compression) and 9 (maximum compression).
557
 * @param doshuffle Specifies whether the shuffle compression preconditioner
558
 * should be applied or not. #BLOSC_NOFILTER means not applying filters,
559
 * #BLOSC_SHUFFLE means applying shuffle at a byte level and
560
 * #BLOSC_BITSHUFFLE at a bit level (slower but *may* achieve better
561
 * compression).
562
 * @param typesize Is the number of bytes for the atomic type in binary
563
 * @p src buffer.  This is mainly useful for the shuffle preconditioner.
564
 * For implementation reasons, only a 1 < typesize < 256 will allow the
565
 * shuffle filter to work.  When typesize is not in this range, shuffle
566
 * will be silently disabled.
567
 * @param nbytes The number of bytes to compress in the @p src buffer.
568
 * @param src The buffer containing the data to compress.
569
 * @param dest The buffer where the compressed data will be put,
570
 * must have at least the size of @p destsize.
571
 * @param destsize The size of the dest buffer. Blosc
572
 * guarantees that if you set @p destsize to, at least,
573
 * (@p nbytes + #BLOSC2_MAX_OVERHEAD), the compression will always succeed.
574
 *
575
 * @return The number of bytes compressed.
576
 * If @p src buffer cannot be compressed into @p destsize, the return
577
 * value is zero and you should discard the contents of the @p dest
578
 * buffer. A negative return value means that an internal error happened. This
579
 * should never happen. If you see this, please report it back
580
 * together with the buffer data causing this and compression settings.
581
 *
582
 *
583
 * @par Environment variables
584
 * @parblock
585
 *
586
 * This function honors different environment variables to control
587
 * internal parameters without the need of doing that programmatically.
588
 * Here are the ones supported:
589
 *
590
 * * **BLOSC_CLEVEL=(INTEGER)**: This will overwrite the @p clevel parameter
591
 * before the compression process starts.
592
 *
593
 * * **BLOSC_SHUFFLE=[NOSHUFFLE | SHUFFLE | BITSHUFFLE]**: This will
594
 * overwrite the @p doshuffle parameter before the compression process
595
 * starts.
596
 *
597
 * * **BLOSC_DELTA=(1|0)**: This will call #blosc2_set_delta() before the
598
 * compression process starts.
599
 *
600
 * * **BLOSC_TYPESIZE=(INTEGER)**: This will overwrite the @p typesize
601
 * parameter before the compression process starts.
602
 *
603
 * * **BLOSC_COMPRESSOR=[BLOSCLZ | LZ4 | LZ4HC | ZLIB | ZSTD]**:
604
 * This will call #blosc1_set_compressor before the compression process starts.
605
 *
606
 * * **BLOSC_NTHREADS=(INTEGER)**: This will call
607
 * #blosc2_set_nthreads before the compression process starts.
608
 *
609
 * * **BLOSC_SPLITMODE=(ALWAYS | NEVER | AUTO | FORWARD_COMPAT)**:
610
 * This will call #blosc1_set_splitmode() before the compression process starts.
611
 *
612
 * * **BLOSC_BLOCKSIZE=(INTEGER)**: This will call
613
 * #blosc1_set_blocksize before the compression process starts.
614
 * *NOTE:* The *blocksize* is a critical parameter with
615
 * important restrictions in the allowed values, so use this with care.
616
 *
617
 * * **BLOSC_NOLOCK=(ANY VALUE)**: This will call #blosc2_compress_ctx under
618
 * the hood, with the *compressor*, *blocksize* and
619
 * *numinternalthreads* parameters set to the same as the last calls to
620
 * #blosc1_set_compressor, #blosc1_set_blocksize and
621
 * #blosc2_set_nthreads. *BLOSC_CLEVEL*, *BLOSC_SHUFFLE*, *BLOSC_DELTA* and
622
 * *BLOSC_TYPESIZE* environment vars will also be honored.
623
 *
624
 * @endparblock
625
 *
626
 * @sa #blosc1_decompress
627
 */
628
BLOSC_EXPORT int blosc1_compress(int clevel, int doshuffle, size_t typesize,
629
                                 size_t nbytes, const void* src, void* dest,
630
                                 size_t destsize);
631
632
633
/**
634
 * @brief Decompress a block of compressed data in @p src, put the result in
635
 * @p dest and returns the size of the decompressed block.
636
 *
637
 * @warning The @p src buffer and the @p dest buffer can not overlap.
638
 *
639
 * @remark Decompression is memory safe and guaranteed not to write the @p dest
640
 * buffer more than what is specified in @p destsize.
641
 * Similar to #blosc2_decompress.
642
 *
643
 * @remark In case you want to keep under control the number of bytes read from
644
 * source, you can call #blosc1_cbuffer_sizes first to check whether the
645
 * @p nbytes (i.e. the number of bytes to be read from @p src buffer by this
646
 * function) in the compressed buffer is ok with you.
647
 *
648
 * @param src The buffer to be decompressed.
649
 * @param dest The buffer where the decompressed data will be put.
650
 * @param destsize The size of the @p dest buffer.
651
 *
652
 * @return The number of bytes decompressed.
653
 * If an error occurs, e.g. the compressed data is corrupted or the
654
 * output buffer is not large enough, then a negative value
655
 * will be returned instead.
656
 *
657
 * @par Environment variables
658
 * @parblock
659
 * This function honors different environment variables to control
660
 * internal parameters without the need of doing that programmatically.
661
 * Here are the ones supported:
662
 *
663
 * * **BLOSC_NTHREADS=(INTEGER)**: This will call
664
 * #blosc2_set_nthreads before the proper decompression
665
 * process starts.
666
 *
667
 * * **BLOSC_NOLOCK=(ANY VALUE)**: This will call #blosc2_decompress_ctx
668
 * under the hood, with the *numinternalthreads* parameter set to the
669
 * same value as the last call to #blosc2_set_nthreads.
670
 *
671
 * @endparblock
672
 *
673
 * @sa #blosc1_compress
674
 */
675
BLOSC_EXPORT int blosc1_decompress(const void* src, void* dest, size_t destsize);
676
677
678
/**
679
 * @brief Get @p nitems (of @p typesize size) in @p src buffer starting in @p start.
680
 * The items are returned in @p dest buffer, which has to have enough
681
 * space for storing all items.
682
 *
683
 * @remark The function #blosc2_getitem is a more complete and secure version.
684
 *
685
 * @param src The compressed buffer from data will be decompressed.
686
 * @param start The position of the first item (of @p typesize size) from where data
687
 * will be retrieved.
688
 * @param nitems The number of items (of @p typesize size) that will be retrieved.
689
 * @param dest The buffer where the decompressed data retrieved will be put.
690
 *
691
 * @return The number of bytes copied to @p dest or a negative value if
692
 * some error happens.
693
 */
694
BLOSC_EXPORT int blosc1_getitem(const void* src, int start, int nitems, void* dest);
695
696
/**
697
 * @brief Get @p nitems (of @p typesize size) in @p src buffer starting in @p start.
698
 * The items are returned in @p dest buffer. The dest buffer should have enough space
699
 * for storing all items. This function is a more secure version of #blosc1_getitem.
700
 *
701
 * @param src The compressed buffer holding the data to be retrieved.
702
 * @param srcsize Size of the compressed buffer.
703
 * @param start The position of the first item (of @p typesize size) from where data
704
 * will be retrieved.
705
 * @param nitems The number of items (of @p typesize size) that will be retrieved.
706
 * @param dest The buffer where the retrieved data will be stored decompressed.
707
 * @param destsize Size of the buffer where retrieved data will be stored.
708
 *
709
 * @return The number of bytes copied to @p dest or a negative value if
710
 * some error happens.
711
 */
712
BLOSC_EXPORT int blosc2_getitem(const void* src, int32_t srcsize, int start, int nitems,
713
                                void* dest, int32_t destsize);
714
715
/**
716
  Pointer to a callback function that executes `dojob(jobdata + i*jobdata_elsize)` for `i = 0 to numjobs-1`,
717
  possibly in parallel threads (but not returning until all `dojob` calls have returned).   This allows the
718
  caller to provide a custom threading backend as an alternative to the default Blosc-managed threads.
719
  `callback_data` is passed through from `blosc2_set_threads_callback`.
720
 */
721
typedef void (*blosc_threads_callback)(void *callback_data, void (*dojob)(void *), int numjobs, size_t jobdata_elsize, void *jobdata);
722
723
/**
724
  * @brief Set the threading backend for parallel compression/decompression to use @p callback to execute work
725
  * instead of using the Blosc-managed threads.  The @p callback_data argument is passed through to the callback.
726
727
  * @param callback: the callback to use. Passing `NULL` uses the default Blosc threading backend.
728
  * @param callback_data: the callback data.
729
  *
730
  * @warning This function is *not* thread-safe and should be called
731
  * before any other Blosc function: it affects all Blosc contexts.
732
  * @sa https://github.com/Blosc/c-blosc2/pull/81
733
  */
734
BLOSC_EXPORT void blosc2_set_threads_callback(blosc_threads_callback callback, void *callback_data);
735
736
737
/**
738
 * @brief Returns the current number of threads that are used for
739
 * compression/decompression.
740
 */
741
BLOSC_EXPORT int16_t blosc2_get_nthreads(void);
742
743
744
/**
745
 * @brief Initialize a pool of threads for compression/decompression. If
746
 * @p nthreads is 1, then the serial version is chosen and a possible
747
 * previous existing pool is ended. If this is not called, @p nthreads
748
 * is set to 1 internally.
749
 *
750
 * @param nthreads The number of threads to use.
751
 *
752
 * @return The previous number of threads.
753
 */
754
BLOSC_EXPORT int16_t blosc2_set_nthreads(int16_t nthreads);
755
756
757
/**
758
 * @brief Get the current compressor that is used for compression.
759
 *
760
 * @return The string identifying the compressor being used.
761
 */
762
BLOSC_EXPORT const char* blosc1_get_compressor(void);
763
764
765
/**
766
 * @brief Select the compressor to be used. The supported ones are "blosclz",
767
 * "lz4", "lz4hc", "zlib" and "ztsd". If this function is not
768
 * called, then "blosclz" will be used.
769
 *
770
 * @param compname The name identifier of the compressor to be set.
771
 *
772
 * @return The code for the compressor (>=0). In case the compressor
773
 * is not recognized, or there is not support for it in this build,
774
 * it returns a -1.
775
 */
776
BLOSC_EXPORT int blosc1_set_compressor(const char* compname);
777
778
779
/**
780
 * @brief Select the delta coding filter to be used.
781
 *
782
 * @param dodelta A value >0 will activate the delta filter.
783
 * If 0, it will be de-activated
784
 *
785
 * This call should always succeed.
786
 */
787
BLOSC_EXPORT void blosc2_set_delta(int dodelta);
788
789
790
/**
791
 * @brief Get the compressor name associated with the compressor code.
792
 *
793
 * @param compcode The code identifying the compressor
794
 * @param compname The pointer to a string where the compressor name will be put.
795
 *
796
 * @return The compressor code. If the compressor code is not recognized,
797
 * or there is not support for it in this build, -1 is returned.
798
 */
799
BLOSC_EXPORT int blosc2_compcode_to_compname(int compcode, const char** compname);
800
801
802
/**
803
 * @brief Get the compressor code associated with the compressor name.
804
 *
805
 * @param compname The string containing the compressor name.
806
 *
807
 * @return The compressor code. If the compressor name is not recognized,
808
 * or there is not support for it in this build, -1 is returned instead.
809
 */
810
BLOSC_EXPORT int blosc2_compname_to_compcode(const char* compname);
811
812
813
/**
814
 * @brief Get a list of compressors supported in the current build.
815
 *
816
 * @return The comma separated string with the list of compressor names
817
 * supported.
818
 *
819
 * This function does not leak, so you should not free() the returned
820
 * list.
821
 *
822
 * This function should always succeed.
823
 */
824
BLOSC_EXPORT const char* blosc2_list_compressors(void);
825
826
827
/**
828
 * @brief Get the version of Blosc in string format.
829
 *
830
 * @return The string with the current Blosc version.
831
 * Useful for dynamic libraries.
832
 */
833
BLOSC_EXPORT const char* blosc2_get_version_string(void);
834
835
836
/**
837
 * @brief Get info from compression libraries included in the current build.
838
 *
839
 * @param compname The compressor name that you want info from.
840
 * @param complib The pointer to a string where the
841
 * compression library name, if available, will be put.
842
 * @param version The pointer to a string where the
843
 * compression library version, if available, will be put.
844
 *
845
 * @warning You are in charge of the @p complib and @p version strings,
846
 * you should free() them so as to avoid leaks.
847
 *
848
 * @return The code for the compression library (>=0). If it is not supported,
849
 * this function returns -1.
850
 */
851
BLOSC_EXPORT int blosc2_get_complib_info(const char* compname, char** complib,
852
                                         char** version);
853
854
855
/**
856
 * @brief Free possible memory temporaries and thread resources. Use this
857
 * when you are not going to use Blosc for a long while.
858
 *
859
 * @return A 0 if succeeds, in case of problems releasing the resources,
860
 * it returns a negative number.
861
 */
862
BLOSC_EXPORT int blosc2_free_resources(void);
863
864
865
/**
866
 * @brief Get information about a compressed buffer, namely the number of
867
 * uncompressed bytes (@p nbytes) and compressed (@p cbytes). It also
868
 * returns the @p blocksize (which is used internally for doing the
869
 * compression by blocks).
870
 *
871
 * @remark Equivalent to function #blosc2_cbuffer_sizes.
872
 *
873
 * @param cbuffer The buffer of compressed data.
874
 * @param nbytes The pointer where the number of uncompressed bytes will be put.
875
 * @param cbytes The pointer where the number of compressed bytes will be put.
876
 * @param blocksize The pointer where the block size will be put.
877
 *
878
 * You only need to pass the first BLOSC_MIN_HEADER_LENGTH bytes of a
879
 * compressed buffer for this call to work.
880
 *
881
 * This function should always succeed.
882
 */
883
BLOSC_EXPORT void blosc1_cbuffer_sizes(const void* cbuffer, size_t* nbytes,
884
                                       size_t* cbytes, size_t* blocksize);
885
/**
886
 * @brief Get information about a compressed buffer, namely the number of
887
 * uncompressed bytes (@p nbytes) and compressed (@p cbytes). It also
888
 * returns the @p blocksize (which is used internally for doing the
889
 * compression by blocks).
890
 *
891
 * @param cbuffer The buffer of compressed data.
892
 * @param nbytes The pointer where the number of uncompressed bytes will be put.
893
 * @param cbytes The pointer where the number of compressed bytes will be put.
894
 * @param blocksize The pointer where the block size will be put.
895
 *
896
 * @note: if any of the nbytes, cbytes or blocksize is NULL, it will not be returned.
897
 *
898
 * You only need to pass the first BLOSC_MIN_HEADER_LENGTH bytes of a
899
 * compressed buffer for this call to work.
900
 *
901
 * @return On failure, returns negative value.
902
 */
903
BLOSC_EXPORT int blosc2_cbuffer_sizes(const void* cbuffer, int32_t* nbytes,
904
                                      int32_t* cbytes, int32_t* blocksize);
905
906
/**
907
 * @brief Checks that the compressed buffer starting at @p cbuffer of length @p cbytes
908
 * may contain valid blosc compressed data, and that it is safe to call
909
 * blosc1_decompress/blosc1_getitem.
910
 * On success, returns 0 and sets @p nbytes to the size of the uncompressed data.
911
 * This does not guarantee that the decompression function won't return an error,
912
 * but does guarantee that it is safe to attempt decompression.
913
 *
914
 * @param cbuffer The buffer of compressed data.
915
 * @param cbytes The number of compressed bytes.
916
 * @param nbytes The pointer where the number of uncompressed bytes will be put.
917
 *
918
 * @return On failure, returns negative value.
919
 */
920
BLOSC_EXPORT int blosc1_cbuffer_validate(const void* cbuffer, size_t cbytes,
921
                                         size_t* nbytes);
922
923
/**
924
 * @brief Get information about a compressed buffer, namely the type size
925
 * (@p typesize), as well as some internal @p flags.
926
 *
927
 * @param cbuffer The buffer of compressed data.
928
 * @param typesize The pointer where the type size will be put.
929
 * @param flags The pointer of the integer where the additional info is encoded.
930
 * The @p flags is a set of bits, where the currently used ones are:
931
 *   * bit 0: whether the shuffle filter has been applied or not
932
 *   * bit 1: whether the internal buffer is a pure memcpy or not
933
 *   * bit 2: whether the bitshuffle filter has been applied or not
934
 *   * bit 3: whether the delta coding filter has been applied or not
935
 *
936
 * You can use the @p BLOSC_DOSHUFFLE, @p BLOSC_DOBITSHUFFLE, @p BLOSC_DODELTA
937
 * and @p BLOSC_MEMCPYED symbols for extracting the interesting bits
938
 * (e.g. @p flags & @p BLOSC_DOSHUFFLE says whether the buffer is byte-shuffled
939
 * or not).
940
 *
941
 * This function should always succeed.
942
 */
943
BLOSC_EXPORT void blosc1_cbuffer_metainfo(const void* cbuffer, size_t* typesize,
944
                                          int* flags);
945
946
947
/**
948
 * @brief Get information about a compressed buffer, namely the internal
949
 * Blosc format version (@p version) and the format for the internal
950
 * Lempel-Ziv compressor used (@p versionlz).
951
 *
952
 * @param cbuffer The buffer of compressed data.
953
 * @param version The pointer where the Blosc format version will be put.
954
 * @param versionlz The pointer where the Lempel-Ziv version will be put.
955
 *
956
 * This function should always succeed.
957
 */
958
BLOSC_EXPORT void blosc2_cbuffer_versions(const void* cbuffer, int* version,
959
                                          int* versionlz);
960
961
962
/**
963
 * @brief Get the compressor library/format used in a compressed buffer.
964
 *
965
 * @param cbuffer The buffer of compressed data.
966
 *
967
 * @return The string identifying the compressor library/format used.
968
 *
969
 * This function should always succeed.
970
 */
971
BLOSC_EXPORT const char* blosc2_cbuffer_complib(const void* cbuffer);
972
973
/*********************************************************************
974
  Structures and functions related with user-defined input/output.
975
*********************************************************************/
976
977
enum {
978
  BLOSC2_IO_FILESYSTEM = 0,
979
  BLOSC2_IO_FILESYSTEM_MMAP = 1,
980
  BLOSC_IO_LAST_BLOSC_DEFINED = 2,  // sentinel
981
  BLOSC_IO_LAST_REGISTERED = 32,  // sentinel
982
};
983
984
enum {
985
  BLOSC2_IO_BLOSC_DEFINED = 32,
986
  BLOSC2_IO_REGISTERED = 160,
987
  BLOSC2_IO_USER_DEFINED = 256
988
};
989
990
typedef void*   (*blosc2_open_cb)(const char *urlpath, const char *mode, void *params);
991
typedef int     (*blosc2_close_cb)(void *stream);
992
typedef int64_t (*blosc2_size_cb)(void *stream);
993
typedef int64_t (*blosc2_write_cb)(const void *ptr, int64_t size, int64_t nitems, int64_t position, void *stream);
994
typedef int64_t (*blosc2_read_cb)(void **ptr, int64_t size, int64_t nitems, int64_t position, void *stream);
995
typedef int     (*blosc2_truncate_cb)(void *stream, int64_t size);
996
typedef int     (*blosc2_destroy_cb)(void *params);
997
998
999
/*
1000
 * Input/Output callbacks.
1001
 */
1002
typedef struct {
1003
  uint8_t id;
1004
  //!< The IO identifier.
1005
  char* name;
1006
  //!< The IO name.
1007
  bool is_allocation_necessary;
1008
  //!< If true, the caller needs to allocate data for the read function (ptr argument). If false, the read function
1009
  //!< takes care of memory allocation and stores the address in the allocated_ptr argument.
1010
  blosc2_open_cb open;
1011
  //!< The IO open callback.
1012
  blosc2_close_cb close;
1013
  //!< The IO close callback.
1014
  blosc2_size_cb size;
1015
  //!< The IO size callback.
1016
  blosc2_write_cb write;
1017
  //!< The IO write callback.
1018
  blosc2_read_cb read;
1019
  //!< The IO read callback.
1020
  blosc2_truncate_cb truncate;
1021
  //!< The IO truncate callback.
1022
  blosc2_destroy_cb destroy;
1023
  //!< The IO destroy callback (called in the end when finished with the schunk).
1024
} blosc2_io_cb;
1025
1026
1027
/*
1028
 * Input/Output parameters.
1029
 */
1030
typedef struct {
1031
  uint8_t id;
1032
  const char *name;
1033
  //!< The IO identifier.
1034
  void *params;
1035
  //!< The IO parameters.
1036
} blosc2_io;
1037
1038
static const blosc2_io BLOSC2_IO_DEFAULTS = {
1039
  /* .id = */ BLOSC2_IO_FILESYSTEM,
1040
  /* .name = */ "filesystem",
1041
  /* .params = */ NULL,
1042
};
1043
1044
1045
/**
1046
 * @brief Register a user-defined input/output callbacks in Blosc.
1047
 *
1048
 * @param io The callbacks API to register.
1049
 *
1050
 * @return 0 if succeeds. Else a negative code is returned.
1051
 */
1052
BLOSC_EXPORT int blosc2_register_io_cb(const blosc2_io_cb *io);
1053
1054
/**
1055
 * @brief Get a user-defined input/output callback in Blosc.
1056
 *
1057
 * @param id The id of the callback to get.
1058
 *
1059
 * @return A pointer containing the desired callback if success. Else a NULL pointer is returned.
1060
 */
1061
BLOSC_EXPORT blosc2_io_cb *blosc2_get_io_cb(uint8_t id);
1062
1063
/*********************************************************************
1064
  Structures and functions related with contexts.
1065
*********************************************************************/
1066
1067
typedef struct blosc2_context_s blosc2_context;   /* opaque type */
1068
1069
typedef struct {
1070
  int (*init)(void * config, blosc2_context* cctx, blosc2_context* dctx);
1071
  //!< Initialize tuner. Keep in mind dctx may be NULL. This should memcpy the cctx->tuner_params.
1072
  int (*next_blocksize)(blosc2_context * context);
1073
  //!< Only compute the next blocksize. Only it is executed if tuner is not initialized.
1074
  int (*next_cparams)(blosc2_context * context);
1075
  //!< Compute the next cparams. Only is executed if tuner is initialized.
1076
  int (*update)(blosc2_context * context, double ctime);
1077
  //!< Update the tuner parameters.
1078
  int (*free)(blosc2_context * context);
1079
  //!< Free the tuner.
1080
  int id;
1081
  //!< The tuner id
1082
  char *name;
1083
  //!< The tuner name
1084
} blosc2_tuner;
1085
1086
1087
/**
1088
 * @brief Register locally a user-defined tuner in Blosc.
1089
 *
1090
 * @param tuner The tuner to register.
1091
 *
1092
 * @return 0 if succeeds. Else a negative code is returned.
1093
 */
1094
BLOSC_EXPORT int blosc2_register_tuner(blosc2_tuner *tuner);
1095
1096
1097
/**
1098
 * @brief The parameters for a prefilter function.
1099
 *
1100
 */
1101
typedef struct {
1102
  void *user_data;  // user-provided info (optional)
1103
  const uint8_t *input;  // the input buffer
1104
  uint8_t *output;  // the output buffer
1105
  int32_t output_size;  // the output size (in bytes)
1106
  int32_t output_typesize;  // the output typesize
1107
  int32_t output_offset; // offset to reach the start of the output buffer
1108
  int64_t nchunk;  // the current nchunk in associated schunk (if exists; if not -1)
1109
  int32_t nblock;  // the current nblock in associated chunk
1110
  int32_t tid;  // thread id
1111
  uint8_t *ttmp;  // a temporary that is able to hold several blocks for the output and is private for each thread
1112
  size_t ttmp_nbytes;  // the size of the temporary in bytes
1113
  blosc2_context *ctx;  // the compression context
1114
} blosc2_prefilter_params;
1115
1116
/**
1117
 * @brief The parameters for a postfilter function.
1118
 *
1119
 */
1120
typedef struct {
1121
  void *user_data;  // user-provided info (optional)
1122
  const uint8_t *input;  // the input buffer
1123
  uint8_t *output;  // the output buffer
1124
  int32_t size;  // the input size (in bytes)
1125
  int32_t typesize;  // the input typesize
1126
  int32_t offset;  // offset to reach the start of the input buffer
1127
  int64_t nchunk;  // the current nchunk in associated schunk (if exists; if not -1)
1128
  int32_t nblock;  // the current nblock in associated chunk
1129
  int32_t tid;  // thread id
1130
  uint8_t *ttmp;  // a temporary that is able to hold several blocks for the output and is private for each thread
1131
  size_t ttmp_nbytes;  // the size of the temporary in bytes
1132
  blosc2_context *ctx;  // the decompression context
1133
} blosc2_postfilter_params;
1134
1135
/**
1136
 * @brief The type of the prefilter function.
1137
 *
1138
 * If the function call is successful, the return value should be 0; else, a negative value.
1139
 */
1140
typedef int (*blosc2_prefilter_fn)(blosc2_prefilter_params* params);
1141
1142
/**
1143
 * @brief The type of the postfilter function.
1144
 *
1145
 * If the function call is successful, the return value should be 0; else, a negative value.
1146
 */
1147
typedef int (*blosc2_postfilter_fn)(blosc2_postfilter_params* params);
1148
1149
/**
1150
 * @brief The parameters for creating a context for compression purposes.
1151
 *
1152
 * In parenthesis it is shown the default value used internally when a 0
1153
 * (zero) in the fields of the struct is passed to a function.
1154
 */
1155
typedef struct {
1156
  uint8_t compcode;
1157
  //!< The compressor codec.
1158
  uint8_t compcode_meta;
1159
  //!< The metadata for the compressor codec.
1160
  uint8_t clevel;
1161
  //!< The compression level (5).
1162
  int use_dict;
1163
  //!< Use dicts or not when compressing (only for ZSTD).
1164
  int32_t typesize;
1165
  //!< The type size (8).
1166
  int16_t nthreads;
1167
  //!< The number of threads to use internally (1).
1168
  int32_t blocksize;
1169
  //!< The requested size of the compressed blocks (0 means automatic).
1170
  int32_t splitmode;
1171
  //!< Whether the blocks should be split or not.
1172
  void* schunk;
1173
  //!< The associated schunk, if any (NULL).
1174
  uint8_t filters[BLOSC2_MAX_FILTERS];
1175
  //!< The (sequence of) filters.
1176
  uint8_t filters_meta[BLOSC2_MAX_FILTERS];
1177
  //!< The metadata for filters.
1178
  blosc2_prefilter_fn prefilter;
1179
  //!< The prefilter function.
1180
  blosc2_prefilter_params *preparams;
1181
  //!< The prefilter parameters.
1182
  void *tuner_params;
1183
  //!< Tune configuration.
1184
  int tuner_id;
1185
  //!< The tuner id.
1186
  bool instr_codec;
1187
  //!< Whether the codec is instrumented or not
1188
  void *codec_params;
1189
  //!< User defined parameters for the codec
1190
  void *filter_params[BLOSC2_MAX_FILTERS];
1191
  //!< User defined parameters for the filters
1192
} blosc2_cparams;
1193
1194
/**
1195
 * @brief Default struct for compression params meant for user initialization.
1196
 */
1197
static const blosc2_cparams BLOSC2_CPARAMS_DEFAULTS = {
1198
        BLOSC_BLOSCLZ, 0, 5, 0, 8, 1, 0,
1199
        BLOSC_FORWARD_COMPAT_SPLIT, NULL,
1200
        {0, 0, 0, 0, 0, BLOSC_SHUFFLE},
1201
        {0, 0, 0, 0, 0, 0},
1202
        NULL, NULL, NULL, 0, 0,
1203
        NULL, {NULL, NULL, NULL, NULL, NULL, NULL}
1204
        };
1205
1206
1207
/**
1208
  @brief The parameters for creating a context for decompression purposes.
1209
1210
  In parenthesis it is shown the default value used internally when a 0
1211
  (zero) in the fields of the struct is passed to a function.
1212
 */
1213
typedef struct {
1214
  int16_t nthreads;
1215
  //!< The number of threads to use internally (1).
1216
  void* schunk;
1217
  //!< The associated schunk, if any (NULL).
1218
  blosc2_postfilter_fn postfilter;
1219
  //!< The postfilter function.
1220
  blosc2_postfilter_params *postparams;
1221
  //!< The postfilter parameters.
1222
} blosc2_dparams;
1223
1224
/**
1225
 * @brief Default struct for decompression params meant for user initialization.
1226
 */
1227
static const blosc2_dparams BLOSC2_DPARAMS_DEFAULTS = {1, NULL, NULL, NULL};
1228
1229
/**
1230
 * @brief Create a context for @a *_ctx() compression functions.
1231
 *
1232
 * @param cparams The blosc2_cparams struct with the compression parameters.
1233
 *
1234
 * @return A pointer to the new context. NULL is returned if this fails.
1235
 *
1236
 * @note This supports the same environment variables than #blosc2_compress
1237
 * for overriding the programmatic compression values.
1238
 *
1239
 * @sa #blosc2_compress
1240
 */
1241
BLOSC_EXPORT blosc2_context* blosc2_create_cctx(blosc2_cparams cparams);
1242
1243
/**
1244
 * @brief Create a context for *_ctx() decompression functions.
1245
 *
1246
 * @param dparams The blosc2_dparams struct with the decompression parameters.
1247
 *
1248
 * @return A pointer to the new context. NULL is returned if this fails.
1249
 *
1250
 * @note This supports the same environment variables than #blosc2_decompress
1251
 * for overriding the programmatic decompression values.
1252
 *
1253
 * @sa #blosc2_decompress
1254
 *
1255
 */
1256
BLOSC_EXPORT blosc2_context* blosc2_create_dctx(blosc2_dparams dparams);
1257
1258
/**
1259
 * @brief Free the resources associated with a context.
1260
 *
1261
 * @param context The context to free.
1262
 *
1263
 * This function should always succeed and is valid for contexts meant for
1264
 * both compression and decompression.
1265
 */
1266
BLOSC_EXPORT void blosc2_free_ctx(blosc2_context* context);
1267
1268
/**
1269
 * @brief Create a @p cparams associated to a context.
1270
 *
1271
 * @param ctx The context from where to extract the compression parameters.
1272
 * @param cparams The pointer where the compression params will be stored.
1273
 *
1274
 * @return 0 if succeeds. Else a negative code is returned.
1275
 */
1276
BLOSC_EXPORT int blosc2_ctx_get_cparams(blosc2_context *ctx, blosc2_cparams *cparams);
1277
1278
/**
1279
 * @brief Create a @p dparams associated to a context.
1280
 *
1281
 * @param ctx The context from where to extract the decompression parameters.
1282
 * @param dparams The pointer where the decompression params will be stored.
1283
 *
1284
 * @return 0 if succeeds. Else a negative code is returned.
1285
 */
1286
BLOSC_EXPORT int blosc2_ctx_get_dparams(blosc2_context *ctx, blosc2_dparams *dparams);
1287
1288
/**
1289
 * @brief Set a maskout so as to avoid decompressing specified blocks.
1290
 *
1291
 * @param ctx The decompression context to update.
1292
 *
1293
 * @param maskout The boolean mask for the blocks where decompression
1294
 * is to be avoided.
1295
 *
1296
 * @remark The maskout is valid for contexts *only* meant for decompressing
1297
 * a chunk via #blosc2_decompress_ctx.  Once a call to #blosc2_decompress_ctx
1298
 * is done, this mask is reset so that next call to #blosc2_decompress_ctx
1299
 * will decompress the whole chunk.
1300
 *
1301
 * @param nblocks The number of blocks in maskout above.
1302
 *
1303
 * @return If success, a 0 is returned.  An error is signaled with a negative int.
1304
 *
1305
 */
1306
BLOSC_EXPORT int blosc2_set_maskout(blosc2_context *ctx, bool *maskout, int nblocks);
1307
1308
/**
1309
 * @brief Compress a block of data in the @p src buffer and returns the size of
1310
 * compressed block.
1311
 *
1312
 * @remark Compression is memory safe and guaranteed not to write @p dest
1313
 * more than what is specified in @p destsize.
1314
 * There is not a minimum for @p src buffer size @p nbytes.
1315
 *
1316
 * @warning The @p src buffer and the @p dest buffer can not overlap.
1317
 *
1318
 * @param clevel The desired compression level and must be a number
1319
 * between 0 (no compression) and 9 (maximum compression).
1320
 * @param doshuffle Specifies whether the shuffle compression preconditioner
1321
 * should be applied or not. #BLOSC_NOFILTER means not applying filters,
1322
 * #BLOSC_SHUFFLE means applying shuffle at a byte level and
1323
 * #BLOSC_BITSHUFFLE at a bit level (slower but *may* achieve better
1324
 * compression).
1325
 * @param typesize Is the number of bytes for the atomic type in binary
1326
 * @p src buffer.  This is mainly useful for the shuffle preconditioner.
1327
 * For implementation reasons, only a 1 < typesize < 256 will allow the
1328
 * shuffle filter to work.  When typesize is not in this range, shuffle
1329
 * will be silently disabled.
1330
 * @param src The buffer containing the data to compress.
1331
 * @param srcsize The number of bytes to compress in the @p src buffer.
1332
 * @param dest The buffer where the compressed data will be put,
1333
 * must have at least the size of @p destsize.
1334
 * @param destsize The size of the dest buffer. Blosc
1335
 * guarantees that if you set @p destsize to, at least,
1336
 * (@p nbytes + #BLOSC2_MAX_OVERHEAD), the compression will always succeed.
1337
 *
1338
 * @return The number of bytes compressed.
1339
 * If @p src buffer cannot be compressed into @p destsize, the return
1340
 * value is zero and you should discard the contents of the @p dest
1341
 * buffer. A negative return value means that either a parameter is not correct
1342
 * or that an internal error happened. Set the BLOSC_TRACE environment variable
1343
 * for getting more info on what is happening. If the error is not related with
1344
 * wrong params, please report it back together with the buffer data causing this,
1345
 * as well as the compression params used.
1346
*/
1347
/*
1348
 * Environment variables
1349
 * _____________________
1350
 *
1351
 * *blosc2_compress()* honors different environment variables to control
1352
 * internal parameters without the need of doing that programmatically.
1353
 * Here are the ones supported:
1354
 *
1355
 * **BLOSC_CLEVEL=(INTEGER)**: This will overwrite the @p clevel parameter
1356
 * before the compression process starts.
1357
 *
1358
 * **BLOSC_SHUFFLE=[NOSHUFFLE | SHUFFLE | BITSHUFFLE]**: This will
1359
 * overwrite the *doshuffle* parameter before the compression process
1360
 * starts.
1361
 *
1362
 * **BLOSC_DELTA=(1|0)**: This will call *blosc2_set_delta()^* before the
1363
 * compression process starts.
1364
 *
1365
 * **BLOSC_TYPESIZE=(INTEGER)**: This will overwrite the *typesize*
1366
 * parameter before the compression process starts.
1367
 *
1368
 * **BLOSC_COMPRESSOR=[BLOSCLZ | LZ4 | LZ4HC | ZLIB | ZSTD]**:
1369
 * This will call #blosc_set_compressor before the compression process starts.
1370
 *
1371
 * **BLOSC_NTHREADS=(INTEGER)**: This will call
1372
 * #blosc_set_nthreads before the compression process
1373
 * starts.
1374
 *
1375
 * **BLOSC_SPLITMODE=(ALWAYS | NEVER | AUTO | FORWARD_COMPAT)**:
1376
 * This will call #blosc1_set_splitmode() before the compression process starts.
1377
 *
1378
 * **BLOSC_BLOCKSIZE=(INTEGER)**: This will call
1379
 * #blosc_set_blocksize before the compression process starts.
1380
 * *NOTE:* The blocksize is a critical parameter with
1381
 * important restrictions in the allowed values, so use this with care.
1382
 *
1383
 * **BLOSC_NOLOCK=(ANY VALUE)**: This will call #blosc2_compress_ctx under
1384
 * the hood, with the *compressor*, *blocksize* and
1385
 * *numinternalthreads* parameters set to the same as the last calls to
1386
 * #blosc1_set_compressor, #blosc1_set_blocksize and
1387
 * #blosc2_set_nthreads. *BLOSC_CLEVEL*, *BLOSC_SHUFFLE*, *BLOSC_DELTA* and
1388
 * *BLOSC_TYPESIZE* environment vars will also be honored.
1389
 *
1390
 */
1391
BLOSC_EXPORT int blosc2_compress(int clevel, int doshuffle, int32_t typesize,
1392
                                 const void* src, int32_t srcsize, void* dest,
1393
                                 int32_t destsize);
1394
1395
1396
/**
1397
 * @brief Decompress a block of compressed data in @p src, put the result in
1398
 * @p dest and returns the size of the decompressed block.
1399
 *
1400
 * @warning The @p src buffer and the @p dest buffer can not overlap.
1401
 *
1402
 * @remark Decompression is memory safe and guaranteed not to write the @p dest
1403
 * buffer more than what is specified in @p destsize.
1404
 *
1405
 * @remark In case you want to keep under control the number of bytes read from
1406
 * source, you can call #blosc1_cbuffer_sizes first to check whether the
1407
 * @p nbytes (i.e. the number of bytes to be read from @p src buffer by this
1408
 * function) in the compressed buffer is ok with you.
1409
 *
1410
 * @param src The buffer to be decompressed.
1411
 * @param srcsize The size of the buffer to be decompressed.
1412
 * @param dest The buffer where the decompressed data will be put.
1413
 * @param destsize The size of the @p dest buffer.
1414
 *
1415
 * @return The number of bytes decompressed.
1416
 * If an error occurs, e.g. the compressed data is corrupted or the
1417
 * output buffer is not large enough, then a negative value
1418
 * will be returned instead.
1419
*/
1420
/*
1421
 * Environment variables
1422
 * _____________________
1423
 *
1424
 * *blosc1_decompress* honors different environment variables to control
1425
 * internal parameters without the need of doing that programmatically.
1426
 * Here are the ones supported:
1427
 *
1428
 * **BLOSC_NTHREADS=(INTEGER)**: This will call
1429
 * *blosc_set_nthreads(BLOSC_NTHREADS)* before the proper decompression
1430
 * process starts.
1431
 *
1432
 * **BLOSC_NOLOCK=(ANY VALUE)**: This will call *blosc2_decompress_ctx*
1433
 * under the hood, with the *numinternalthreads* parameter set to the
1434
 * same value as the last call to *blosc2_set_nthreads*.
1435
 *
1436
 */
1437
BLOSC_EXPORT int blosc2_decompress(const void* src, int32_t srcsize,
1438
                                   void* dest, int32_t destsize);
1439
1440
/**
1441
 * @brief Context interface to Blosc compression. This does not require a call
1442
 * to #blosc2_init and can be called from multithreaded applications
1443
 * without the global lock being used, so allowing Blosc be executed
1444
 * simultaneously in those scenarios.
1445
 *
1446
 * @param context A blosc2_context struct with the different compression params.
1447
 * @param src The buffer containing the data to be compressed.
1448
 * @param srcsize The number of bytes to be compressed from the @p src buffer.
1449
 * @param dest The buffer where the compressed data will be put.
1450
 * @param destsize The size in bytes of the @p dest buffer.
1451
 *
1452
 * @return The number of bytes compressed.
1453
 * If @p src buffer cannot be compressed into @p destsize, the return
1454
 * value is zero and you should discard the contents of the @p dest
1455
 * buffer.  A negative return value means that an internal error happened.
1456
 * It could happen that context is not meant for compression (which is stated in stderr).
1457
 * Otherwise, please report it back together with the buffer data causing this
1458
 * and compression settings.
1459
 */
1460
BLOSC_EXPORT int blosc2_compress_ctx(
1461
        blosc2_context* context, const void* src, int32_t srcsize, void* dest,
1462
        int32_t destsize);
1463
1464
1465
/**
1466
 * @brief Context interface to Blosc decompression. This does not require a
1467
 * call to #blosc2_init and can be called from multithreaded
1468
 * applications without the global lock being used, so allowing Blosc
1469
 * be executed simultaneously in those scenarios.
1470
 *
1471
 * @param context The blosc2_context struct with the different compression params.
1472
 * @param src The buffer of compressed data.
1473
 * @param srcsize The length of buffer of compressed data.
1474
 * @param dest The buffer where the decompressed data will be put.
1475
 * @param destsize The size in bytes of the @p dest buffer.
1476
 *
1477
 * @warning The @p src buffer and the @p dest buffer can not overlap.
1478
 *
1479
 * @remark Decompression is memory safe and guaranteed not to write the @p dest
1480
 * buffer more than what is specified in @p destsize.
1481
 *
1482
 * @remark In case you want to keep under control the number of bytes read from
1483
 * source, you can call #blosc1_cbuffer_sizes first to check the @p nbytes
1484
 * (i.e. the number of bytes to be read from @p src buffer by this function)
1485
 * in the compressed buffer.
1486
 *
1487
 * @remark If #blosc2_set_maskout is called prior to this function, its
1488
 * @p block_maskout parameter will be honored for just *one single* shot;
1489
 * i.e. the maskout in context will be automatically reset to NULL, so
1490
 * mask won't be used next time (unless #blosc2_set_maskout is called again).
1491
 *
1492
 * @return The number of bytes decompressed (i.e. the maskout blocks are not
1493
 * counted). If an error occurs, e.g. the compressed data is corrupted,
1494
 * @p destsize is not large enough or context is not meant for decompression,
1495
 * then a negative value will be returned instead.
1496
 */
1497
BLOSC_EXPORT int blosc2_decompress_ctx(blosc2_context* context, const void* src,
1498
                                       int32_t srcsize, void* dest, int32_t destsize);
1499
1500
/**
1501
 * @brief Create a chunk made of zeros.
1502
 *
1503
 * @param cparams The compression parameters.
1504
 * @param nbytes The size (in bytes) of the chunk.
1505
 * @param dest The buffer where the data chunk will be put.
1506
 * @param destsize The size (in bytes) of the @p dest buffer;
1507
 * must be BLOSC_EXTENDED_HEADER_LENGTH at least.
1508
 *
1509
 * @return The number of bytes compressed (BLOSC_EXTENDED_HEADER_LENGTH).
1510
 * If negative, there has been an error and @p dest is unusable.
1511
 * */
1512
BLOSC_EXPORT int blosc2_chunk_zeros(blosc2_cparams cparams, int32_t nbytes,
1513
                                    void* dest, int32_t destsize);
1514
1515
1516
/**
1517
 * @brief Create a chunk made of nans.
1518
 *
1519
 * @param cparams The compression parameters;
1520
 * only 4 bytes (float) and 8 bytes (double) are supported.
1521
 * @param nbytes The size (in bytes) of the chunk.
1522
 * @param dest The buffer where the data chunk will be put.
1523
 * @param destsize The size (in bytes) of the @p dest buffer;
1524
 * must be BLOSC_EXTENDED_HEADER_LENGTH at least.
1525
 *
1526
 * @note Whether the NaNs are floats or doubles will be given by the typesize.
1527
 *
1528
 * @return The number of bytes compressed (BLOSC_EXTENDED_HEADER_LENGTH).
1529
 * If negative, there has been an error and @p dest is unusable.
1530
 * */
1531
BLOSC_EXPORT int blosc2_chunk_nans(blosc2_cparams cparams, int32_t nbytes,
1532
                                   void* dest, int32_t destsize);
1533
1534
1535
/**
1536
 * @brief Create a chunk made of repeated values.
1537
 *
1538
 * @param cparams The compression parameters.
1539
 * @param nbytes The size (in bytes) of the chunk.
1540
 * @param dest The buffer where the data chunk will be put.
1541
 * @param destsize The size (in bytes) of the @p dest buffer.
1542
 * @param repeatval A pointer to the repeated value (little endian).
1543
 * The size of the value is given by @p cparams.typesize param.
1544
 *
1545
 * @return The number of bytes compressed (BLOSC_EXTENDED_HEADER_LENGTH + typesize).
1546
 * If negative, there has been an error and @p dest is unusable.
1547
 * */
1548
BLOSC_EXPORT int blosc2_chunk_repeatval(blosc2_cparams cparams, int32_t nbytes,
1549
                                        void* dest, int32_t destsize, const void* repeatval);
1550
1551
1552
/**
1553
 * @brief Create a chunk made of uninitialized values.
1554
 *
1555
 * @param cparams The compression parameters.
1556
 * @param nbytes The size (in bytes) of the chunk.
1557
 * @param dest The buffer where the data chunk will be put.
1558
 * @param destsize The size (in bytes) of the @p dest buffer;
1559
 * must be BLOSC_EXTENDED_HEADER_LENGTH at least.
1560
 *
1561
 * @return The number of bytes compressed (BLOSC_EXTENDED_HEADER_LENGTH).
1562
 * If negative, there has been an error and @p dest is unusable.
1563
 * */
1564
BLOSC_EXPORT int blosc2_chunk_uninit(blosc2_cparams cparams, int32_t nbytes,
1565
                                     void* dest, int32_t destsize);
1566
1567
1568
/**
1569
 * @brief Context interface counterpart for #blosc1_getitem.
1570
 *
1571
 * @param context Context pointer.
1572
 * @param src The compressed buffer from data will be decompressed.
1573
 * @param srcsize Compressed buffer length.
1574
 * @param start The position of the first item (of @p typesize size) from where data
1575
 * will be retrieved.
1576
 * @param nitems The number of items (of @p typesize size) that will be retrieved.
1577
 * @param dest The buffer where the decompressed data retrieved will be put.
1578
 * @param destsize Output buffer length.
1579
 *
1580
 * @return The number of bytes copied to @p dest or a negative value if
1581
 * some error happens.
1582
 */
1583
BLOSC_EXPORT int blosc2_getitem_ctx(blosc2_context* context, const void* src,
1584
                                    int32_t srcsize, int start, int nitems, void* dest,
1585
                                    int32_t destsize);
1586
1587
1588
/*********************************************************************
1589
  Super-chunk related structures and functions.
1590
*********************************************************************/
1591
1592
0
#define BLOSC2_MAX_METALAYERS 16
1593
0
#define BLOSC2_METALAYER_NAME_MAXLEN 31
1594
1595
// Allow for a reasonable number of vl metalayers
1596
// max is 64 * 1024 due to msgpack map 16 in frame
1597
// mem usage 8 * 1024 entries for blosc2_schunk.vlmetalayers[] is 64 KB
1598
0
#define BLOSC2_MAX_VLMETALAYERS (8 * 1024)
1599
#define BLOSC2_VLMETALAYERS_NAME_MAXLEN BLOSC2_METALAYER_NAME_MAXLEN
1600
1601
/**
1602
 * @brief This struct is meant for holding storage parameters for a
1603
 * for a blosc2 container, allowing to specify, for example, how to interpret
1604
 * the contents included in the schunk.
1605
 */
1606
typedef struct {
1607
    bool contiguous;
1608
    //!< Whether the chunks are contiguous or sparse.
1609
    char* urlpath;
1610
    //!< The path for persistent storage. If NULL, that means in-memory.
1611
    blosc2_cparams* cparams;
1612
    //!< The compression params when creating a schunk.
1613
    //!< If NULL, sensible defaults are used depending on the context.
1614
    blosc2_dparams* dparams;
1615
    //!< The decompression params when creating a schunk.
1616
    //!< If NULL, sensible defaults are used depending on the context.
1617
    blosc2_io *io;
1618
    //!< Input/output backend.
1619
} blosc2_storage;
1620
1621
/**
1622
 * @brief Default struct for #blosc2_storage meant for user initialization.
1623
 */
1624
static const blosc2_storage BLOSC2_STORAGE_DEFAULTS = {false, NULL, NULL, NULL, NULL};
1625
1626
/**
1627
 * @brief Get default struct for compression params meant for user initialization.
1628
 */
1629
BLOSC_EXPORT blosc2_cparams blosc2_get_blosc2_cparams_defaults(void);
1630
1631
/**
1632
 * @brief Get default struct for decompression params meant for user initialization.
1633
 */
1634
BLOSC_EXPORT blosc2_dparams blosc2_get_blosc2_dparams_defaults(void);
1635
1636
/**
1637
 * @brief Get default struct for #blosc2_storage meant for user initialization.
1638
 */
1639
BLOSC_EXPORT blosc2_storage blosc2_get_blosc2_storage_defaults(void);
1640
1641
/**
1642
 * @brief Get default struct for #blosc2_io meant for user initialization.
1643
 */
1644
BLOSC_EXPORT blosc2_io blosc2_get_blosc2_io_defaults(void);
1645
1646
/**
1647
 * @brief Get default struct for #blosc2_stdio_mmap meant for user initialization.
1648
 */
1649
BLOSC_EXPORT blosc2_stdio_mmap blosc2_get_blosc2_stdio_mmap_defaults(void);
1650
1651
typedef struct blosc2_frame_s blosc2_frame;   /* opaque type */
1652
1653
/**
1654
 * @brief This struct is meant to store metadata information inside
1655
 * a #blosc2_schunk, allowing to specify, for example, how to interpret
1656
 * the contents included in the schunk.
1657
 */
1658
typedef struct blosc2_metalayer {
1659
  char* name;          //!< The metalayer identifier for Blosc client (e.g. Blosc2 NDim).
1660
  uint8_t* content;    //!< The serialized (msgpack preferably) content of the metalayer.
1661
  int32_t content_len; //!< The length in bytes of the content.
1662
} blosc2_metalayer;
1663
1664
/**
1665
 * @brief This struct is the standard container for Blosc 2 compressed data.
1666
 *
1667
 * This is essentially a container for Blosc 1 chunks of compressed data,
1668
 * and it allows to overcome the 32-bit limitation in Blosc 1. Optionally,
1669
 * a #blosc2_frame can be attached so as to store the compressed chunks contiguously.
1670
 */
1671
typedef struct blosc2_schunk {
1672
  uint8_t version;
1673
  uint8_t compcode;
1674
  //!< The default compressor. Each chunk can override this.
1675
  uint8_t compcode_meta;
1676
  //!< The default compressor metadata. Each chunk can override this.
1677
  uint8_t clevel;
1678
  //!< The compression level and other compress params.
1679
  uint8_t splitmode;
1680
  //!< The split mode.
1681
  int32_t typesize;
1682
  //!< The type size.
1683
  int32_t blocksize;
1684
  //!< The requested size of the compressed blocks (0; meaning automatic).
1685
  int32_t chunksize;
1686
  //!< Size of each chunk. 0 if not a fixed chunksize.
1687
  uint8_t filters[BLOSC2_MAX_FILTERS];
1688
  //!< The (sequence of) filters.  8-bit per filter.
1689
  uint8_t filters_meta[BLOSC2_MAX_FILTERS];
1690
  //!< Metadata for filters. 8-bit per meta-slot.
1691
  int64_t nchunks;
1692
  //!< Number of chunks in super-chunk.
1693
  int64_t current_nchunk;
1694
  //!< The current chunk that is being accessed
1695
  int64_t nbytes;
1696
  //!< The data size (uncompressed).
1697
  int64_t cbytes;
1698
  //!< The data size + chunks header size (compressed).
1699
  uint8_t** data;
1700
  //!< Pointer to chunk data pointers buffer.
1701
  size_t data_len;
1702
  //!< Length of the chunk data pointers buffer.
1703
  blosc2_storage* storage;
1704
  //!< Pointer to storage info.
1705
  blosc2_frame* frame;
1706
  //!< Pointer to frame used as store for chunks.
1707
  //!<uint8_t* ctx;
1708
  //!< Context for the thread holder. NULL if not acquired.
1709
  blosc2_context* cctx;
1710
  //!< Context for compression
1711
  blosc2_context* dctx;
1712
  //!< Context for decompression.
1713
  struct blosc2_metalayer *metalayers[BLOSC2_MAX_METALAYERS];
1714
  //!< The array of metalayers.
1715
  uint16_t nmetalayers;
1716
  //!< The number of metalayers in the super-chunk
1717
  struct blosc2_metalayer *vlmetalayers[BLOSC2_MAX_VLMETALAYERS];
1718
  //<! The array of variable-length metalayers.
1719
  int16_t nvlmetalayers;
1720
  //!< The number of variable-length metalayers.
1721
  void *tuner_params;
1722
  //!< Tune configuration.
1723
  int tuner_id;
1724
  //<! Id for tuner
1725
  int8_t ndim;
1726
  //<! The ndim (mainly for ZFP usage)
1727
  int64_t *blockshape;
1728
  //<! The blockshape (mainly for ZFP usage)
1729
  bool view;
1730
  //<! Whether the schunk is a view or not.
1731
} blosc2_schunk;
1732
1733
1734
/**
1735
 * @brief Create a new super-chunk.
1736
 *
1737
 * @param storage The storage properties.
1738
 *
1739
 * @remark In case that storage.urlpath is not NULL, the data is stored
1740
 * on-disk.  If the data file(s) exist, they are *overwritten*.
1741
 *
1742
 * @return The new super-chunk.
1743
 */
1744
BLOSC_EXPORT blosc2_schunk* blosc2_schunk_new(blosc2_storage *storage);
1745
1746
/**
1747
 * Create a copy of a super-chunk.
1748
 *
1749
 * @param schunk The super-chunk to be copied.
1750
 * @param storage The storage properties.
1751
 *
1752
 * @return The new super-chunk.
1753
 */
1754
BLOSC_EXPORT blosc2_schunk* blosc2_schunk_copy(blosc2_schunk *schunk, blosc2_storage *storage);
1755
1756
/**
1757
 * @brief Create a super-chunk out of a contiguous frame buffer.
1758
 *
1759
 * @param cframe The buffer of the in-memory frame.
1760
 * @param copy Whether the super-chunk should make a copy of
1761
 * the @p cframe data or not.  The copy will be made to an internal
1762
 * sparse frame.
1763
 *
1764
 * @remark If copy is false, the @p cframe buffer passed will be owned
1765
 * by the super-chunk and will be automatically freed when
1766
 * blosc2_schunk_free() is called.  If the user frees it after the
1767
 * opening, bad things will happen.  Don't do that (or set @p copy).
1768
 *
1769
 * @param len The length of the buffer (in bytes).
1770
 *
1771
 * @return The new super-chunk.
1772
 */
1773
BLOSC_EXPORT blosc2_schunk* blosc2_schunk_from_buffer(uint8_t *cframe, int64_t len, bool copy);
1774
1775
/**
1776
 * @brief Set the private `avoid_cframe_free` field in a frame.
1777
 *
1778
 * @param schunk The super-chunk referencing the frame.
1779
 * @param avoid_cframe_free The value to set in the blosc2_frame_s structure.
1780
 *
1781
 * @warning If you set it to `true` you will be responsible of freeing it.
1782
 */
1783
BLOSC_EXPORT void blosc2_schunk_avoid_cframe_free(blosc2_schunk *schunk, bool avoid_cframe_free);
1784
1785
/**
1786
 * @brief Open an existing super-chunk that is on-disk (frame). No in-memory copy is made.
1787
 *
1788
 * @param urlpath The file name.
1789
 *
1790
 * @return The new super-chunk.  NULL if not found or not in frame format.
1791
 */
1792
BLOSC_EXPORT blosc2_schunk* blosc2_schunk_open(const char* urlpath);
1793
1794
/**
1795
 * @brief Open an existing super-chunk that is on-disk (frame). No in-memory copy is made.
1796
 *
1797
 * @param urlpath The file name.
1798
 *
1799
 * @param offset The frame offset.
1800
 *
1801
 * @return The new super-chunk.  NULL if not found or not in frame format.
1802
 */
1803
BLOSC_EXPORT blosc2_schunk* blosc2_schunk_open_offset(const char* urlpath, int64_t offset);
1804
1805
/**
1806
 * @brief Open an existing super-chunk (no copy is made) using a user-defined I/O interface.
1807
 *
1808
 * @param urlpath The file name.
1809
 *
1810
 * @param udio The user-defined I/O interface.
1811
 *
1812
 * @return The new super-chunk.
1813
 */
1814
BLOSC_EXPORT blosc2_schunk* blosc2_schunk_open_udio(const char* urlpath, const blosc2_io *udio);
1815
1816
/**
1817
 * @brief Open an existing super-chunk (no copy is made) using a user-defined I/O interface.
1818
 *
1819
 * @param urlpath The file name.
1820
 *
1821
 * @param offset The frame offset.
1822
 *
1823
 * @param udio The user-defined I/O interface.
1824
 *
1825
 * @return The new super-chunk.
1826
 */
1827
BLOSC_EXPORT blosc2_schunk* blosc2_schunk_open_offset_udio(const char* urlpath, int64_t offset, const blosc2_io *udio);
1828
1829
/* @brief Convert a super-chunk into a contiguous frame buffer.
1830
 *
1831
 * @param schunk The super-chunk to convert.
1832
 * @param cframe The address of the destination buffer (output).
1833
 * @param needs_free The pointer to a boolean indicating if it is the user's
1834
 * responsibility to free the resulting @p cframe buffer or not.
1835
 *
1836
 * @return If successful, return the size of the (frame) @p cframe buffer.
1837
 * Else, a negative value.
1838
 */
1839
BLOSC_EXPORT int64_t blosc2_schunk_to_buffer(blosc2_schunk* schunk, uint8_t** cframe, bool* needs_free);
1840
1841
/* @brief Store a super-chunk into a file.
1842
 *
1843
 * @param schunk The super-chunk to write.
1844
 * @param urlpath The path for persistent storage.
1845
 *
1846
 * @return If successful, return the size of the (fileframe) in @p urlpath.
1847
 * Else, a negative value.
1848
 */
1849
BLOSC_EXPORT int64_t blosc2_schunk_to_file(blosc2_schunk* schunk, const char* urlpath);
1850
1851
/* @brief Append a super-chunk into a file.
1852
 *
1853
 * @param schunk The super-chunk to write.
1854
 * @param urlpath The path for persistent storage.
1855
 *
1856
 * @return If successful, return the offset where @p schunk has been appended in @p urlpath.
1857
 * Else, a negative value.
1858
 */
1859
BLOSC_EXPORT int64_t blosc2_schunk_append_file(blosc2_schunk* schunk, const char* urlpath);
1860
1861
/**
1862
 * @brief Release resources from a super-chunk.
1863
 *
1864
 * @param schunk The super-chunk to be freed.
1865
 *
1866
 * @remark All the memory resources attached to the super-chunk are freed.
1867
 * If the super-chunk is on-disk, the data continues there for a later
1868
 * re-opening.
1869
 *
1870
 * @return 0 if success.
1871
 */
1872
BLOSC_EXPORT int blosc2_schunk_free(blosc2_schunk *schunk);
1873
1874
/**
1875
 * @brief Append an existing @p chunk to a super-chunk.
1876
 *
1877
 * @param schunk The super-chunk where the chunk will be appended.
1878
 * @param chunk The @p chunk to append.  An internal copy is made, so @p chunk can be reused or
1879
 * freed if desired.
1880
 * @param copy Whether the chunk should be copied internally or can be used as-is.
1881
 *
1882
 * @return The number of chunks in super-chunk. If some problem is
1883
 * detected, this number will be negative.
1884
 */
1885
BLOSC_EXPORT int64_t blosc2_schunk_append_chunk(blosc2_schunk *schunk, uint8_t *chunk, bool copy);
1886
1887
/**
1888
  * @brief Update a chunk at a specific position in a super-chunk.
1889
  *
1890
  * @param schunk The super-chunk where the chunk will be updated.
1891
  * @param nchunk The position where the chunk will be updated.
1892
  * @param chunk The new @p chunk. If an internal copy is made, the @p chunk can be reused or
1893
  * freed if desired.
1894
  * @param copy Whether the chunk should be copied internally or can be used as-is.
1895
  *
1896
  * @return The number of chunks in super-chunk. If some problem is
1897
  * detected, this number will be negative.
1898
  */
1899
BLOSC_EXPORT int64_t blosc2_schunk_update_chunk(blosc2_schunk *schunk, int64_t nchunk, uint8_t *chunk, bool copy);
1900
1901
/**
1902
 * @brief Insert a chunk at a specific position in a super-chunk.
1903
 *
1904
 * @param schunk The super-chunk where the chunk will be appended.
1905
 * @param nchunk The position where the chunk will be inserted.
1906
 * @param chunk The @p chunk to insert. If an internal copy is made, the @p chunk can be reused or
1907
 * freed if desired.
1908
 * @param copy Whether the chunk should be copied internally or can be used as-is.
1909
 *
1910
 * @return The number of chunks in super-chunk. If some problem is
1911
 * detected, this number will be negative.
1912
 */
1913
BLOSC_EXPORT int64_t blosc2_schunk_insert_chunk(blosc2_schunk *schunk, int64_t nchunk, uint8_t *chunk, bool copy);
1914
1915
/**
1916
 * @brief Delete a chunk at a specific position in a super-chunk.
1917
 *
1918
 * @param schunk The super-chunk where the chunk will be deleted.
1919
 * @param nchunk The position where the chunk will be deleted.
1920
 *
1921
 * @return The number of chunks in super-chunk. If some problem is
1922
 * detected, this number will be negative.
1923
 */
1924
BLOSC_EXPORT int64_t blosc2_schunk_delete_chunk(blosc2_schunk *schunk, int64_t nchunk);
1925
1926
/**
1927
 * @brief Append a @p src data buffer to a super-chunk.
1928
 *
1929
 * @param schunk The super-chunk where data will be appended.
1930
 * @param src The buffer of data to compress.
1931
 * @param nbytes The size of the @p src buffer.
1932
 *
1933
 * @return The number of chunks in super-chunk. If some problem is
1934
 * detected, this number will be negative.
1935
 */
1936
BLOSC_EXPORT int64_t blosc2_schunk_append_buffer(blosc2_schunk *schunk, const void *src, int32_t nbytes);
1937
1938
/**
1939
 * @brief Decompress and return the @p nchunk chunk of a super-chunk.
1940
 *
1941
 * If the chunk is uncompressed successfully, it is put in the @p *dest
1942
 * pointer.
1943
 *
1944
 * @param schunk The super-chunk from where the chunk will be decompressed.
1945
 * @param nchunk The chunk to be decompressed (0 indexed).
1946
 * @param dest The buffer where the decompressed data will be put.
1947
 * @param nbytes The size of the area pointed by @p *dest.
1948
 *
1949
 * @warning You must make sure that you have enough space to store the
1950
 * uncompressed data.
1951
 *
1952
 * @return The size of the decompressed chunk or 0 if it is non-initialized. If some problem is
1953
 * detected, a negative code is returned instead.
1954
 */
1955
BLOSC_EXPORT int blosc2_schunk_decompress_chunk(blosc2_schunk *schunk, int64_t nchunk, void *dest, int32_t nbytes);
1956
1957
/**
1958
 * @brief Return a compressed chunk that is part of a super-chunk in the @p chunk parameter.
1959
 *
1960
 * @param schunk The super-chunk from where to extract a chunk.
1961
 * @param nchunk The chunk to be extracted (0 indexed).
1962
 * @param chunk The pointer to the chunk of compressed data.
1963
 * @param needs_free The pointer to a boolean indicating if it is the user's
1964
 * responsibility to free the chunk returned or not.
1965
 *
1966
 * @warning If the super-chunk is backed by a frame that is disk-based, a buffer is allocated for the
1967
 * (compressed) chunk, and hence a free is needed.
1968
 * You can check whether the chunk requires a free with the @p needs_free parameter.
1969
 * If the chunk does not need a free, it means that a pointer to the location in the super-chunk
1970
 * (or the backing in-memory frame) is returned in the @p chunk parameter.
1971
 *
1972
 * @return The size of the (compressed) chunk or 0 if it is non-initialized. If some problem is
1973
 * detected, a negative code is returned instead.
1974
 */
1975
BLOSC_EXPORT int blosc2_schunk_get_chunk(blosc2_schunk *schunk, int64_t nchunk, uint8_t **chunk,
1976
                                         bool *needs_free);
1977
1978
/**
1979
 * @brief Return a (lazy) compressed chunk that is part of a super-chunk in the @p chunk parameter.
1980
 *
1981
 * @param schunk The super-chunk from where to extract a chunk.
1982
 * @param nchunk The chunk to be extracted (0 indexed).
1983
 * @param chunk The pointer to the (lazy) chunk of compressed data.
1984
 * @param needs_free The pointer to a boolean indicating if it is the user's
1985
 * responsibility to free the chunk returned or not.
1986
 *
1987
 * @note For disk-based frames, a lazy chunk is always returned.
1988
 *
1989
 * @warning Currently, a lazy chunk can only be used by #blosc2_decompress_ctx and #blosc2_getitem_ctx.
1990
 *
1991
 * @warning If the super-chunk is backed by a frame that is disk-based, a buffer is allocated for the
1992
 * (compressed) chunk, and hence a free is needed.
1993
 * You can check whether requires a free with the @p needs_free parameter.
1994
 * If the chunk does not need a free, it means that a pointer to the location in the super-chunk
1995
 * (or the backing in-memory frame) is returned in the @p chunk parameter.  In this case the returned
1996
 * chunk is not lazy.
1997
 *
1998
 * @return The size of the (compressed) chunk or 0 if it is non-initialized. If some problem is
1999
 * detected, a negative code is returned instead.  Note that a lazy chunk is somewhat larger than
2000
 * a regular chunk because of the trailer section (for details see `README_CHUNK_FORMAT.rst`).
2001
 */
2002
BLOSC_EXPORT int blosc2_schunk_get_lazychunk(blosc2_schunk *schunk, int64_t nchunk, uint8_t **chunk,
2003
                                             bool *needs_free);
2004
2005
/**
2006
 * @brief Fill buffer with a schunk slice.
2007
 *
2008
 * @param schunk The super-chunk from where to extract a slice.
2009
 * @param start Index (0-based) where the slice begins.
2010
 * @param stop The first index (0-based) that is not in the selected slice.
2011
 * @param buffer The buffer where the data will be stored.
2012
 *
2013
 * @warning You must make sure that you have enough space in buffer to store the
2014
 * uncompressed data.
2015
 *
2016
 * @return An error code.
2017
 */
2018
BLOSC_EXPORT int blosc2_schunk_get_slice_buffer(blosc2_schunk *schunk, int64_t start, int64_t stop, void *buffer);
2019
2020
/**
2021
 * @brief Update a schunk slice from buffer.
2022
 *
2023
 * @param schunk The super-chunk where to set the slice.
2024
 * @param start Index (0-based) where the slice begins.
2025
 * @param stop The first index (0-based) that is not in the selected slice.
2026
 * @param buffer The buffer containing the data to set.
2027
 *
2028
 *
2029
 * @return An error code.
2030
 */
2031
BLOSC_EXPORT int blosc2_schunk_set_slice_buffer(blosc2_schunk *schunk, int64_t start, int64_t stop, void *buffer);
2032
2033
/**
2034
 * @brief Return the @p cparams associated to a super-chunk.
2035
 *
2036
 * @param schunk The super-chunk from where to extract the compression parameters.
2037
 * @param cparams The pointer where the compression params will be returned.
2038
 *
2039
 * @warning A new struct is allocated, and the user should free it after use.
2040
 *
2041
 * @return 0 if succeeds. Else a negative code is returned.
2042
 */
2043
BLOSC_EXPORT int blosc2_schunk_get_cparams(blosc2_schunk *schunk, blosc2_cparams **cparams);
2044
2045
/**
2046
 * @brief Return the @p dparams struct associated to a super-chunk.
2047
 *
2048
 * @param schunk The super-chunk from where to extract the decompression parameters.
2049
 * @param dparams The pointer where the decompression params will be returned.
2050
 *
2051
 * @warning A new struct is allocated, and the user should free it after use.
2052
 *
2053
 * @return 0 if succeeds. Else a negative code is returned.
2054
 */
2055
BLOSC_EXPORT int blosc2_schunk_get_dparams(blosc2_schunk *schunk, blosc2_dparams **dparams);
2056
2057
/**
2058
 * @brief Reorder the chunk offsets of an existing super-chunk.
2059
 *
2060
 * @param schunk The super-chunk whose chunk offsets are to be reordered.
2061
 * @param offsets_order The new order of the chunk offsets.
2062
 *
2063
 * @return 0 if succeeds. Else a negative code is returned.
2064
 */
2065
BLOSC_EXPORT int blosc2_schunk_reorder_offsets(blosc2_schunk *schunk, int64_t *offsets_order);
2066
2067
/**
2068
 * @brief Get the length (in bytes) of the internal frame of the super-chunk.
2069
 *
2070
 * @param schunk The super-chunk.
2071
 *
2072
 * @return The length (in bytes) of the internal frame.
2073
 * If there is not an internal frame, an estimate of the length is provided.
2074
 */
2075
BLOSC_EXPORT int64_t blosc2_schunk_frame_len(blosc2_schunk* schunk);
2076
2077
/**
2078
 * @brief Quickly fill an empty frame with special values (zeros, NaNs, uninit).
2079
 *
2080
 * @param schunk The super-chunk to be filled.  This must be empty initially.
2081
 * @param nitems The number of items to fill.
2082
 * @param special_value The special value to use for filling.  The only values
2083
 * supported for now are BLOSC2_SPECIAL_ZERO, BLOSC2_SPECIAL_NAN and BLOSC2_SPECIAL_UNINIT.
2084
 * @param chunksize The chunksize for the chunks that are to be added to the super-chunk.
2085
 *
2086
 * @return The total number of chunks that have been added to the super-chunk.
2087
 * If there is an error, a negative value is returned.
2088
 */
2089
BLOSC_EXPORT int64_t blosc2_schunk_fill_special(blosc2_schunk* schunk, int64_t nitems,
2090
                                                int special_value, int32_t chunksize);
2091
2092
2093
/*********************************************************************
2094
  Functions related with fixed-length metalayers.
2095
*********************************************************************/
2096
2097
/**
2098
 * @brief Find whether the schunk has a metalayer or not.
2099
 *
2100
 * @param schunk The super-chunk from which the metalayer will be checked.
2101
 * @param name The name of the metalayer to be checked.
2102
 *
2103
 * @return If successful, return the index of the metalayer. Else, return a negative value.
2104
 */
2105
0
static inline int blosc2_meta_exists(blosc2_schunk *schunk, const char *name) {
2106
0
  if (strlen(name) > BLOSC2_METALAYER_NAME_MAXLEN) {
2107
0
    BLOSC_TRACE_ERROR("Metalayers cannot be larger than %d chars.", BLOSC2_METALAYER_NAME_MAXLEN);
2108
0
    return BLOSC2_ERROR_INVALID_PARAM;
2109
0
  }
2110
2111
0
  if (schunk == NULL) {
2112
0
    BLOSC_TRACE_ERROR("Schunk must not be NUll.");
2113
0
    return BLOSC2_ERROR_INVALID_PARAM;
2114
0
  }
2115
2116
0
  for (int nmetalayer = 0; nmetalayer < schunk->nmetalayers; nmetalayer++) {
2117
0
    if (strcmp(name, schunk->metalayers[nmetalayer]->name) == 0) {
2118
0
      return nmetalayer;
2119
0
    }
2120
0
  }
2121
0
  return BLOSC2_ERROR_NOT_FOUND;
2122
0
}
Unexecuted instantiation: fuzz_compress_chunk.c:blosc2_meta_exists
Unexecuted instantiation: blosc2.c:blosc2_meta_exists
Unexecuted instantiation: blosclz.c:blosc2_meta_exists
Unexecuted instantiation: schunk.c:blosc2_meta_exists
Unexecuted instantiation: frame.c:blosc2_meta_exists
Unexecuted instantiation: stune.c:blosc2_meta_exists
Unexecuted instantiation: trunc-prec.c:blosc2_meta_exists
Unexecuted instantiation: timestamp.c:blosc2_meta_exists
Unexecuted instantiation: sframe.c:blosc2_meta_exists
Unexecuted instantiation: blosc2-stdio.c:blosc2_meta_exists
Unexecuted instantiation: b2nd.c:blosc2_meta_exists
Unexecuted instantiation: b2nd_utils.c:blosc2_meta_exists
Unexecuted instantiation: shuffle.c:blosc2_meta_exists
Unexecuted instantiation: blosc2-zfp.c:blosc2_meta_exists
Unexecuted instantiation: codecs-registry.c:blosc2_meta_exists
Unexecuted instantiation: tuners-registry.c:blosc2_meta_exists
Unexecuted instantiation: filters-registry.c:blosc2_meta_exists
Unexecuted instantiation: ndlz.c:blosc2_meta_exists
Unexecuted instantiation: ndlz4x4.c:blosc2_meta_exists
Unexecuted instantiation: ndlz8x8.c:blosc2_meta_exists
Unexecuted instantiation: ndcell.c:blosc2_meta_exists
Unexecuted instantiation: ndmean.c:blosc2_meta_exists
Unexecuted instantiation: bytedelta.c:blosc2_meta_exists
Unexecuted instantiation: int_trunc.c:blosc2_meta_exists
2123
2124
/**
2125
 * @brief Add content into a new metalayer.
2126
 *
2127
 * @param schunk The super-chunk to which the metalayer should be added.
2128
 * @param name The name of the metalayer.
2129
 * @param content The content of the metalayer.
2130
 * @param content_len The length of the content.
2131
 *
2132
 * @return If successful, the index of the new metalayer. Else, return a negative value.
2133
 */
2134
BLOSC_EXPORT int blosc2_meta_add(blosc2_schunk *schunk, const char *name, uint8_t *content,
2135
                                 int32_t content_len);
2136
2137
/**
2138
 * @brief Update the content of an existing metalayer.
2139
 *
2140
 * @param schunk The frame containing the metalayer.
2141
 * @param name The name of the metalayer to be updated.
2142
 * @param content The new content of the metalayer.
2143
 * @param content_len The length of the content.
2144
 *
2145
 * @note Contrarily to #blosc2_meta_add the updates to metalayers
2146
 * are automatically serialized into a possible attached frame.
2147
 *
2148
 * @return If successful, the index of the metalayer. Else, return a negative value.
2149
 */
2150
BLOSC_EXPORT int blosc2_meta_update(blosc2_schunk *schunk, const char *name, uint8_t *content,
2151
                                    int32_t content_len);
2152
2153
/**
2154
 * @brief Get the content out of a metalayer.
2155
 *
2156
 * @param schunk The frame containing the metalayer.
2157
 * @param name The name of the metalayer.
2158
 * @param content The pointer where the content will be put.
2159
 * @param content_len The length of the content.
2160
 *
2161
 * @warning The @p **content receives a malloc'ed copy of the content.
2162
 * The user is responsible of freeing it.
2163
 *
2164
 * @note This function is inlined and available even when not linking with libblosc2.
2165
 *
2166
 * @return If successful, the index of the new metalayer. Else, return a negative value.
2167
 */
2168
static inline int blosc2_meta_get(blosc2_schunk *schunk, const char *name, uint8_t **content,
2169
0
                                  int32_t *content_len) {
2170
0
  int nmetalayer = blosc2_meta_exists(schunk, name);
2171
0
  if (nmetalayer < 0) {
2172
0
    BLOSC_TRACE_WARNING("Metalayer \"%s\" not found.", name);
2173
0
    return nmetalayer;
2174
0
  }
2175
0
  *content_len = schunk->metalayers[nmetalayer]->content_len;
2176
0
  *content = (uint8_t*)malloc((size_t)*content_len);
2177
0
  memcpy(*content, schunk->metalayers[nmetalayer]->content, (size_t)*content_len);
2178
0
  return nmetalayer;
2179
0
}
Unexecuted instantiation: fuzz_compress_chunk.c:blosc2_meta_get
Unexecuted instantiation: blosc2.c:blosc2_meta_get
Unexecuted instantiation: blosclz.c:blosc2_meta_get
Unexecuted instantiation: schunk.c:blosc2_meta_get
Unexecuted instantiation: frame.c:blosc2_meta_get
Unexecuted instantiation: stune.c:blosc2_meta_get
Unexecuted instantiation: trunc-prec.c:blosc2_meta_get
Unexecuted instantiation: timestamp.c:blosc2_meta_get
Unexecuted instantiation: sframe.c:blosc2_meta_get
Unexecuted instantiation: blosc2-stdio.c:blosc2_meta_get
Unexecuted instantiation: b2nd.c:blosc2_meta_get
Unexecuted instantiation: b2nd_utils.c:blosc2_meta_get
Unexecuted instantiation: shuffle.c:blosc2_meta_get
Unexecuted instantiation: blosc2-zfp.c:blosc2_meta_get
Unexecuted instantiation: codecs-registry.c:blosc2_meta_get
Unexecuted instantiation: tuners-registry.c:blosc2_meta_get
Unexecuted instantiation: filters-registry.c:blosc2_meta_get
Unexecuted instantiation: ndlz.c:blosc2_meta_get
Unexecuted instantiation: ndlz4x4.c:blosc2_meta_get
Unexecuted instantiation: ndlz8x8.c:blosc2_meta_get
Unexecuted instantiation: ndcell.c:blosc2_meta_get
Unexecuted instantiation: ndmean.c:blosc2_meta_get
Unexecuted instantiation: bytedelta.c:blosc2_meta_get
Unexecuted instantiation: int_trunc.c:blosc2_meta_get
2180
2181
2182
/*********************************************************************
2183
  Variable-length metalayers functions.
2184
*********************************************************************/
2185
2186
/**
2187
 * @brief Find whether the schunk has a variable-length metalayer or not.
2188
 *
2189
 * @param schunk The super-chunk from which the variable-length metalayer will be checked.
2190
 * @param name The name of the variable-length metalayer to be checked.
2191
 *
2192
 * @return If successful, return the index of the variable-length metalayer. Else, return a negative value.
2193
 */
2194
BLOSC_EXPORT int blosc2_vlmeta_exists(blosc2_schunk *schunk, const char *name);
2195
2196
/**
2197
 * @brief Add content into a new variable-length metalayer.
2198
 *
2199
 * @param schunk The super-chunk to which the variable-length metalayer should be added.
2200
 * @param name The name of the variable-length metalayer.
2201
 * @param content The content to be added.
2202
 * @param content_len The length of the content.
2203
 * @param cparams The parameters for compressing the variable-length metalayer content. If NULL,
2204
 * the `BLOSC2_CPARAMS_DEFAULTS` will be used.
2205
 *
2206
 * @return If successful, the index of the new variable-length metalayer. Else, return a negative value.
2207
 */
2208
BLOSC_EXPORT int blosc2_vlmeta_add(blosc2_schunk *schunk, const char *name,
2209
                                   uint8_t *content, int32_t content_len,
2210
                                   blosc2_cparams *cparams);
2211
2212
/**
2213
 * @brief Update the content of an existing variable-length metalayer.
2214
 *
2215
 * @param schunk The super-chunk containing the variable-length metalayer.
2216
 * @param name The name of the variable-length metalayer to be updated.
2217
 * @param content The new content of the variable-length metalayer.
2218
 * @param content_len The length of the content.
2219
 * @param cparams The parameters for compressing the variable-length metalayer content. If NULL,
2220
 * the `BLOSC2_CPARAMS_DEFAULTS` will be used.
2221
 *
2222
 * @return If successful, the index of the variable-length metalayer. Else, return a negative value.
2223
 */
2224
BLOSC_EXPORT int blosc2_vlmeta_update(blosc2_schunk *schunk, const char *name,
2225
                                      uint8_t *content, int32_t content_len,
2226
                                      blosc2_cparams *cparams);
2227
2228
/**
2229
 * @brief Get the content out of a variable-length metalayer.
2230
 *
2231
 * @param schunk The super-chunk containing the variable-length metalayer.
2232
 * @param name The name of the variable-length metalayer.
2233
 * @param content The pointer where the content will be put.
2234
 * @param content_len The pointer where the length of the content will be put.
2235
 *
2236
 * @warning The @p **content receives a malloc'ed copy of the content.
2237
 * The user is responsible of freeing it.
2238
 *
2239
 * @return If successful, the index of the new variable-length metalayer. Else, return a negative value.
2240
 */
2241
BLOSC_EXPORT int blosc2_vlmeta_get(blosc2_schunk *schunk, const char *name,
2242
                                   uint8_t **content, int32_t *content_len);
2243
2244
/**
2245
 * @brief Delete the variable-length metalayer from the super-chunk.
2246
 *
2247
 * @param schunk The super-chunk containing the variable-length metalayer.
2248
 * @param name The name of the variable-length metalayer.
2249
 *
2250
 * @return If successful, the number of the variable-length metalayers in the super-chunk. Else, return a negative value.
2251
 */
2252
BLOSC_EXPORT int blosc2_vlmeta_delete(blosc2_schunk *schunk, const char *name);
2253
2254
/**
2255
 * @brief Get a list of all the variable-length metalayer names.
2256
 *
2257
 * @param schunk The super-chunk containing the variable-length metalayers.
2258
 * @param names The pointer to a char** to store the name pointers. This should
2259
 * be of size *schunk->nvlmetalayers * sizeof(char*).
2260
 *
2261
 * @return The number of the variable-length metalayers in the super-chunk.
2262
 * This cannot fail unless the user does not pass a @p names which is large enough to
2263
 * keep pointers to all names, in which case funny things (seg faults and such) will happen.
2264
 */
2265
BLOSC_EXPORT int blosc2_vlmeta_get_names(blosc2_schunk *schunk, char **names);
2266
2267
2268
/*********************************************************************
2269
  Time measurement utilities.
2270
*********************************************************************/
2271
2272
#if defined(_WIN32)
2273
/* For QueryPerformanceCounter(), etc. */
2274
  #include <windows.h>
2275
#elif defined(__MACH__)
2276
#include <mach/clock.h>
2277
#include <mach/mach.h>
2278
#include <time.h>
2279
#elif defined(__unix__)
2280
#if defined(__linux__)
2281
    #include <time.h>
2282
  #else
2283
    #include <sys/time.h>
2284
  #endif
2285
#else
2286
  #error Unable to detect platform.
2287
#endif
2288
2289
/* The type of timestamp used on this system. */
2290
#if defined(_WIN32)
2291
typedef LARGE_INTEGER blosc_timestamp_t;
2292
#else
2293
typedef struct timespec blosc_timestamp_t;
2294
#endif
2295
2296
/*
2297
 * @brief Set a timestamp.
2298
 *
2299
 * @param timestamp
2300
 *
2301
 */
2302
BLOSC_EXPORT void blosc_set_timestamp(blosc_timestamp_t* timestamp);
2303
2304
/*
2305
 * @brief Get the nanoseconds between 2 timestamps.
2306
 *
2307
 * @param start_time
2308
 * @param end_time
2309
 *
2310
 * @return The nanoseconds between start_time and end_time.
2311
 */
2312
BLOSC_EXPORT double blosc_elapsed_nsecs(blosc_timestamp_t start_time,
2313
                                        blosc_timestamp_t end_time);
2314
2315
/*
2316
 * @brief Get the seconds between 2 timestamps.
2317
 *
2318
 * @param start_time
2319
 * @param end_time
2320
 *
2321
 * @return The seconds between start_time and end_time.
2322
 */
2323
BLOSC_EXPORT double blosc_elapsed_secs(blosc_timestamp_t start_time,
2324
                                       blosc_timestamp_t end_time);
2325
2326
2327
/*********************************************************************
2328
  Low-level functions follows.  Use them only if you are an expert!
2329
*********************************************************************/
2330
2331
/**
2332
 * @brief Get the internal blocksize to be used during compression. 0 means
2333
 * that an automatic blocksize is computed internally.
2334
 *
2335
 * @return The size in bytes of the internal block size.
2336
 */
2337
BLOSC_EXPORT int blosc1_get_blocksize(void);
2338
2339
/**
2340
 * @brief Force the use of a specific blocksize. If 0, an automatic
2341
 * blocksize will be used (the default).
2342
 *
2343
 * @warning The blocksize is a critical parameter with important
2344
 * restrictions in the allowed values, so use this with care.
2345
 */
2346
BLOSC_EXPORT void blosc1_set_blocksize(size_t blocksize);
2347
2348
2349
/**
2350
  * @brief Set the split mode.
2351
2352
  * @param splitmode It can take the next values:
2353
  *  BLOSC_FORWARD_COMPAT_SPLIT
2354
  *  BLOSC_AUTO_SPLIT
2355
  *  BLOSC_NEVER_SPLIT
2356
  *  BLOSC_ALWAYS_SPLIT
2357
  *
2358
  * BLOSC_FORWARD_COMPAT offers reasonably forward compatibility,
2359
  * BLOSC_AUTO_SPLIT is for nearly optimal results (based on heuristics),
2360
  * BLOSC_NEVER_SPLIT and BLOSC_ALWAYS_SPLIT are for the user experimenting
2361
  *  when trying to get best compression ratios and/or speed.
2362
  *
2363
  * If not called, the default mode is BLOSC_FORWARD_COMPAT_SPLIT.
2364
  *
2365
  * This function should always succeed.
2366
 */
2367
BLOSC_EXPORT void blosc1_set_splitmode(int splitmode);
2368
2369
2370
/**
2371
 * @brief Get the offsets of a frame in a super-chunk.
2372
 *
2373
 * @param schunk The super-chunk containing the frame.
2374
 *
2375
 * @return If successful, return a pointer to a buffer of the decompressed offsets.
2376
 * The number of offsets is equal to schunk->nchunks; the user is
2377
 * responsible to free this buffer. Else, return a NULL value.
2378
 */
2379
BLOSC_EXPORT int64_t* blosc2_frame_get_offsets(blosc2_schunk *schunk);
2380
2381
2382
/*********************************************************************
2383
  Structures and functions related with compression codecs.
2384
*********************************************************************/
2385
2386
typedef int (* blosc2_codec_encoder_cb) (const uint8_t *input, int32_t input_len, uint8_t *output, int32_t output_len,
2387
            uint8_t meta, blosc2_cparams *cparams, const void* chunk);
2388
typedef int (* blosc2_codec_decoder_cb) (const uint8_t *input, int32_t input_len, uint8_t *output, int32_t output_len,
2389
            uint8_t meta, blosc2_dparams *dparams, const void* chunk);
2390
2391
typedef struct {
2392
  uint8_t compcode;
2393
  //!< The codec identifier.
2394
  char *compname;
2395
  //!< The codec name.
2396
  uint8_t complib;
2397
  //!< The codec library format.
2398
  uint8_t version;
2399
  //!< The codec version.
2400
  blosc2_codec_encoder_cb encoder;
2401
  //!< The codec encoder that is used during compression.
2402
  blosc2_codec_decoder_cb decoder;
2403
  //!< The codec decoder that is used during decompression.
2404
} blosc2_codec;
2405
2406
/**
2407
 * @brief Register locally a user-defined codec in Blosc.
2408
 *
2409
 * @param codec The codec to register.
2410
 *
2411
 * @return 0 if succeeds. Else a negative code is returned.
2412
 */
2413
BLOSC_EXPORT int blosc2_register_codec(blosc2_codec *codec);
2414
2415
2416
/*********************************************************************
2417
  Structures and functions related with filters plugins.
2418
*********************************************************************/
2419
2420
typedef int (* blosc2_filter_forward_cb)  (const uint8_t *, uint8_t *, int32_t, uint8_t, blosc2_cparams *,
2421
                                           uint8_t);
2422
typedef int (* blosc2_filter_backward_cb) (const uint8_t *, uint8_t *, int32_t, uint8_t, blosc2_dparams *,
2423
                                           uint8_t);
2424
2425
/**
2426
 * @brief The parameters for a user-defined filter.
2427
 */
2428
typedef struct {
2429
  uint8_t id;
2430
  //!< The filter identifier.
2431
  char * name;
2432
  //!< The filter name.
2433
  uint8_t version;
2434
  //!< The filter version.
2435
  blosc2_filter_forward_cb forward;
2436
  //!< The filter function that is used during compression.
2437
  blosc2_filter_backward_cb backward;
2438
  //!< The filter function that is used during decompression.
2439
} blosc2_filter;
2440
2441
/**
2442
 * @brief Register locally a user-defined filter in Blosc.
2443
 *
2444
 * @param filter The filter to register.
2445
 *
2446
 * @return 0 if succeeds. Else a negative code is returned.
2447
 */
2448
BLOSC_EXPORT int blosc2_register_filter(blosc2_filter *filter);
2449
2450
/*********************************************************************
2451
  Directory utilities.
2452
*********************************************************************/
2453
2454
/*
2455
 * @brief Remove a directory and its files.
2456
 *
2457
 * @param path The directory to remove.
2458
 *
2459
 * @return 0 if succeeds. Else a negative code is returned.
2460
 */
2461
BLOSC_EXPORT int blosc2_remove_dir(const char *path);
2462
2463
/*
2464
 * @brief Remove a file or a directory given by path.
2465
 *
2466
 * @param path The file or directory to remove.
2467
 *
2468
 * @return 0 if succeeds. Else a negative code is returned.
2469
 */
2470
BLOSC_EXPORT int blosc2_remove_urlpath(const char *path);
2471
2472
/*
2473
 * @brief Rename a file or a directory given by old_urlpath to new_path.
2474
 *
2475
 * @param old_urlpath The original path to the directory or file.
2476
 * @param new_path The new path to the directory or file.
2477
 *
2478
 * @return 0 if succeeds. Else a negative code is returned.
2479
 */
2480
BLOSC_EXPORT int blosc2_rename_urlpath(char* old_urlpath, char* new_path);
2481
2482
2483
/*********************************************************************
2484
  Index utilities.
2485
*********************************************************************/
2486
2487
/*
2488
 * @brief Convert a sequential index into a multidimensional index
2489
 */
2490
BLOSC_EXPORT void blosc2_unidim_to_multidim(uint8_t ndim, int64_t *shape, int64_t i, int64_t *index);
2491
2492
/*
2493
 * @brief Convert a multidimensional index into a sequential index
2494
 */
2495
BLOSC_EXPORT void blosc2_multidim_to_unidim(const int64_t *index, int8_t ndim, const int64_t *strides, int64_t *i);
2496
2497
/*
2498
 * @brief Get the unidimensional chunk indexes needed to get a slice of a schunk or a b2nd array
2499
 *
2500
 * @param schunk The super-chunk (of b2nd array or not).
2501
 * @param start Index (0-based if it is a schunk) where the slice begins.
2502
 * @param stop The first index (0-based if it is a schunk) that is not in the selected slice.
2503
 * @param chunks_idx The pointer to the buffer where the indexes will be written. It is the user responsibility
2504
 * to free the buffer.
2505
 *
2506
 * @return The number of chunks needed to get the slice. If some problem is
2507
 * detected, a negative code is returned instead.
2508
 */
2509
BLOSC_EXPORT int blosc2_get_slice_nchunks(blosc2_schunk* schunk, int64_t *start, int64_t *stop, int64_t **chunks_idx);
2510
2511
2512
/*********************************************************************
2513
  Private functions, these are here for convenience,
2514
  and are not meant to be included in public docs
2515
*********************************************************************/
2516
2517
// Private function needed in b2nd.h for deserializing meta
2518
0
static inline void swap_store(void *dest, const void *pa, int size) {
2519
0
  uint8_t *pa_ = (uint8_t *) pa;
2520
0
  uint8_t *pa2_ = (uint8_t*)malloc((size_t) size);
2521
0
  int i = 1; /* for big/little endian detection */
2522
0
  char *p = (char *) &i;
2523
2524
0
  if (p[0] == 1) {
2525
    /* little endian */
2526
0
    switch (size) {
2527
0
      case 8:
2528
0
        pa2_[0] = pa_[7];
2529
0
        pa2_[1] = pa_[6];
2530
0
        pa2_[2] = pa_[5];
2531
0
        pa2_[3] = pa_[4];
2532
0
        pa2_[4] = pa_[3];
2533
0
        pa2_[5] = pa_[2];
2534
0
        pa2_[6] = pa_[1];
2535
0
        pa2_[7] = pa_[0];
2536
0
        break;
2537
0
      case 4:
2538
0
        pa2_[0] = pa_[3];
2539
0
        pa2_[1] = pa_[2];
2540
0
        pa2_[2] = pa_[1];
2541
0
        pa2_[3] = pa_[0];
2542
0
        break;
2543
0
      case 2:
2544
0
        pa2_[0] = pa_[1];
2545
0
        pa2_[1] = pa_[0];
2546
0
        break;
2547
0
      case 1:
2548
0
        pa2_[0] = pa_[0];
2549
0
        break;
2550
0
      default:
2551
0
        fprintf(stderr, "Unhandled nitems: %d\n", size);
2552
0
    }
2553
0
  }
2554
0
  memcpy(dest, pa2_, size);
2555
0
  free(pa2_);
2556
0
}
Unexecuted instantiation: fuzz_compress_chunk.c:swap_store
Unexecuted instantiation: blosc2.c:swap_store
Unexecuted instantiation: blosclz.c:swap_store
Unexecuted instantiation: schunk.c:swap_store
Unexecuted instantiation: frame.c:swap_store
Unexecuted instantiation: stune.c:swap_store
Unexecuted instantiation: trunc-prec.c:swap_store
Unexecuted instantiation: timestamp.c:swap_store
Unexecuted instantiation: sframe.c:swap_store
Unexecuted instantiation: blosc2-stdio.c:swap_store
Unexecuted instantiation: b2nd.c:swap_store
Unexecuted instantiation: b2nd_utils.c:swap_store
Unexecuted instantiation: shuffle.c:swap_store
Unexecuted instantiation: blosc2-zfp.c:swap_store
Unexecuted instantiation: codecs-registry.c:swap_store
Unexecuted instantiation: tuners-registry.c:swap_store
Unexecuted instantiation: filters-registry.c:swap_store
Unexecuted instantiation: ndlz.c:swap_store
Unexecuted instantiation: ndlz4x4.c:swap_store
Unexecuted instantiation: ndlz8x8.c:swap_store
Unexecuted instantiation: ndcell.c:swap_store
Unexecuted instantiation: ndmean.c:swap_store
Unexecuted instantiation: bytedelta.c:swap_store
Unexecuted instantiation: int_trunc.c:swap_store
2557
2558
#ifdef __cplusplus
2559
}
2560
#endif
2561
2562
#endif /* BLOSC_BLOSC2_H */