Skip to content

Commit aefee19

Browse files
committed
Changes for miniexpr compatibility
1 parent c271956 commit aefee19

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

blosc/blosc2.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
#include <sys/types.h>
6969
#include <assert.h>
7070
#include <math.h>
71-
71+
#include <stdint.h>
7272

7373
/* Synchronization variables */
7474

@@ -946,11 +946,14 @@ uint8_t* pipeline_forward(struct thread_context* thread_context, const int32_t b
946946
uint8_t* filters = context->filters;
947947
uint8_t* filters_meta = context->filters_meta;
948948
bool memcpyed = context->header_flags & (uint8_t)BLOSC_MEMCPYED;
949-
949+
bool output_is_disposable = (context->preparams != NULL) ? context->preparams->output_is_disposable : false;
950+
950951
/* Prefilter function */
951952
if (context->prefilter != NULL) {
952953
/* Set unwritten values to zero */
953-
memset(_dest, 0, bsize);
954+
if (!output_is_disposable) {
955+
memset(_dest, 0, bsize);
956+
}
954957
// Create new prefilter parameters for this block (must be private for each thread)
955958
blosc2_prefilter_params preparams;
956959
memcpy(&preparams, context->preparams, sizeof(preparams));
@@ -965,8 +968,14 @@ uint8_t* pipeline_forward(struct thread_context* thread_context, const int32_t b
965968
preparams.ttmp = thread_context->tmp;
966969
preparams.ttmp_nbytes = thread_context->tmp_nbytes;
967970
preparams.ctx = context;
971+
preparams.output_is_disposable = output_is_disposable;
968972

969973
if (context->prefilter(&preparams) != 0) {
974+
if (output_is_disposable) {
975+
// Output is going to be discarded; no more filters are required
976+
BLOSC_TRACE_INFO("Output is disposable");
977+
return _dest;
978+
}
970979
BLOSC_TRACE_ERROR("Execution of prefilter function failed");
971980
return NULL;
972981
}
@@ -1087,6 +1096,7 @@ static int blosc_c(struct thread_context* thread_context, int32_t bsize,
10871096
int32_t ctbytes = 0; /* number of compressed bytes in block */
10881097
int32_t maxout;
10891098
int32_t typesize = context->typesize;
1099+
bool output_is_disposable = (context->preparams != NULL) ? context->preparams->output_is_disposable : false;
10901100
const char* compname;
10911101
int accel;
10921102
const uint8_t* _src;
@@ -1149,6 +1159,13 @@ static int blosc_c(struct thread_context* thread_context, int32_t bsize,
11491159
ntbytes += sizeof(int32_t);
11501160
ctbytes += sizeof(int32_t);
11511161

1162+
if (context->header_overhead == BLOSC_EXTENDED_HEADER_LENGTH && output_is_disposable) {
1163+
// Simulate a run of 0s
1164+
BLOSC_TRACE_INFO("Output is disposable, simulating a run of 0s");
1165+
memset(dest - 4, 0, sizeof(int32_t));
1166+
continue;
1167+
}
1168+
11521169
const uint8_t *ip = (uint8_t *) _src + j * neblock;
11531170
const uint8_t *ipbound = (uint8_t *) _src + (j + 1) * neblock;
11541171

blosc/directories.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <windows.h>
2222
#include <malloc.h>
2323
#include <io.h>
24+
#include <direct.h> /* <- add this for _rmdir */
2425

2526
int blosc2_remove_dir(const char* dir_path) {
2627
char* path;
@@ -62,7 +63,12 @@
6263
free(fname);
6364
}
6465

65-
rmdir(dir_path);
66+
/* remove the directory */
67+
if (_rmdir(dir_path) != 0) {
68+
BLOSC_TRACE_ERROR("Could not remove directory %s (errno=%d)", dir_path, errno);
69+
_findclose(file);
70+
return BLOSC2_ERROR_FAILURE;
71+
}
6672
_findclose(file);
6773
return BLOSC2_ERROR_SUCCESS;
6874
}

include/blosc2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,7 @@ typedef struct {
11111111
uint8_t *ttmp; // a temporary that is able to hold several blocks for the output and is private for each thread
11121112
size_t ttmp_nbytes; // the size of the temporary in bytes
11131113
blosc2_context *ctx; // the compression context
1114+
bool output_is_disposable; // whether the output buffer is disposable
11141115
} blosc2_prefilter_params;
11151116

11161117
/**

0 commit comments

Comments
 (0)