Skip to content

Commit

Permalink
Fixes in signature of functions
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescAlted committed Oct 30, 2023
1 parent 374f12e commit e01c72a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
11 changes: 5 additions & 6 deletions blosc/blosc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ void _cycle_buffers(uint8_t **src, uint8_t **dest, uint8_t **tmp) {

uint8_t* pipeline_forward(struct thread_context* thread_context, const int32_t bsize,
const uint8_t* src, const int32_t offset,
uint8_t* dest, uint8_t* tmp, uint8_t* tmp2) {
uint8_t* dest, uint8_t* tmp) {
blosc2_context* context = thread_context->parent_context;
uint8_t* _src = (uint8_t*)src + offset;
uint8_t* _tmp = tmp;
Expand Down Expand Up @@ -977,7 +977,7 @@ uint8_t* pipeline_forward(struct thread_context* thread_context, const int32_t b
}
break;
case BLOSC_BITSHUFFLE:
if (bitshuffle(typesize, bsize, _src, _dest, tmp2) < 0) {
if (bitshuffle(typesize, bsize, _src, _dest) < 0) {
return NULL;
}
break;
Expand Down Expand Up @@ -1081,7 +1081,6 @@ static int blosc_c(struct thread_context* thread_context, int32_t bsize,
int accel;
const uint8_t* _src;
uint8_t *_tmp = tmp, *_tmp2 = tmp2;
uint8_t *_tmp3 = thread_context->tmp4;
int last_filter_index = last_filter(context->filters, 'c');
bool memcpyed = context->header_flags & (uint8_t)BLOSC_MEMCPYED;
bool instr_codec = context->blosc2_flags & BLOSC2_INSTR_CODEC;
Expand All @@ -1097,14 +1096,14 @@ static int blosc_c(struct thread_context* thread_context, int32_t bsize,
/* Apply the filter pipeline just for the prefilter */
if (memcpyed && context->prefilter != NULL) {
// We only need the prefilter output
_src = pipeline_forward(thread_context, bsize, src, offset, dest, _tmp2, _tmp3);
_src = pipeline_forward(thread_context, bsize, src, offset, dest, _tmp2);
if (_src == NULL) {
return BLOSC2_ERROR_FILTER_PIPELINE;
}
return bsize;
}
/* Apply regular filter pipeline */
_src = pipeline_forward(thread_context, bsize, src, offset, _tmp, _tmp2, _tmp3);
_src = pipeline_forward(thread_context, bsize, src, offset, _tmp, _tmp2);
if (_src == NULL) {
return BLOSC2_ERROR_FILTER_PIPELINE;
}
Expand Down Expand Up @@ -1357,7 +1356,7 @@ int pipeline_backward(struct thread_context* thread_context, const int32_t bsize
}
break;
case BLOSC_BITSHUFFLE:
if (bitunshuffle(typesize, bsize, _src, _dest, _tmp, context->src[BLOSC2_CHUNK_VERSION]) < 0) {
if (bitunshuffle(typesize, bsize, _src, _dest, context->src[BLOSC2_CHUNK_VERSION]) < 0) {
return BLOSC2_ERROR_FILTER_PIPELINE;
}
break;
Expand Down
25 changes: 10 additions & 15 deletions blosc/shuffle.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@

#include "shuffle-generic.h"
#include "bitshuffle-generic.h"
#include "blosc2/blosc2-common.h"
#include "blosc2.h"

#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>


Expand All @@ -65,8 +62,8 @@ typedef void(* shuffle_func)(const int32_t, const int32_t, const uint8_t*, const
typedef void(* unshuffle_func)(const int32_t, const int32_t, const uint8_t*, const uint8_t*);
// For bitshuffle, everything is done in terms of size_t and int64_t (return value)
// and although this is not strictly necessary for Blosc, it does not hurt either
typedef int64_t(* bitshuffle_func)(void*, void*, const size_t, const size_t, void*);
typedef int64_t(* bitunshuffle_func)(void*, void*, const size_t, const size_t, void*);
typedef int64_t(* bitshuffle_func)(const void*, void*, const size_t, const size_t);
typedef int64_t(* bitunshuffle_func)(const void*, void*, const size_t, const size_t);

/* An implementation of shuffle/unshuffle routines. */
typedef struct shuffle_implementation {
Expand Down Expand Up @@ -449,15 +446,14 @@ unshuffle(const int32_t bytesoftype, const int32_t blocksize,
hardware-accelerated routine at run-time. */
int32_t
bitshuffle(const int32_t bytesoftype, const int32_t blocksize,
const uint8_t *_src, const uint8_t *_dest,
const uint8_t *_tmp) {
const uint8_t *_src, const uint8_t *_dest) {
/* Initialize the shuffle implementation if necessary. */
init_shuffle_implementation();
size_t size = blocksize / bytesoftype;
/* bitshuffle only supports a number of elements that is a multiple of 8. */
size -= size % 8;
int ret = (int) (host_implementation.bitshuffle)((void *) _src, (void *) _dest,
size, bytesoftype, (void *) _tmp);
int ret = (int) (host_implementation.bitshuffle)
((const void *) _src, (void *) _dest, size, bytesoftype);
if (ret < 0) {
// Some error in bitshuffle (should not happen)
BLOSC_TRACE_ERROR("the impossible happened: the bitshuffle filter failed!");
Expand All @@ -475,7 +471,7 @@ bitshuffle(const int32_t bytesoftype, const int32_t blocksize,
hardware-accelerated routine at run-time. */
int32_t bitunshuffle(const int32_t bytesoftype, const int32_t blocksize,
const uint8_t *_src, const uint8_t *_dest,
const uint8_t *_tmp, const uint8_t format_version) {
const uint8_t format_version) {
/* Initialize the shuffle implementation if necessary. */
init_shuffle_implementation();
size_t size = blocksize / bytesoftype;
Expand All @@ -485,9 +481,8 @@ int32_t bitunshuffle(const int32_t bytesoftype, const int32_t blocksize,
if ((size % 8) == 0) {
/* The number of elems is a multiple of 8 which is supported by
bitshuffle. */
int ret = (int) (host_implementation.bitunshuffle)((void *) _src, (void *) _dest,
blocksize / bytesoftype,
bytesoftype, (void *) _tmp);
int ret = (int) (host_implementation.bitunshuffle)
((const void *) _src, (void *) _dest, blocksize / bytesoftype, bytesoftype);
if (ret < 0) {
// Some error in bitshuffle (should not happen)
BLOSC_TRACE_ERROR("the impossible happened: the bitunshuffle filter failed!");
Expand All @@ -504,8 +499,8 @@ int32_t bitunshuffle(const int32_t bytesoftype, const int32_t blocksize,
else {
/* bitshuffle only supports a number of bytes that is a multiple of 8. */
size -= size % 8;
int ret = (int) (host_implementation.bitunshuffle)((void *) _src, (void *) _dest,
size, bytesoftype, (void *) _tmp);
int ret = (int) (host_implementation.bitunshuffle)
((const void *) _src, (void *) _dest, size, bytesoftype);
if (ret < 0) {
BLOSC_TRACE_ERROR("the impossible happened: the bitunshuffle filter failed!");
return ret;
Expand Down
5 changes: 2 additions & 3 deletions blosc/shuffle.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ BLOSC_NO_EXPORT void

BLOSC_NO_EXPORT int32_t
bitshuffle(const int32_t bytesoftype, const int32_t blocksize,
const uint8_t *_src, const uint8_t *_dest,
const uint8_t *_tmp);
const uint8_t *_src, const uint8_t *_dest);

/**
Primary unshuffle and bitunshuffle routine.
Expand All @@ -84,6 +83,6 @@ BLOSC_NO_EXPORT void
BLOSC_NO_EXPORT int32_t
bitunshuffle(const int32_t bytesoftype, const int32_t blocksize,
const uint8_t *_src, const uint8_t *_dest,
const uint8_t *_tmp, const uint8_t format_version);
const uint8_t format_version);

#endif /* BLOSC_SHUFFLE_H */

0 comments on commit e01c72a

Please sign in to comment.