diff options
Diffstat (limited to 'src/backends')
-rw-r--r-- | src/backends/rs_vand/rs_vand.c | 148 |
1 files changed, 74 insertions, 74 deletions
diff --git a/src/backends/rs_vand/rs_vand.c b/src/backends/rs_vand/rs_vand.c index 22500ff..b709e13 100644 --- a/src/backends/rs_vand/rs_vand.c +++ b/src/backends/rs_vand/rs_vand.c @@ -31,32 +31,32 @@ #include "erasurecode_backend.h" #include "erasurecode_helpers.h" -#define LIBERASURECODE_RS_VAND_LIB_MAJOR 1 -#define LIBERASURECODE_RS_VAND_LIB_MINOR 0 -#define LIBERASURECODE_RS_VAND_LIB_REV 0 -#define LIBERASURECODE_RS_VAND_LIB_VER_STR "1.0" -#define LIBERASURECODE_RS_VAND_LIB_NAME "liberasurecode_rsvand" +#define INTERNAL_RS_VAND_LIB_MAJOR 1 +#define INTERNAL_RS_VAND_LIB_MINOR 0 +#define INTERNAL_RS_VAND_LIB_REV 0 +#define INTERNAL_RS_VAND_LIB_VER_STR "1.0" +#define INTERNAL_RS_VAND_LIB_NAME "liberasurecode_rsvand" #if defined(__MACOS__) || defined(__MACOSX__) || defined(__OSX__) || defined(__APPLE__) -#define LIBERASURECODE_RS_VAND_SO_NAME "liberasurecode_rsvand.dylib" +#define INTERNAL_RS_VAND_SO_NAME "liberasurecode_rsvand.dylib" #else -#define LIBERASURECODE_RS_VAND_SO_NAME "liberasurecode_rsvand.so" +#define INTERNAL_RS_VAND_SO_NAME "liberasurecode_rsvand.so" #endif /* Forward declarations */ -struct ec_backend_op_stubs liberasurecode_rs_vand_ops; -struct ec_backend liberasurecode_rs_vand; -struct ec_backend_common backend_liberasurecode_rs_vand; +struct ec_backend_op_stubs internal_rs_vand_ops; +struct ec_backend internal_rs_vand; +struct ec_backend_common backend_internal_rs_vand; -typedef int (*liberasurecode_rs_vand_encode_func)(int *, char **, char **, int, int, int); -typedef int (*liberasurecode_rs_vand_decode_func)(int *, char **, char **, int, int, int *, int, int); -typedef int (*liberasurecode_rs_vand_reconstruct_func)(int *, char **, char **, int, int, int *, int, int); +typedef int (*internal_rs_vand_encode_func)(int *, char **, char **, int, int, int); +typedef int (*internal_rs_vand_decode_func)(int *, char **, char **, int, int, int *, int, int); +typedef int (*internal_rs_vand_reconstruct_func)(int *, char **, char **, int, int, int *, int, int); typedef void (*init_rs_vand_func)(int, int); typedef void (*deinit_rs_vand_func)(); typedef void (*free_systematic_matrix_func)(int *); typedef int* (*make_systematic_matrix_func)(int, int); -struct liberasurecode_rs_vand_descriptor { +struct internal_rs_vand_descriptor { /* calls required for init */ init_rs_vand_func init_rs_vand; deinit_rs_vand_func deinit_rs_vand; @@ -64,13 +64,13 @@ struct liberasurecode_rs_vand_descriptor { make_systematic_matrix_func make_systematic_matrix; /* calls required for encode */ - liberasurecode_rs_vand_encode_func liberasurecode_rs_vand_encode; + internal_rs_vand_encode_func internal_rs_vand_encode; /* calls required for decode */ - liberasurecode_rs_vand_decode_func liberasurecode_rs_vand_decode; + internal_rs_vand_decode_func internal_rs_vand_decode; /* calls required for reconstruct */ - liberasurecode_rs_vand_reconstruct_func liberasurecode_rs_vand_reconstruct; + internal_rs_vand_reconstruct_func internal_rs_vand_reconstruct; /* fields needed to hold state */ int *matrix; @@ -79,49 +79,49 @@ struct liberasurecode_rs_vand_descriptor { int w; }; -static int liberasurecode_rs_vand_encode(void *desc, char **data, char **parity, +static int internal_rs_vand_encode(void *desc, char **data, char **parity, int blocksize) { - struct liberasurecode_rs_vand_descriptor *rs_vand_desc = - (struct liberasurecode_rs_vand_descriptor*) desc; + struct internal_rs_vand_descriptor *rs_vand_desc = + (struct internal_rs_vand_descriptor*) desc; /* FIXME: Should this return something? */ - rs_vand_desc->liberasurecode_rs_vand_encode(rs_vand_desc->matrix, data, parity, + rs_vand_desc->internal_rs_vand_encode(rs_vand_desc->matrix, data, parity, rs_vand_desc->k, rs_vand_desc->m, blocksize); return 0; } -static int liberasurecode_rs_vand_decode(void *desc, char **data, char **parity, +static int internal_rs_vand_decode(void *desc, char **data, char **parity, int *missing_idxs, int blocksize) { - struct liberasurecode_rs_vand_descriptor *rs_vand_desc = - (struct liberasurecode_rs_vand_descriptor*) desc; + struct internal_rs_vand_descriptor *rs_vand_desc = + (struct internal_rs_vand_descriptor*) desc; /* FIXME: Should this return something? */ - rs_vand_desc->liberasurecode_rs_vand_decode(rs_vand_desc->matrix, data, parity, + rs_vand_desc->internal_rs_vand_decode(rs_vand_desc->matrix, data, parity, rs_vand_desc->k, rs_vand_desc->m, missing_idxs, blocksize, 1); return 0; } -static int liberasurecode_rs_vand_reconstruct(void *desc, char **data, char **parity, +static int internal_rs_vand_reconstruct(void *desc, char **data, char **parity, int *missing_idxs, int destination_idx, int blocksize) { - struct liberasurecode_rs_vand_descriptor *rs_vand_desc = - (struct liberasurecode_rs_vand_descriptor*) desc; + struct internal_rs_vand_descriptor *rs_vand_desc = + (struct internal_rs_vand_descriptor*) desc; /* FIXME: Should this return something? */ - rs_vand_desc->liberasurecode_rs_vand_reconstruct(rs_vand_desc->matrix, data, parity, + rs_vand_desc->internal_rs_vand_reconstruct(rs_vand_desc->matrix, data, parity, rs_vand_desc->k, rs_vand_desc->m, missing_idxs, destination_idx, blocksize); return 0; } -static int liberasurecode_rs_vand_min_fragments(void *desc, int *missing_idxs, +static int internal_rs_vand_min_fragments(void *desc, int *missing_idxs, int *fragments_to_exclude, int *fragments_needed) { - struct liberasurecode_rs_vand_descriptor *rs_vand_desc = - (struct liberasurecode_rs_vand_descriptor*)desc; + struct internal_rs_vand_descriptor *rs_vand_desc = + (struct internal_rs_vand_descriptor*)desc; uint64_t exclude_bm = convert_list_to_bitmap(fragments_to_exclude); uint64_t missing_bm = convert_list_to_bitmap(missing_idxs) | exclude_bm; @@ -144,13 +144,13 @@ static int liberasurecode_rs_vand_min_fragments(void *desc, int *missing_idxs, return ret; } -static void * liberasurecode_rs_vand_init(struct ec_backend_args *args, +static void * internal_rs_vand_init(struct ec_backend_args *args, void *backend_sohandle) { - struct liberasurecode_rs_vand_descriptor *desc = NULL; + struct internal_rs_vand_descriptor *desc = NULL; - desc = (struct liberasurecode_rs_vand_descriptor *) - malloc(sizeof(struct liberasurecode_rs_vand_descriptor)); + desc = (struct internal_rs_vand_descriptor *) + malloc(sizeof(struct internal_rs_vand_descriptor)); if (NULL == desc) { return NULL; } @@ -177,9 +177,9 @@ static void * liberasurecode_rs_vand_init(struct ec_backend_args *args, deinit_rs_vand_func deinitp; free_systematic_matrix_func freematrixp; make_systematic_matrix_func makematrixp; - liberasurecode_rs_vand_encode_func encodep; - liberasurecode_rs_vand_decode_func decodep; - liberasurecode_rs_vand_reconstruct_func reconstructp; + internal_rs_vand_encode_func encodep; + internal_rs_vand_decode_func decodep; + internal_rs_vand_reconstruct_func reconstructp; void *vptr; } func_handle = {.vptr = NULL}; @@ -214,23 +214,23 @@ static void * liberasurecode_rs_vand_init(struct ec_backend_args *args, } func_handle.vptr = NULL; - func_handle.vptr = dlsym(backend_sohandle, "liberasurecode_rs_vand_encode"); - desc->liberasurecode_rs_vand_encode = func_handle.encodep; - if (NULL == desc->liberasurecode_rs_vand_encode) { + func_handle.vptr = dlsym(backend_sohandle, "internal_rs_vand_encode"); + desc->internal_rs_vand_encode = func_handle.encodep; + if (NULL == desc->internal_rs_vand_encode) { goto error; } func_handle.vptr = NULL; - func_handle.vptr = dlsym(backend_sohandle, "liberasurecode_rs_vand_decode"); - desc->liberasurecode_rs_vand_decode = func_handle.decodep; - if (NULL == desc->liberasurecode_rs_vand_decode) { + func_handle.vptr = dlsym(backend_sohandle, "internal_rs_vand_decode"); + desc->internal_rs_vand_decode = func_handle.decodep; + if (NULL == desc->internal_rs_vand_decode) { goto error; } func_handle.vptr = NULL; - func_handle.vptr = dlsym(backend_sohandle, "liberasurecode_rs_vand_reconstruct"); - desc->liberasurecode_rs_vand_reconstruct = func_handle.reconstructp; - if (NULL == desc->liberasurecode_rs_vand_reconstruct) { + func_handle.vptr = dlsym(backend_sohandle, "internal_rs_vand_reconstruct"); + desc->internal_rs_vand_reconstruct = func_handle.reconstructp; + if (NULL == desc->internal_rs_vand_reconstruct) { goto error; } @@ -258,20 +258,20 @@ error: * Returns the size in bits! */ static int -liberasurecode_rs_vand_element_size(void* desc) +internal_rs_vand_element_size(void* desc) { - struct liberasurecode_rs_vand_descriptor *rs_vand_desc = NULL; + struct internal_rs_vand_descriptor *rs_vand_desc = NULL; - rs_vand_desc = (struct liberasurecode_rs_vand_descriptor*) desc; + rs_vand_desc = (struct internal_rs_vand_descriptor*) desc; return rs_vand_desc->w; } -static int liberasurecode_rs_vand_exit(void *desc) +static int internal_rs_vand_exit(void *desc) { - struct liberasurecode_rs_vand_descriptor *rs_vand_desc = NULL; + struct internal_rs_vand_descriptor *rs_vand_desc = NULL; - rs_vand_desc = (struct liberasurecode_rs_vand_descriptor*) desc; + rs_vand_desc = (struct internal_rs_vand_descriptor*) desc; rs_vand_desc->free_systematic_matrix(rs_vand_desc->matrix); rs_vand_desc->deinit_rs_vand(); @@ -284,29 +284,29 @@ static int liberasurecode_rs_vand_exit(void *desc) * For the time being, we only claim compatibility with versions that * match exactly */ -static bool liberasurecode_rs_vand_is_compatible_with(uint32_t version) { - return version == backend_liberasurecode_rs_vand.ec_backend_version; +static bool internal_rs_vand_is_compatible_with(uint32_t version) { + return version == backend_internal_rs_vand.ec_backend_version; } -struct ec_backend_op_stubs liberasurecode_rs_vand_op_stubs = { - .INIT = liberasurecode_rs_vand_init, - .EXIT = liberasurecode_rs_vand_exit, - .ENCODE = liberasurecode_rs_vand_encode, - .DECODE = liberasurecode_rs_vand_decode, - .FRAGSNEEDED = liberasurecode_rs_vand_min_fragments, - .RECONSTRUCT = liberasurecode_rs_vand_reconstruct, - .ELEMENTSIZE = liberasurecode_rs_vand_element_size, - .ISCOMPATIBLEWITH = liberasurecode_rs_vand_is_compatible_with, +struct ec_backend_op_stubs internal_rs_vand_op_stubs = { + .INIT = internal_rs_vand_init, + .EXIT = internal_rs_vand_exit, + .ENCODE = internal_rs_vand_encode, + .DECODE = internal_rs_vand_decode, + .FRAGSNEEDED = internal_rs_vand_min_fragments, + .RECONSTRUCT = internal_rs_vand_reconstruct, + .ELEMENTSIZE = internal_rs_vand_element_size, + .ISCOMPATIBLEWITH = internal_rs_vand_is_compatible_with, }; -struct ec_backend_common backend_liberasurecode_rs_vand = { - .id = EC_BACKEND_LIBERASURECODE_RS_VAND, - .name = LIBERASURECODE_RS_VAND_LIB_NAME, - .soname = LIBERASURECODE_RS_VAND_SO_NAME, - .soversion = LIBERASURECODE_RS_VAND_LIB_VER_STR, - .ops = &liberasurecode_rs_vand_op_stubs, +struct ec_backend_common backend_internal_rs_vand = { + .id = EC_BACKEND_INTERNAL_RS_VAND, + .name = INTERNAL_RS_VAND_LIB_NAME, + .soname = INTERNAL_RS_VAND_SO_NAME, + .soversion = INTERNAL_RS_VAND_LIB_VER_STR, + .ops = &internal_rs_vand_op_stubs, .backend_metadata_size = 0, - .ec_backend_version = _VERSION(LIBERASURECODE_RS_VAND_LIB_MAJOR, - LIBERASURECODE_RS_VAND_LIB_MINOR, - LIBERASURECODE_RS_VAND_LIB_REV), + .ec_backend_version = _VERSION(INTERNAL_RS_VAND_LIB_MAJOR, + INTERNAL_RS_VAND_LIB_MINOR, + INTERNAL_RS_VAND_LIB_REV), }; |