Remove trailing whitespaces
We probably want some format tools (like clang-format) in the future, but for now all these spaces are deleted manually. Change-Id: Idcc1cbfa39aecf0d5109488defd89b8a60b786da
This commit is contained in:
parent
cc7de356d6
commit
b260f0963f
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* Copyright 2014 Kevin M Greenan
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -82,12 +82,12 @@ struct jerasure_rs_cauchy_descriptor {
|
|||
|
||||
/* calls required for encode */
|
||||
jerasure_bitmatrix_encode_func jerasure_bitmatrix_encode;
|
||||
|
||||
|
||||
|
||||
|
||||
/* calls required for decode */
|
||||
jerasure_bitmatrix_decode_func jerasure_bitmatrix_decode;
|
||||
|
||||
|
||||
|
||||
|
||||
/* calls required for reconstruct */
|
||||
jerasure_erasures_to_erased_func jerasure_erasures_to_erased;
|
||||
jerasure_make_decoding_bitmatrix_func jerasure_make_decoding_bitmatrix;
|
||||
|
@ -108,7 +108,7 @@ static void free_rs_cauchy_desc(
|
|||
static int jerasure_rs_cauchy_encode(void *desc, char **data, char **parity,
|
||||
int blocksize)
|
||||
{
|
||||
struct jerasure_rs_cauchy_descriptor *jerasure_desc =
|
||||
struct jerasure_rs_cauchy_descriptor *jerasure_desc =
|
||||
(struct jerasure_rs_cauchy_descriptor*) desc;
|
||||
|
||||
/* FIXME - make jerasure_bitmatrix_encode return a value */
|
||||
|
@ -123,19 +123,19 @@ static int jerasure_rs_cauchy_encode(void *desc, char **data, char **parity,
|
|||
static int jerasure_rs_cauchy_decode(void *desc, char **data, char **parity,
|
||||
int *missing_idxs, int blocksize)
|
||||
{
|
||||
struct jerasure_rs_cauchy_descriptor *jerasure_desc =
|
||||
struct jerasure_rs_cauchy_descriptor *jerasure_desc =
|
||||
(struct jerasure_rs_cauchy_descriptor*)desc;
|
||||
|
||||
return jerasure_desc->jerasure_bitmatrix_decode(jerasure_desc->k,
|
||||
jerasure_desc->m,
|
||||
jerasure_desc->w,
|
||||
jerasure_desc->bitmatrix,
|
||||
0,
|
||||
return jerasure_desc->jerasure_bitmatrix_decode(jerasure_desc->k,
|
||||
jerasure_desc->m,
|
||||
jerasure_desc->w,
|
||||
jerasure_desc->bitmatrix,
|
||||
0,
|
||||
missing_idxs,
|
||||
data,
|
||||
parity,
|
||||
blocksize,
|
||||
PYECC_CAUCHY_PACKETSIZE);
|
||||
data,
|
||||
parity,
|
||||
blocksize,
|
||||
PYECC_CAUCHY_PACKETSIZE);
|
||||
}
|
||||
|
||||
static int jerasure_rs_cauchy_reconstruct(void *desc, char **data, char **parity,
|
||||
|
@ -148,7 +148,7 @@ static int jerasure_rs_cauchy_reconstruct(void *desc, char **data, char **parity
|
|||
int *dm_ids = NULL; /* k length list of fragment ids */
|
||||
int *decoding_matrix = NULL; /* matrix for decoding */
|
||||
|
||||
struct jerasure_rs_cauchy_descriptor *jerasure_desc =
|
||||
struct jerasure_rs_cauchy_descriptor *jerasure_desc =
|
||||
(struct jerasure_rs_cauchy_descriptor*) desc;
|
||||
k = jerasure_desc->k;
|
||||
m = jerasure_desc->m;
|
||||
|
@ -162,20 +162,20 @@ static int jerasure_rs_cauchy_reconstruct(void *desc, char **data, char **parity
|
|||
goto out;
|
||||
}
|
||||
|
||||
ret = jerasure_desc->jerasure_make_decoding_bitmatrix(k, m, w,
|
||||
ret = jerasure_desc->jerasure_make_decoding_bitmatrix(k, m, w,
|
||||
jerasure_desc->bitmatrix,
|
||||
erased, decoding_matrix, dm_ids);
|
||||
if (ret == 0) {
|
||||
decoding_row = decoding_matrix + (destination_idx * k * w * w);
|
||||
|
||||
jerasure_desc->jerasure_bitmatrix_dotprod(jerasure_desc->k, jerasure_desc->w,
|
||||
|
||||
jerasure_desc->jerasure_bitmatrix_dotprod(jerasure_desc->k, jerasure_desc->w,
|
||||
decoding_row, dm_ids, destination_idx,
|
||||
data, parity, blocksize, PYECC_CAUCHY_PACKETSIZE);
|
||||
} else {
|
||||
/*
|
||||
* ToDo (KMG) I know this is not needed, but keeping to prevent future
|
||||
* memory leaks, as this function will be better optimized for decoding
|
||||
* missing parity
|
||||
* ToDo (KMG) I know this is not needed, but keeping to prevent future
|
||||
* memory leaks, as this function will be better optimized for decoding
|
||||
* missing parity
|
||||
*/
|
||||
goto out;
|
||||
}
|
||||
|
@ -187,31 +187,31 @@ static int jerasure_rs_cauchy_reconstruct(void *desc, char **data, char **parity
|
|||
* did with ISA-L.
|
||||
*/
|
||||
jerasure_desc->jerasure_bitmatrix_decode(k, m, w,
|
||||
jerasure_desc->bitmatrix,
|
||||
0,
|
||||
jerasure_desc->bitmatrix,
|
||||
0,
|
||||
missing_idxs,
|
||||
data,
|
||||
parity,
|
||||
blocksize,
|
||||
PYECC_CAUCHY_PACKETSIZE);
|
||||
data,
|
||||
parity,
|
||||
blocksize,
|
||||
PYECC_CAUCHY_PACKETSIZE);
|
||||
}
|
||||
|
||||
out:
|
||||
free(erased);
|
||||
free(decoding_matrix);
|
||||
free(dm_ids);
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Caller will allocate an array of size k for fragments_needed
|
||||
*
|
||||
*
|
||||
*/
|
||||
static int jerasure_rs_cauchy_min_fragments(void *desc, int *missing_idxs,
|
||||
int *fragments_to_exclude, int *fragments_needed)
|
||||
{
|
||||
struct jerasure_rs_cauchy_descriptor *jerasure_desc =
|
||||
struct jerasure_rs_cauchy_descriptor *jerasure_desc =
|
||||
(struct jerasure_rs_cauchy_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;
|
||||
|
@ -240,7 +240,7 @@ static void * jerasure_rs_cauchy_init(struct ec_backend_args *args,
|
|||
{
|
||||
struct jerasure_rs_cauchy_descriptor *desc = NULL;
|
||||
int k, m, w;
|
||||
|
||||
|
||||
desc = (struct jerasure_rs_cauchy_descriptor *)
|
||||
malloc(sizeof(struct jerasure_rs_cauchy_descriptor));
|
||||
if (NULL == desc) {
|
||||
|
@ -280,68 +280,68 @@ static void * jerasure_rs_cauchy_init(struct ec_backend_args *args,
|
|||
galois_uninit_field_func uninitp;
|
||||
jerasure_bitmatrix_encode_func encodep;
|
||||
jerasure_bitmatrix_decode_func decodep;
|
||||
jerasure_erasures_to_erased_func erasedp;
|
||||
jerasure_erasures_to_erased_func erasedp;
|
||||
jerasure_make_decoding_bitmatrix_func decodematrixp;
|
||||
jerasure_bitmatrix_dotprod_func dotprodp;
|
||||
void *vptr;
|
||||
} func_handle = {.vptr = NULL};
|
||||
|
||||
|
||||
/* fill in function addresses */
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "jerasure_bitmatrix_encode");
|
||||
desc->jerasure_bitmatrix_encode = func_handle.encodep;
|
||||
if (NULL == desc->jerasure_bitmatrix_encode) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "jerasure_bitmatrix_decode");
|
||||
desc->jerasure_bitmatrix_decode = func_handle.decodep;
|
||||
if (NULL == desc->jerasure_bitmatrix_decode) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "cauchy_original_coding_matrix");
|
||||
desc->cauchy_original_coding_matrix = func_handle.initp;
|
||||
if (NULL == desc->cauchy_original_coding_matrix) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "jerasure_matrix_to_bitmatrix");
|
||||
desc->jerasure_matrix_to_bitmatrix = func_handle.matrixtobitmatrixp;
|
||||
if (NULL == desc->jerasure_matrix_to_bitmatrix) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "jerasure_smart_bitmatrix_to_schedule");
|
||||
desc->jerasure_smart_bitmatrix_to_schedule = func_handle.matrixschedulep;
|
||||
if (NULL == desc->jerasure_smart_bitmatrix_to_schedule) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "jerasure_make_decoding_bitmatrix");
|
||||
desc->jerasure_make_decoding_bitmatrix = func_handle.decodematrixp;
|
||||
if (NULL == desc->jerasure_make_decoding_bitmatrix) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "jerasure_bitmatrix_dotprod");
|
||||
desc->jerasure_bitmatrix_dotprod = func_handle.dotprodp;
|
||||
if (NULL == desc->jerasure_bitmatrix_dotprod) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "jerasure_erasures_to_erased");
|
||||
desc->jerasure_erasures_to_erased = func_handle.erasedp;
|
||||
if (NULL == desc->jerasure_erasures_to_erased) {
|
||||
goto error;
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "galois_uninit_field");
|
||||
|
@ -376,15 +376,15 @@ error:
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the element-size, which is the number of bits stored
|
||||
* on a given device, per codeword.
|
||||
*
|
||||
* Return the element-size, which is the number of bits stored
|
||||
* on a given device, per codeword.
|
||||
*
|
||||
* Returns the size in bits!
|
||||
*/
|
||||
static int
|
||||
jerasure_rs_cauchy_element_size(void* desc)
|
||||
{
|
||||
struct jerasure_rs_cauchy_descriptor *jerasure_desc =
|
||||
struct jerasure_rs_cauchy_descriptor *jerasure_desc =
|
||||
(struct jerasure_rs_cauchy_descriptor*)desc;
|
||||
|
||||
return jerasure_desc->w * PYECC_CAUCHY_PACKETSIZE * 8;
|
||||
|
@ -417,7 +417,7 @@ static void free_rs_cauchy_desc(
|
|||
// the schedule array, it appears that the sentinal used to signal the end
|
||||
// of the array is a value of -1 in the first int field in the dereferenced
|
||||
// value. We use this determine when to stop free-ing elements. See the
|
||||
// jerasure_smart_bitmatrix_to_schedule and
|
||||
// jerasure_smart_bitmatrix_to_schedule and
|
||||
// jerasure_dumb_bitmatrix_to_schedule functions in jerasure.c for the
|
||||
// details.
|
||||
schedule = jerasure_desc->schedule;
|
||||
|
@ -437,7 +437,7 @@ static void free_rs_cauchy_desc(
|
|||
|
||||
static int jerasure_rs_cauchy_exit(void *desc)
|
||||
{
|
||||
struct jerasure_rs_cauchy_descriptor *jerasure_desc =
|
||||
struct jerasure_rs_cauchy_descriptor *jerasure_desc =
|
||||
(struct jerasure_rs_cauchy_descriptor*)desc;
|
||||
free_rs_cauchy_desc(jerasure_desc);
|
||||
return 0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* Copyright 2014 Kevin M Greenan
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -51,7 +51,7 @@ struct ec_backend jerasure_rs_vand;
|
|||
struct ec_backend_common backend_jerasure_rs_vand;
|
||||
|
||||
typedef int* (*reed_sol_vandermonde_coding_matrix_func)(int, int, int);
|
||||
typedef void (*jerasure_matrix_encode_func)(int, int, int, int*, char **, char **, int);
|
||||
typedef void (*jerasure_matrix_encode_func)(int, int, int, int*, char **, char **, int);
|
||||
typedef int (*jerasure_matrix_decode_func)(int, int, int, int *, int, int*, char **, char **, int);
|
||||
typedef int (*jerasure_make_decoding_matrix_func)(int, int, int, int *, int *, int *, int *);
|
||||
typedef int * (*jerasure_erasures_to_erased_func)(int, int, int *);
|
||||
|
@ -67,10 +67,10 @@ struct jerasure_rs_vand_descriptor {
|
|||
|
||||
/* calls required for encode */
|
||||
jerasure_matrix_encode_func jerasure_matrix_encode;
|
||||
|
||||
|
||||
/* calls required for decode */
|
||||
jerasure_matrix_decode_func jerasure_matrix_decode;
|
||||
|
||||
|
||||
/* calls required for reconstruct */
|
||||
jerasure_make_decoding_matrix_func jerasure_make_decoding_matrix;
|
||||
jerasure_erasures_to_erased_func jerasure_erasures_to_erased;
|
||||
|
@ -86,7 +86,7 @@ struct jerasure_rs_vand_descriptor {
|
|||
static int jerasure_rs_vand_encode(void *desc, char **data, char **parity,
|
||||
int blocksize)
|
||||
{
|
||||
struct jerasure_rs_vand_descriptor *jerasure_desc =
|
||||
struct jerasure_rs_vand_descriptor *jerasure_desc =
|
||||
(struct jerasure_rs_vand_descriptor*) desc;
|
||||
|
||||
/* FIXME - make jerasure_matrix_encode return a value */
|
||||
|
@ -99,7 +99,7 @@ static int jerasure_rs_vand_encode(void *desc, char **data, char **parity,
|
|||
static int jerasure_rs_vand_decode(void *desc, char **data, char **parity,
|
||||
int *missing_idxs, int blocksize)
|
||||
{
|
||||
struct jerasure_rs_vand_descriptor *jerasure_desc =
|
||||
struct jerasure_rs_vand_descriptor *jerasure_desc =
|
||||
(struct jerasure_rs_vand_descriptor*)desc;
|
||||
|
||||
/* FIXME - make jerasure_matrix_decode return a value */
|
||||
|
@ -119,9 +119,9 @@ static int jerasure_rs_vand_reconstruct(void *desc, char **data, char **parity,
|
|||
int *dm_ids = NULL; /* k length list of frag ids */
|
||||
int *decoding_matrix = NULL; /* matrix for decoding */
|
||||
|
||||
struct jerasure_rs_vand_descriptor *jerasure_desc =
|
||||
struct jerasure_rs_vand_descriptor *jerasure_desc =
|
||||
(struct jerasure_rs_vand_descriptor*) desc;
|
||||
|
||||
|
||||
if (destination_idx < jerasure_desc->k) {
|
||||
dm_ids = (int *) alloc_zeroed_buffer(sizeof(int) * jerasure_desc->k);
|
||||
decoding_matrix = (int *)
|
||||
|
@ -137,16 +137,16 @@ static int jerasure_rs_vand_reconstruct(void *desc, char **data, char **parity,
|
|||
erased, decoding_matrix, dm_ids);
|
||||
|
||||
decoding_row = decoding_matrix + (destination_idx * jerasure_desc->k);
|
||||
|
||||
|
||||
if (ret == 0) {
|
||||
jerasure_desc->jerasure_matrix_dotprod(jerasure_desc->k,
|
||||
jerasure_desc->w, decoding_row, dm_ids, destination_idx,
|
||||
data, parity, blocksize);
|
||||
} else {
|
||||
/*
|
||||
* ToDo (KMG) I know this is not needed, but keeping to prevent future
|
||||
* memory leaks, as this function will be better optimized for decoding
|
||||
* missing parity
|
||||
* ToDo (KMG) I know this is not needed, but keeping to prevent future
|
||||
* memory leaks, as this function will be better optimized for decoding
|
||||
* missing parity
|
||||
*/
|
||||
goto out;
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ parity_reconstr_out:
|
|||
static int jerasure_rs_vand_min_fragments(void *desc, int *missing_idxs,
|
||||
int *fragments_to_exclude, int *fragments_needed)
|
||||
{
|
||||
struct jerasure_rs_vand_descriptor *jerasure_desc =
|
||||
struct jerasure_rs_vand_descriptor *jerasure_desc =
|
||||
(struct jerasure_rs_vand_descriptor*)desc;
|
||||
|
||||
uint64_t exclude_bm = convert_list_to_bitmap(fragments_to_exclude);
|
||||
|
@ -204,7 +204,7 @@ static void * jerasure_rs_vand_init(struct ec_backend_args *args,
|
|||
void *backend_sohandle)
|
||||
{
|
||||
struct jerasure_rs_vand_descriptor *desc = NULL;
|
||||
|
||||
|
||||
desc = (struct jerasure_rs_vand_descriptor *)
|
||||
malloc(sizeof(struct jerasure_rs_vand_descriptor));
|
||||
if (NULL == desc) {
|
||||
|
@ -254,42 +254,42 @@ static void * jerasure_rs_vand_init(struct ec_backend_args *args,
|
|||
func_handle.vptr = dlsym(backend_sohandle, "jerasure_matrix_encode");
|
||||
desc->jerasure_matrix_encode = func_handle.encodep;
|
||||
if (NULL == desc->jerasure_matrix_encode) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "jerasure_matrix_decode");
|
||||
desc->jerasure_matrix_decode = func_handle.decodep;
|
||||
if (NULL == desc->jerasure_matrix_decode) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "jerasure_make_decoding_matrix");
|
||||
desc->jerasure_make_decoding_matrix = func_handle.decodematrixp;
|
||||
if (NULL == desc->jerasure_make_decoding_matrix) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "jerasure_matrix_dotprod");
|
||||
desc->jerasure_matrix_dotprod = func_handle.dotprodp;
|
||||
if (NULL == desc->jerasure_matrix_dotprod) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "jerasure_erasures_to_erased");
|
||||
desc->jerasure_erasures_to_erased = func_handle.erasep;
|
||||
if (NULL == desc->jerasure_erasures_to_erased) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "reed_sol_vandermonde_coding_matrix");
|
||||
desc->reed_sol_vandermonde_coding_matrix = func_handle.initp;
|
||||
if (NULL == desc->reed_sol_vandermonde_coding_matrix) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
|
@ -302,28 +302,28 @@ static void * jerasure_rs_vand_init(struct ec_backend_args *args,
|
|||
desc->matrix = desc->reed_sol_vandermonde_coding_matrix(
|
||||
desc->k, desc->m, desc->w);
|
||||
if (NULL == desc->matrix) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
return desc;
|
||||
|
||||
error:
|
||||
free(desc);
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the element-size, which is the number of bits stored
|
||||
* on a given device, per codeword. For Vandermonde, this is
|
||||
* 'w'. For somthing like cauchy, this is packetsize * w.
|
||||
*
|
||||
* Return the element-size, which is the number of bits stored
|
||||
* on a given device, per codeword. For Vandermonde, this is
|
||||
* 'w'. For somthing like cauchy, this is packetsize * w.
|
||||
*
|
||||
* Returns the size in bits!
|
||||
*/
|
||||
static int
|
||||
jerasure_rs_vand_element_size(void* desc)
|
||||
{
|
||||
struct jerasure_rs_vand_descriptor *jerasure_desc =
|
||||
struct jerasure_rs_vand_descriptor *jerasure_desc =
|
||||
(struct jerasure_rs_vand_descriptor*)desc;
|
||||
|
||||
/* Note that cauchy will return pyeclib_handle->w * PYECC_CAUCHY_PACKETSIZE * 8 */
|
||||
|
@ -333,7 +333,7 @@ jerasure_rs_vand_element_size(void* desc)
|
|||
static int jerasure_rs_vand_exit(void *desc)
|
||||
{
|
||||
struct jerasure_rs_vand_descriptor *jerasure_desc = NULL;
|
||||
|
||||
|
||||
jerasure_desc = (struct jerasure_rs_vand_descriptor*) desc;
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* Copyright 2014 Tushar Gohad
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -100,7 +100,7 @@ static int null_min_fragments(void *desc, int *missing_idxs,
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the element-size, which is the number of bits stored
|
||||
* Return the element-size, which is the number of bits stored
|
||||
* on a given device, per codeword. This is usually just 'w'.
|
||||
*/
|
||||
static int
|
||||
|
@ -164,35 +164,35 @@ static void * null_init(struct ec_backend_args *args, void *backend_sohandle)
|
|||
func_handle.vptr = dlsym(backend_sohandle, "null_code_init");
|
||||
xdesc->init_null_code = func_handle.initp;
|
||||
if (NULL == xdesc->init_null_code) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "null_code_encode");
|
||||
xdesc->null_code_encode = func_handle.encodep;
|
||||
if (NULL == xdesc->null_code_encode) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "null_code_decode");
|
||||
xdesc->null_code_decode = func_handle.decodep;
|
||||
if (NULL == xdesc->null_code_decode) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "null_reconstruct");
|
||||
xdesc->null_reconstruct = func_handle.reconp;
|
||||
if (NULL == xdesc->null_reconstruct) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "null_code_fragments_needed");
|
||||
xdesc->null_code_fragments_needed = func_handle.fragsneededp;
|
||||
if (NULL == xdesc->null_code_fragments_needed) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
return (void *) xdesc;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* Copyright 2015 Kevin M Greenan
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -59,17 +59,17 @@ typedef int* (*make_systematic_matrix_func)(int, int);
|
|||
|
||||
struct liberasurecode_rs_vand_descriptor {
|
||||
/* calls required for init */
|
||||
init_liberasurecode_rs_vand_func init_liberasurecode_rs_vand;
|
||||
init_liberasurecode_rs_vand_func init_liberasurecode_rs_vand;
|
||||
deinit_liberasurecode_rs_vand_func deinit_liberasurecode_rs_vand;
|
||||
free_systematic_matrix_func free_systematic_matrix;
|
||||
make_systematic_matrix_func make_systematic_matrix;
|
||||
|
||||
|
||||
/* calls required for encode */
|
||||
liberasurecode_rs_vand_encode_func liberasurecode_rs_vand_encode;
|
||||
|
||||
|
||||
/* calls required for decode */
|
||||
liberasurecode_rs_vand_decode_func liberasurecode_rs_vand_decode;
|
||||
|
||||
liberasurecode_rs_vand_decode_func liberasurecode_rs_vand_decode;
|
||||
|
||||
/* calls required for reconstruct */
|
||||
liberasurecode_rs_vand_reconstruct_func liberasurecode_rs_vand_reconstruct;
|
||||
|
||||
|
@ -83,7 +83,7 @@ struct liberasurecode_rs_vand_descriptor {
|
|||
static int liberasurecode_rs_vand_encode(void *desc, char **data, char **parity,
|
||||
int blocksize)
|
||||
{
|
||||
struct liberasurecode_rs_vand_descriptor *rs_vand_desc =
|
||||
struct liberasurecode_rs_vand_descriptor *rs_vand_desc =
|
||||
(struct liberasurecode_rs_vand_descriptor*) desc;
|
||||
|
||||
/* FIXME: Should this return something? */
|
||||
|
@ -95,11 +95,11 @@ static int liberasurecode_rs_vand_encode(void *desc, char **data, char **parity,
|
|||
static int liberasurecode_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 *rs_vand_desc =
|
||||
(struct liberasurecode_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->liberasurecode_rs_vand_decode(rs_vand_desc->matrix, data, parity,
|
||||
rs_vand_desc->k, rs_vand_desc->m, missing_idxs, blocksize, 1);
|
||||
|
||||
return 0;
|
||||
|
@ -108,11 +108,11 @@ static int liberasurecode_rs_vand_decode(void *desc, char **data, char **parity,
|
|||
static int liberasurecode_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 *rs_vand_desc =
|
||||
(struct liberasurecode_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->liberasurecode_rs_vand_reconstruct(rs_vand_desc->matrix, data, parity,
|
||||
rs_vand_desc->k, rs_vand_desc->m, missing_idxs, destination_idx, blocksize);
|
||||
|
||||
return 0;
|
||||
|
@ -121,7 +121,7 @@ static int liberasurecode_rs_vand_reconstruct(void *desc, char **data, char **pa
|
|||
static int liberasurecode_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 *rs_vand_desc =
|
||||
(struct liberasurecode_rs_vand_descriptor*)desc;
|
||||
|
||||
uint64_t exclude_bm = convert_list_to_bitmap(fragments_to_exclude);
|
||||
|
@ -149,7 +149,7 @@ static void * liberasurecode_rs_vand_init(struct ec_backend_args *args,
|
|||
void *backend_sohandle)
|
||||
{
|
||||
struct liberasurecode_rs_vand_descriptor *desc = NULL;
|
||||
|
||||
|
||||
desc = (struct liberasurecode_rs_vand_descriptor *)
|
||||
malloc(sizeof(struct liberasurecode_rs_vand_descriptor));
|
||||
if (NULL == desc) {
|
||||
|
@ -190,79 +190,79 @@ static void * liberasurecode_rs_vand_init(struct ec_backend_args *args,
|
|||
func_handle.vptr = dlsym(backend_sohandle, "init_liberasurecode_rs_vand");
|
||||
desc->init_liberasurecode_rs_vand = func_handle.initp;
|
||||
if (NULL == desc->init_liberasurecode_rs_vand) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "deinit_liberasurecode_rs_vand");
|
||||
desc->deinit_liberasurecode_rs_vand = func_handle.deinitp;
|
||||
if (NULL == desc->deinit_liberasurecode_rs_vand) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "make_systematic_matrix");
|
||||
desc->make_systematic_matrix = func_handle.makematrixp;
|
||||
if (NULL == desc->make_systematic_matrix) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
func_handle.vptr = NULL;
|
||||
func_handle.vptr = dlsym(backend_sohandle, "free_systematic_matrix");
|
||||
desc->free_systematic_matrix = func_handle.freematrixp;
|
||||
if (NULL == desc->free_systematic_matrix) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
goto error;
|
||||
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) {
|
||||
goto error;
|
||||
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) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
desc->init_liberasurecode_rs_vand(desc->k, desc->m);
|
||||
|
||||
desc->matrix = desc->make_systematic_matrix(desc->k, desc->m);
|
||||
|
||||
|
||||
if (NULL == desc->matrix) {
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
|
||||
return desc;
|
||||
|
||||
error:
|
||||
free(desc);
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the element-size, which is the number of bits stored
|
||||
* on a given device, per codeword. For Vandermonde, this is
|
||||
* 'w'. For somthing like cauchy, this is packetsize * w.
|
||||
*
|
||||
* Return the element-size, which is the number of bits stored
|
||||
* on a given device, per codeword. For Vandermonde, this is
|
||||
* 'w'. For somthing like cauchy, this is packetsize * w.
|
||||
*
|
||||
* Returns the size in bits!
|
||||
*/
|
||||
static int
|
||||
liberasurecode_rs_vand_element_size(void* desc)
|
||||
{
|
||||
struct liberasurecode_rs_vand_descriptor *rs_vand_desc = NULL;
|
||||
|
||||
|
||||
rs_vand_desc = (struct liberasurecode_rs_vand_descriptor*) desc;
|
||||
|
||||
return rs_vand_desc->w;
|
||||
|
@ -271,7 +271,7 @@ liberasurecode_rs_vand_element_size(void* desc)
|
|||
static int liberasurecode_rs_vand_exit(void *desc)
|
||||
{
|
||||
struct liberasurecode_rs_vand_descriptor *rs_vand_desc = NULL;
|
||||
|
||||
|
||||
rs_vand_desc = (struct liberasurecode_rs_vand_descriptor*) desc;
|
||||
|
||||
rs_vand_desc->free_systematic_matrix(rs_vand_desc->matrix);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* Copyright 2014 Tushar Gohad
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -93,13 +93,13 @@ static int flat_xor_hd_reconstruct(void *desc,
|
|||
(struct flat_xor_hd_descriptor *) desc;
|
||||
|
||||
xor_code_t *xor_desc = (xor_code_t *) xdesc->xor_desc;
|
||||
xor_reconstruct_one(xor_desc, data, parity,
|
||||
xor_reconstruct_one(xor_desc, data, parity,
|
||||
missing_idxs, destination_idx, blocksize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int flat_xor_hd_min_fragments(void *desc,
|
||||
int *missing_idxs, int *fragments_to_exclude,
|
||||
int *missing_idxs, int *fragments_to_exclude,
|
||||
int *fragments_needed)
|
||||
{
|
||||
struct flat_xor_hd_descriptor *xdesc =
|
||||
|
@ -111,7 +111,7 @@ static int flat_xor_hd_min_fragments(void *desc,
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the element-size, which is the number of bits stored
|
||||
* Return the element-size, which is the number of bits stored
|
||||
* on a given device, per codeword. This is usually just 'w'.
|
||||
*/
|
||||
static int
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* <Copyright>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* Copyright 2015 Kevin M Greenan
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -58,7 +58,7 @@ void print_matrix(int *matrix, int rows, int cols)
|
|||
void square_matrix_multiply(int *m1, int *m2, int *prod, int n)
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
for (j = 0; j < n; j++) {
|
||||
int p = 0;
|
||||
|
@ -124,8 +124,8 @@ int create_decoding_matrix(int *gen_matrix, int *dec_matrix, int *missing_idxs,
|
|||
for (i = 0, j = 0; i < n && j < k; i++) {
|
||||
if (!is_missing(missing_idxs, i)) {
|
||||
copy_row(gen_matrix, dec_matrix, i, j, k);
|
||||
j++;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
return j == k;
|
||||
|
@ -149,7 +149,7 @@ int * create_non_systematic_vand_matrix(int k, int m)
|
|||
int i, j, acc;
|
||||
int *matrix = (int*)malloc(sizeof(int)*rows*cols);
|
||||
|
||||
if (NULL == matrix) return NULL;
|
||||
if (NULL == matrix) return NULL;
|
||||
|
||||
// First row is 1, 0, 0, ..., 0
|
||||
matrix[0] = 1;
|
||||
|
@ -177,14 +177,14 @@ void swap_matrix_rows(int *r1, int *r2, int num_cols)
|
|||
for (i = 0; i < num_cols; i++) {
|
||||
tmp = r1[i];
|
||||
r1[i] = r2[i];
|
||||
r2[i] = tmp;
|
||||
r2[i] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void col_mult(int *matrix, int elem, int col_idx, int num_rows, int num_cols)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < num_rows; i++) {
|
||||
matrix[col_idx] = rs_galois_mult(matrix[col_idx], elem);
|
||||
col_idx += num_cols;
|
||||
|
@ -204,7 +204,7 @@ void row_mult(int *matrix, int elem, int row_idx, int num_rows, int num_cols)
|
|||
void col_mult_and_add(int *matrix, int elem, int from_col, int to_col, int num_rows, int num_cols)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < num_rows; i++) {
|
||||
matrix[to_col] = matrix[to_col] ^ rs_galois_mult(matrix[from_col], elem);
|
||||
from_col += num_cols;
|
||||
|
@ -218,7 +218,7 @@ void row_mult_and_add(int *matrix, int elem, int from_row, int to_row, int num_r
|
|||
from_row = from_row * num_cols;
|
||||
to_row = to_row * num_cols;
|
||||
for (i = 0; i < num_cols; i++) {
|
||||
matrix[to_row] = matrix[to_row] ^ rs_galois_mult(matrix[from_row], elem);
|
||||
matrix[to_row] = matrix[to_row] ^ rs_galois_mult(matrix[from_row], elem);
|
||||
to_row++;
|
||||
from_row++;
|
||||
}
|
||||
|
@ -227,12 +227,12 @@ void row_mult_and_add(int *matrix, int elem, int from_row, int to_row, int num_r
|
|||
int get_non_zero_diagonal(int *matrix, int row, int num_rows, int num_cols)
|
||||
{
|
||||
int i, row_idx;
|
||||
|
||||
|
||||
row_idx = (num_cols * row) + row;
|
||||
for (i = row; i < num_rows; i++) {
|
||||
if (matrix[row_idx] != 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
row_idx += num_cols;
|
||||
}
|
||||
|
||||
|
@ -243,23 +243,23 @@ int * make_systematic_matrix(int k, int m)
|
|||
{
|
||||
int rows = k + m;
|
||||
int cols = k;
|
||||
int i, j;
|
||||
int i, j;
|
||||
int *matrix = create_non_systematic_vand_matrix(k, m);
|
||||
|
||||
if (NULL == matrix) return NULL;
|
||||
if (NULL == matrix) return NULL;
|
||||
|
||||
// The first row is already 1, 0, 0, ..., 0
|
||||
for (i = 1; i < cols; i++) {
|
||||
int diag_idx = ((cols*i) + i);
|
||||
// Get next row candidate, whose diagonal entry @ i,i != 0
|
||||
int next_row = get_non_zero_diagonal(matrix, i, rows, cols);
|
||||
|
||||
|
||||
// Swap candidate row with row i, if needed
|
||||
if (next_row != i) {
|
||||
swap_matrix_rows(&matrix[next_row*cols], &matrix[i*cols], cols);
|
||||
}
|
||||
|
||||
// Ensure the leading entry of row i is 1 by multiplying the
|
||||
// Ensure the leading entry of row i is 1 by multiplying the
|
||||
// column by the inverse of matrix[diag_idx]
|
||||
if (matrix[diag_idx] != 1) {
|
||||
col_mult(matrix, rs_galois_inverse(matrix[diag_idx]), i, rows, cols);
|
||||
|
@ -280,7 +280,7 @@ int * make_systematic_matrix(int k, int m)
|
|||
int row_val = matrix[(cols * cols) + i];
|
||||
if (row_val != 1) {
|
||||
// Multiply the parity sub-column by the inverse of row_val
|
||||
// We then implicitly multuply row i by the inverse of row_val
|
||||
// We then implicitly multuply row i by the inverse of row_val
|
||||
// (not explicitly necessary, since all other entries are 0)
|
||||
col_mult(&matrix[cols*cols], rs_galois_inverse(row_val), i, rows - cols, cols);
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ int gaussj_inversion(int *matrix, int *inverse, int n)
|
|||
int diag_idx = ((n*i) + i);
|
||||
// Get next row candidate, whose diagonal entry @ i,i != 0
|
||||
int next_row = get_non_zero_diagonal(matrix, i, n, n);
|
||||
|
||||
|
||||
// Swap candidate row with row i, if needed
|
||||
if (next_row != i) {
|
||||
swap_matrix_rows(&matrix[next_row*n], &matrix[i*n], n);
|
||||
|
@ -324,7 +324,7 @@ int gaussj_inversion(int *matrix, int *inverse, int n)
|
|||
row_mult(matrix, leading_val_inv, i, n, n);
|
||||
row_mult(inverse, leading_val_inv, i, n, n);
|
||||
}
|
||||
|
||||
|
||||
// Zero-out all other entries in column i
|
||||
for (j = 0; j < n; j++) {
|
||||
if (i != j) {
|
||||
|
@ -340,7 +340,7 @@ int gaussj_inversion(int *matrix, int *inverse, int n)
|
|||
void region_xor(char *from_buf, char *to_buf, int blocksize)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
uint32_t *_from_buf = (uint32_t*)from_buf;
|
||||
uint32_t *_to_buf = (uint32_t*)to_buf;
|
||||
int adj_blocksize = blocksize / 4;
|
||||
|
@ -349,7 +349,7 @@ void region_xor(char *from_buf, char *to_buf, int blocksize)
|
|||
for (i = 0; i < adj_blocksize; i++) {
|
||||
_to_buf[i] = _to_buf[i] ^ _from_buf[i];
|
||||
}
|
||||
|
||||
|
||||
for (i = blocksize-trailing_bytes; i < blocksize; i++) {
|
||||
to_buf[i] = to_buf[i] ^ from_buf[i];
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ void region_multiply(char *from_buf, char *to_buf, int mult, int xor, int blocks
|
|||
for (i = 0; i < adj_blocksize; i++) {
|
||||
_to_buf[i] = _to_buf[i] ^ (uint16_t)rs_galois_mult(_from_buf[i], mult);
|
||||
}
|
||||
|
||||
|
||||
if (trailing_bytes == 1) {
|
||||
i = blocksize - 1;
|
||||
to_buf[i] = to_buf[i] ^ (char)rs_galois_mult(from_buf[i], mult);
|
||||
|
@ -376,7 +376,7 @@ void region_multiply(char *from_buf, char *to_buf, int mult, int xor, int blocks
|
|||
for (i = 0; i < adj_blocksize; i++) {
|
||||
_to_buf[i] = (uint16_t)rs_galois_mult(_from_buf[i], mult);
|
||||
}
|
||||
|
||||
|
||||
if (trailing_bytes == 1) {
|
||||
i = blocksize - 1;
|
||||
to_buf[i] = (char)rs_galois_mult(from_buf[i], mult);
|
||||
|
@ -387,7 +387,7 @@ void region_multiply(char *from_buf, char *to_buf, int mult, int xor, int blocks
|
|||
void region_dot_product(char **from_bufs, char *to_buf, int *matrix_row, int num_entries, int blocksize)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < num_entries; i++) {
|
||||
int mult = matrix_row[i];
|
||||
if (mult == 1) {
|
||||
|
@ -402,11 +402,11 @@ int liberasurecode_rs_vand_encode(int *generator_matrix, char **data, char **par
|
|||
{
|
||||
int i;
|
||||
int n = k + m;
|
||||
|
||||
|
||||
for (i = k; i < n; i++) {
|
||||
memset(parity[i - k], 0, blocksize);
|
||||
region_dot_product(data, parity[i - k], &generator_matrix[(i * k)], k, blocksize);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ char **get_first_k_available(char **data, char **parity, int *missing, int k)
|
|||
{
|
||||
int i, j;
|
||||
char **first_k_available = (char**)malloc(sizeof(char*)*k);
|
||||
|
||||
|
||||
for (i = 0, j = 0; j < k; i++) {
|
||||
if (!missing[i]) {
|
||||
first_k_available[j] = i < k ? data[i] : parity[i - k];
|
||||
|
@ -450,7 +450,7 @@ int liberasurecode_rs_vand_decode(int *generator_matrix, char **data, char **par
|
|||
decoding_matrix = (int*)malloc(sizeof(int)*k*k);
|
||||
inverse_decoding_matrix = (int*)malloc(sizeof(int)*k*k);
|
||||
first_k_available = get_first_k_available(data, parity, _missing, k);
|
||||
|
||||
|
||||
create_decoding_matrix(generator_matrix, decoding_matrix, missing, k, m);
|
||||
gaussj_inversion(decoding_matrix, inverse_decoding_matrix, k);
|
||||
|
||||
|
@ -461,7 +461,7 @@ int liberasurecode_rs_vand_decode(int *generator_matrix, char **data, char **par
|
|||
region_dot_product(first_k_available, data[i], &inverse_decoding_matrix[(i * k)], k, blocksize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Rebuild parity fragments
|
||||
if (rebuild_parity) {
|
||||
for (i = k; i < n; i++) {
|
||||
|
@ -471,7 +471,7 @@ int liberasurecode_rs_vand_decode(int *generator_matrix, char **data, char **par
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free(decoding_matrix);
|
||||
free(inverse_decoding_matrix);
|
||||
free(first_k_available);
|
||||
|
@ -506,7 +506,7 @@ int liberasurecode_rs_vand_reconstruct(int *generator_matrix, char **data, char
|
|||
decoding_matrix = (int*)malloc(sizeof(int)*k*k);
|
||||
inverse_decoding_matrix = (int*)malloc(sizeof(int)*k*k);
|
||||
first_k_available = get_first_k_available(data, parity, _missing, k);
|
||||
|
||||
|
||||
create_decoding_matrix(generator_matrix, decoding_matrix, missing, k, m);
|
||||
gaussj_inversion(decoding_matrix, inverse_decoding_matrix, k);
|
||||
|
||||
|
@ -527,7 +527,7 @@ int liberasurecode_rs_vand_reconstruct(int *generator_matrix, char **data, char
|
|||
if (!_missing[i]) {
|
||||
parity_row[j] = generator_matrix[(destination_idx * k) + i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* Copyright 2015 Kevin M Greenan
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -59,7 +59,7 @@ void rs_galois_init_tables()
|
|||
ilog_table_begin[i + (GROUP_SIZE*2)] = x;
|
||||
x = x << 1;
|
||||
if (x & FIELD_SIZE) {
|
||||
x ^= PRIM_POLY;
|
||||
x ^= PRIM_POLY;
|
||||
}
|
||||
}
|
||||
ilog_table = &ilog_table_begin[GROUP_SIZE];
|
||||
|
@ -87,7 +87,7 @@ int rs_galois_div(int x, int y)
|
|||
int diff;
|
||||
if (x == 0) return 0;
|
||||
if (y == 0) return -1;
|
||||
|
||||
|
||||
// This can 'underflow'. This is handled
|
||||
// by negative overflow of ilog_table
|
||||
diff = log_table[x] - log_table[y];
|
||||
|
|
|
@ -68,7 +68,7 @@ int missing_elements_bm(xor_code_t *code_desc, int *missing_elements, int (*bit_
|
|||
while (missing_elements[i] > -1) {
|
||||
bm |= bit_lookup_func(code_desc, missing_elements[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return bm;
|
||||
}
|
||||
|
@ -94,16 +94,16 @@ failure_pattern_t get_failure_pattern(xor_code_t *code_desc, int *missing_idxs)
|
|||
pattern = (missing_idxs[i] < code_desc->k) ? FAIL_PATTERN_3D_0P : FAIL_PATTERN_2D_1P;
|
||||
break;
|
||||
case FAIL_PATTERN_3D_0P:
|
||||
pattern = FAIL_PATTERN_GE_HD;
|
||||
pattern = FAIL_PATTERN_GE_HD;
|
||||
break;
|
||||
case FAIL_PATTERN_1D_1P:
|
||||
pattern = (missing_idxs[i] < code_desc->k) ? FAIL_PATTERN_2D_1P : FAIL_PATTERN_1D_2P;
|
||||
break;
|
||||
case FAIL_PATTERN_1D_2P:
|
||||
pattern = FAIL_PATTERN_GE_HD;
|
||||
pattern = FAIL_PATTERN_GE_HD;
|
||||
break;
|
||||
case FAIL_PATTERN_2D_1P:
|
||||
pattern = FAIL_PATTERN_GE_HD;
|
||||
pattern = FAIL_PATTERN_GE_HD;
|
||||
break;
|
||||
case FAIL_PATTERN_0D_1P:
|
||||
pattern = (missing_idxs[i] < code_desc->k) ? FAIL_PATTERN_1D_1P : FAIL_PATTERN_0D_2P;
|
||||
|
@ -112,19 +112,19 @@ failure_pattern_t get_failure_pattern(xor_code_t *code_desc, int *missing_idxs)
|
|||
pattern = (missing_idxs[i] < code_desc->k) ? FAIL_PATTERN_1D_2P : FAIL_PATTERN_0D_3P;
|
||||
break;
|
||||
case FAIL_PATTERN_0D_3P:
|
||||
pattern = FAIL_PATTERN_GE_HD;
|
||||
pattern = FAIL_PATTERN_GE_HD;
|
||||
break;
|
||||
case FAIL_PATTERN_GE_HD:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pattern == FAIL_PATTERN_GE_HD) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return pattern;
|
||||
return pattern;
|
||||
}
|
||||
|
||||
void fast_memcpy(char *dst, char *src, int size)
|
||||
|
@ -145,8 +145,8 @@ void xor_bufs_and_store(char *buf1, char *buf2, int blocksize)
|
|||
int fast_blocksize = blocksize > residual_bytes ? (blocksize - residual_bytes) : 0;
|
||||
int fast_int_blocksize = fast_blocksize / sizeof(__m128i);
|
||||
int i;
|
||||
__m128i *_buf1 = (__m128i*)buf1;
|
||||
__m128i *_buf2 = (__m128i*)buf2;
|
||||
__m128i *_buf1 = (__m128i*)buf1;
|
||||
__m128i *_buf2 = (__m128i*)buf2;
|
||||
|
||||
/*
|
||||
* XOR aligned region using 128-bit XOR
|
||||
|
@ -160,9 +160,9 @@ void xor_bufs_and_store(char *buf1, char *buf2, int blocksize)
|
|||
int fast_int_blocksize = fast_blocksize / sizeof(unsigned long);
|
||||
int i;
|
||||
|
||||
unsigned long*_buf1 = (unsigned long*)buf1;
|
||||
unsigned long*_buf2 = (unsigned long*)buf2;
|
||||
|
||||
unsigned long*_buf1 = (unsigned long*)buf1;
|
||||
unsigned long*_buf2 = (unsigned long*)buf2;
|
||||
|
||||
for (i=0; i < fast_int_blocksize; i++) {
|
||||
_buf2[i] = _buf1[i] ^ _buf2[i];
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ void xor_bufs_and_store(char *buf1, char *buf2, int blocksize)
|
|||
void xor_code_encode(xor_code_t *code_desc, char **data, char **parity, int blocksize)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
||||
for (i=0; i < code_desc->k; i++) {
|
||||
for (j=0; j < code_desc->m; j++) {
|
||||
if (is_data_in_parity(i, code_desc->parity_bms[j])) {
|
||||
|
@ -212,12 +212,12 @@ int * get_missing_parity(xor_code_t *code_desc, int *missing_idxs)
|
|||
|
||||
while (missing_idxs[i] > -1) {
|
||||
if (missing_idxs[i] >= code_desc->k) {
|
||||
missing_parity[j] = missing_idxs[i];
|
||||
missing_parity[j] = missing_idxs[i];
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
missing_parity[j] = -1;
|
||||
return missing_parity;
|
||||
}
|
||||
|
@ -229,12 +229,12 @@ int * get_missing_data(xor_code_t *code_desc, int *missing_idxs)
|
|||
|
||||
while (missing_idxs[i] > -1) {
|
||||
if (missing_idxs[i] < code_desc->k) {
|
||||
missing_data[j] = missing_idxs[i];
|
||||
missing_data[j] = missing_idxs[i];
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
missing_data[j] = -1;
|
||||
return missing_data;
|
||||
}
|
||||
|
@ -280,17 +280,17 @@ void xor_reconstruct_one(xor_code_t *code_desc, char **data, char **parity, int
|
|||
|
||||
// If it is a parity symbol, we need to figure out
|
||||
// what data symbols are needed to reconstruct the
|
||||
// parity. If *any* data symbols in the parity
|
||||
// parity. If *any* data symbols in the parity
|
||||
// equation are missing, we are better off calling
|
||||
// the underlying decode function.
|
||||
int num_data_missing = num_missing_data_in_parity(code_desc, index_to_reconstruct, missing_data);
|
||||
|
||||
if (num_data_missing == 0) {
|
||||
int relative_parity_idx = index_to_reconstruct - code_desc->k;
|
||||
int parity_bm = code_desc->parity_bms[relative_parity_idx];
|
||||
int parity_bm = code_desc->parity_bms[relative_parity_idx];
|
||||
|
||||
memset(parity[relative_parity_idx], 0, blocksize);
|
||||
|
||||
|
||||
for (i=0; i < code_desc->k; i++) {
|
||||
if (parity_bm & (1 << i)) {
|
||||
xor_bufs_and_store(data[i], parity[relative_parity_idx], blocksize);
|
||||
|
@ -321,7 +321,7 @@ int num_missing_data_in_parity(xor_code_t *code_desc, int parity_idx, int *missi
|
|||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
return num_missing_data;
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ int index_of_connected_parity(xor_code_t *code_desc, int data_index, int *missin
|
|||
{
|
||||
int parity_index = -1;
|
||||
int i;
|
||||
|
||||
|
||||
for (i=0; i < code_desc->m; i++) {
|
||||
if (num_missing_data_in_parity(code_desc, i + code_desc->k, missing_data) > 1) {
|
||||
continue;
|
||||
|
@ -343,8 +343,8 @@ int index_of_connected_parity(xor_code_t *code_desc, int data_index, int *missin
|
|||
}
|
||||
while (missing_parity[j] > -1) {
|
||||
if ((code_desc->k + i) == missing_parity[j]) {
|
||||
is_missing = 1;
|
||||
break;
|
||||
is_missing = 1;
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ int index_of_connected_parity(xor_code_t *code_desc, int data_index, int *missin
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Must add k to get the absolute
|
||||
// index of the parity in the stripe
|
||||
return parity_index > -1 ? parity_index + code_desc->k : parity_index;
|
||||
|
@ -365,7 +365,7 @@ void remove_from_missing_list(int element, int *missing_list)
|
|||
int i = 0;
|
||||
int elem_idx = -1;
|
||||
int num_elems = 0;
|
||||
|
||||
|
||||
while (missing_list[i] > -1) {
|
||||
if (missing_list[i] == element) {
|
||||
elem_idx = i;
|
||||
|
@ -377,7 +377,7 @@ void remove_from_missing_list(int element, int *missing_list)
|
|||
num_elems = i;
|
||||
|
||||
for (i=elem_idx;i < num_elems-1;i++) {
|
||||
int tmp = missing_list[i+1];
|
||||
int tmp = missing_list[i+1];
|
||||
missing_list[i+1] = missing_list[i];
|
||||
missing_list[i] = tmp;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ static int fragments_needed_two_data(xor_code_t *code_desc, int *missing_data, i
|
|||
ret = fragments_needed_one_data(code_desc, missing_data, missing_parity, data_bm, parity_bm);
|
||||
|
||||
*data_bm &= ~((unsigned int)1 << data_index);
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -175,10 +175,10 @@ static int fragments_needed_three_data(xor_code_t *code_desc, int *missing_data,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int fragments_needed_one_data_local(xor_code_t *code_desc,
|
||||
static int fragments_needed_one_data_local(xor_code_t *code_desc,
|
||||
int fragment_to_reconstruct,
|
||||
int *fragments_to_exclude,
|
||||
unsigned int *data_bm,
|
||||
unsigned int *data_bm,
|
||||
unsigned int *parity_bm)
|
||||
{
|
||||
int *missing_data = get_missing_data(code_desc, fragments_to_exclude);
|
||||
|
@ -211,7 +211,7 @@ int xor_hd_fragments_needed(xor_code_t *code_desc, int *fragments_to_reconstruct
|
|||
|
||||
/**
|
||||
* Re-visit this decision (KMG): This is non-optimal, but good enough in most cases.
|
||||
* If there is a single data item to reconstruct, then try to find a connected parity
|
||||
* If there is a single data item to reconstruct, then try to find a connected parity
|
||||
* with no items in fragments_to_exclude. If there is a single parity item to reconsturct
|
||||
* or more than 1 data/parity element missing, then just work fragments_to_exclude into
|
||||
* missing_idxs.
|
||||
|
@ -220,10 +220,10 @@ int xor_hd_fragments_needed(xor_code_t *code_desc, int *fragments_to_reconstruct
|
|||
if (pattern == FAIL_PATTERN_1D_0P) {
|
||||
// Since we have landed on this failure pattern, fragments_to_reconstruct[0] is defined.
|
||||
ret = fragments_needed_one_data_local(code_desc, fragments_to_reconstruct[0], fragments_to_exclude, &data_bm, &parity_bm);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* There is either more than one failed element, a failed parity element or
|
||||
* There is either more than one failed element, a failed parity element or
|
||||
* we were unable to return the fragments needed for a simple reconstruction.
|
||||
*/
|
||||
if (ret == -1) {
|
||||
|
@ -235,7 +235,7 @@ int xor_hd_fragments_needed(xor_code_t *code_desc, int *fragments_to_reconstruct
|
|||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (fragments_to_reconstruct[i] > -1) {
|
||||
|
@ -251,8 +251,8 @@ int xor_hd_fragments_needed(xor_code_t *code_desc, int *fragments_to_reconstruct
|
|||
}
|
||||
// End of list
|
||||
missing_idxs[j] = -1;
|
||||
|
||||
pattern = get_failure_pattern(code_desc, missing_idxs);
|
||||
|
||||
pattern = get_failure_pattern(code_desc, missing_idxs);
|
||||
|
||||
switch(pattern) {
|
||||
case FAIL_PATTERN_0D_0P:
|
||||
|
@ -330,7 +330,7 @@ int xor_hd_fragments_needed(xor_code_t *code_desc, int *fragments_to_reconstruct
|
|||
break;
|
||||
}
|
||||
case FAIL_PATTERN_0D_1P:
|
||||
{
|
||||
{
|
||||
int *missing_parity = get_missing_parity(code_desc, missing_idxs);
|
||||
// OR all of the parities
|
||||
i=0;
|
||||
|
@ -385,7 +385,7 @@ int xor_hd_fragments_needed(xor_code_t *code_desc, int *fragments_to_reconstruct
|
|||
i++;
|
||||
data_bm >>= 1;
|
||||
}
|
||||
|
||||
|
||||
i=0;
|
||||
while (parity_bm) {
|
||||
if (parity_bm & 1) {
|
||||
|
@ -395,7 +395,7 @@ int xor_hd_fragments_needed(xor_code_t *code_desc, int *fragments_to_reconstruct
|
|||
i++;
|
||||
parity_bm >>= 1;
|
||||
}
|
||||
|
||||
|
||||
fragments_needed[j] = -1;
|
||||
}
|
||||
|
||||
|
@ -413,7 +413,7 @@ out:
|
|||
*/
|
||||
static void decode_one_data(xor_code_t *code_desc, char **data, char **parity, int *missing_data, int *missing_parity, int blocksize)
|
||||
{
|
||||
// Verify that missing_data[1] == -1?
|
||||
// Verify that missing_data[1] == -1?
|
||||
int data_index = missing_data[0];
|
||||
int parity_index = index_of_connected_parity(code_desc, data_index, missing_parity, missing_data);
|
||||
int i;
|
||||
|
@ -434,7 +434,7 @@ static int decode_two_data(xor_code_t *code_desc, char **data, char **parity, in
|
|||
int data_index = missing_data[0];
|
||||
int parity_index = index_of_connected_parity(code_desc, data_index, missing_parity, missing_data);
|
||||
int i;
|
||||
|
||||
|
||||
if (parity_index < 0) {
|
||||
data_index = missing_data[1];
|
||||
parity_index = index_of_connected_parity(code_desc, data_index, missing_parity, missing_data);
|
||||
|
@ -447,7 +447,7 @@ static int decode_two_data(xor_code_t *code_desc, char **data, char **parity, in
|
|||
missing_data[0] = missing_data[1];
|
||||
missing_data[1] = -1;
|
||||
}
|
||||
|
||||
|
||||
// Copy the appropriate parity into the data buffer
|
||||
fast_memcpy(data[data_index], parity[parity_index-code_desc->k], blocksize);
|
||||
|
||||
|
@ -470,11 +470,11 @@ static int decode_three_data(xor_code_t *code_desc, char **data, char **parity,
|
|||
char *parity_buffer = NULL;
|
||||
|
||||
/*
|
||||
* Try to find a parity that only contains
|
||||
* Try to find a parity that only contains
|
||||
* one of the missing data elements.
|
||||
*/
|
||||
while (missing_data[i] > -1) {
|
||||
parity_index = index_of_connected_parity(code_desc, missing_data[i], missing_parity, missing_data);
|
||||
parity_index = index_of_connected_parity(code_desc, missing_data[i], missing_parity, missing_data);
|
||||
if (parity_index > -1) {
|
||||
data_index = missing_data[i];
|
||||
parity_buffer = parity[parity_index-code_desc->k];
|
||||
|
@ -487,15 +487,15 @@ static int decode_three_data(xor_code_t *code_desc, char **data, char **parity,
|
|||
/*
|
||||
* If we cannot find a parity that is connected to only
|
||||
* one missing element, we must find a parity that is
|
||||
* connected to exactly 2 (P) and another that is connected
|
||||
* connected to exactly 2 (P) and another that is connected
|
||||
* to exactly 3 (Q) (it should exist!!!).
|
||||
*
|
||||
*
|
||||
* We XOR those parities together and use it to recover
|
||||
* the element that is not connected to P.
|
||||
*/
|
||||
if (parity_index < 0) {
|
||||
int contains_2d = -1;
|
||||
int contains_3d = -1;
|
||||
int contains_2d = -1;
|
||||
int contains_3d = -1;
|
||||
|
||||
for (i=0;i < code_desc->m;i++) {
|
||||
int num_missing = num_missing_data_in_parity(code_desc, code_desc->k+i, missing_data);
|
||||
|
@ -546,7 +546,7 @@ static int decode_three_data(xor_code_t *code_desc, char **data, char **parity,
|
|||
fast_memcpy(data[data_index], parity_buffer, blocksize);
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (i=0; i < code_desc->k; i++) {
|
||||
if (i != data_index && is_data_in_parity(i, parity_bm)) {
|
||||
xor_bufs_and_store(data[i], data[data_index], blocksize);
|
||||
|
@ -564,30 +564,30 @@ int xor_hd_decode(xor_code_t *code_desc, char **data, char **parity, int *missin
|
|||
failure_pattern_t pattern = get_failure_pattern(code_desc, missing_idxs);
|
||||
|
||||
switch(pattern) {
|
||||
case FAIL_PATTERN_0D_0P:
|
||||
case FAIL_PATTERN_0D_0P:
|
||||
break;
|
||||
case FAIL_PATTERN_1D_0P:
|
||||
case FAIL_PATTERN_1D_0P:
|
||||
{
|
||||
int *missing_data = get_missing_data(code_desc, missing_idxs);
|
||||
decode_one_data(code_desc, data, parity, missing_data, NULL, blocksize);
|
||||
free(missing_data);
|
||||
break;
|
||||
}
|
||||
case FAIL_PATTERN_2D_0P:
|
||||
case FAIL_PATTERN_2D_0P:
|
||||
{
|
||||
int *missing_data = get_missing_data(code_desc, missing_idxs);
|
||||
ret = decode_two_data(code_desc, data, parity, missing_data, NULL, blocksize);
|
||||
free(missing_data);
|
||||
break;
|
||||
}
|
||||
case FAIL_PATTERN_3D_0P:
|
||||
case FAIL_PATTERN_3D_0P:
|
||||
{
|
||||
int *missing_data = get_missing_data(code_desc, missing_idxs);
|
||||
ret = decode_three_data(code_desc, data, parity, missing_data, NULL, blocksize);
|
||||
free(missing_data);
|
||||
break;
|
||||
}
|
||||
case FAIL_PATTERN_1D_1P:
|
||||
case FAIL_PATTERN_1D_1P:
|
||||
{
|
||||
int *missing_data = get_missing_data(code_desc, missing_idxs);
|
||||
int *missing_parity = get_missing_parity(code_desc, missing_idxs);
|
||||
|
@ -599,7 +599,7 @@ int xor_hd_decode(xor_code_t *code_desc, char **data, char **parity, int *missin
|
|||
free(missing_data);
|
||||
break;
|
||||
}
|
||||
case FAIL_PATTERN_1D_2P:
|
||||
case FAIL_PATTERN_1D_2P:
|
||||
{
|
||||
int *missing_data = get_missing_data(code_desc, missing_idxs);
|
||||
int *missing_parity = get_missing_parity(code_desc, missing_idxs);
|
||||
|
@ -611,7 +611,7 @@ int xor_hd_decode(xor_code_t *code_desc, char **data, char **parity, int *missin
|
|||
free(missing_parity);
|
||||
break;
|
||||
}
|
||||
case FAIL_PATTERN_2D_1P:
|
||||
case FAIL_PATTERN_2D_1P:
|
||||
{
|
||||
int *missing_data = get_missing_data(code_desc, missing_idxs);
|
||||
int *missing_parity = get_missing_parity(code_desc, missing_idxs);
|
||||
|
@ -623,14 +623,14 @@ int xor_hd_decode(xor_code_t *code_desc, char **data, char **parity, int *missin
|
|||
free(missing_data);
|
||||
break;
|
||||
}
|
||||
case FAIL_PATTERN_0D_1P:
|
||||
case FAIL_PATTERN_0D_1P:
|
||||
if (decode_parity) {
|
||||
int *missing_parity = get_missing_parity(code_desc, missing_idxs);
|
||||
selective_encode(code_desc, data, parity, missing_parity, blocksize);
|
||||
free(missing_parity);
|
||||
}
|
||||
break;
|
||||
case FAIL_PATTERN_0D_2P:
|
||||
case FAIL_PATTERN_0D_2P:
|
||||
if (decode_parity) {
|
||||
int *missing_parity = get_missing_parity(code_desc, missing_idxs);
|
||||
selective_encode(code_desc, data, parity, missing_parity, blocksize);
|
||||
|
@ -644,7 +644,7 @@ int xor_hd_decode(xor_code_t *code_desc, char **data, char **parity, int *missin
|
|||
free(missing_parity);
|
||||
}
|
||||
break;
|
||||
case FAIL_PATTERN_GE_HD:
|
||||
case FAIL_PATTERN_GE_HD:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -670,7 +670,7 @@ xor_code_t* init_xor_hd_code(int k, int m, int hd)
|
|||
is_valid = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (hd == 4) {
|
||||
if (m == 6) {
|
||||
if (k <= 20 && k >= 6) {
|
||||
|
|
|
@ -681,7 +681,7 @@ int liberasurecode_decode(int desc,
|
|||
*
|
||||
*/
|
||||
ret = prepare_fragments_for_decode(k, m,
|
||||
data, parity, missing_idxs,
|
||||
data, parity, missing_idxs,
|
||||
&orig_data_size, &blocksize,
|
||||
fragment_len, &realloc_bm);
|
||||
if (ret < 0) {
|
||||
|
|
|
@ -54,9 +54,9 @@ static bool is_fragment(char *buf)
|
|||
|
||||
/**
|
||||
* Memory Management Methods
|
||||
*
|
||||
*
|
||||
* The following methods provide wrappers for allocating and deallocating
|
||||
* memory.
|
||||
* memory.
|
||||
*/
|
||||
void *get_aligned_buffer16(int size)
|
||||
{
|
||||
|
@ -96,7 +96,7 @@ void * alloc_zeroed_buffer(int size)
|
|||
*/
|
||||
void * alloc_and_set_buffer(int size, int value) {
|
||||
void * buf = NULL; /* buffer to allocate and return */
|
||||
|
||||
|
||||
/* Allocate and zero the buffer, or set the appropriate error */
|
||||
buf = malloc((size_t) size);
|
||||
if (buf) {
|
||||
|
@ -106,7 +106,7 @@ void * alloc_and_set_buffer(int size, int value) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Deallocate memory buffer if it's not NULL. This methods returns NULL so
|
||||
* Deallocate memory buffer if it's not NULL. This methods returns NULL so
|
||||
* that you can free and reset a buffer using a single line as follows:
|
||||
*
|
||||
* my_ptr = check_and_free_buffer(my_ptr);
|
||||
|
@ -175,9 +175,9 @@ uint64_t get_fragment_size(char *buf)
|
|||
}
|
||||
|
||||
/**
|
||||
* Compute a size aligned to the number of data and the underlying wordsize
|
||||
* Compute a size aligned to the number of data and the underlying wordsize
|
||||
* of the EC algorithm.
|
||||
*
|
||||
*
|
||||
* @param instance - ec_backend_t instance (to extract args)
|
||||
* @param data_len - integer length of data in bytes
|
||||
* @return integer data length aligned with wordsize of EC algorithm
|
||||
|
@ -427,7 +427,7 @@ int set_backend_id(char *buf, ec_backend_id_t id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int get_backend_id(char *buf, ec_backend_id_t *id)
|
||||
int get_backend_id(char *buf, ec_backend_id_t *id)
|
||||
{
|
||||
if (!is_fragment(buf)) {
|
||||
return -1;
|
||||
|
@ -437,7 +437,7 @@ int get_backend_id(char *buf, ec_backend_id_t *id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int set_backend_version(char *buf, uint32_t version)
|
||||
int set_backend_version(char *buf, uint32_t version)
|
||||
{
|
||||
if (!is_fragment(buf)) {
|
||||
return -1;
|
||||
|
@ -447,7 +447,7 @@ int set_backend_version(char *buf, uint32_t version)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int get_backend_version(char *buf, uint32_t *version)
|
||||
int get_backend_version(char *buf, uint32_t *version)
|
||||
{
|
||||
if (!is_fragment(buf)) {
|
||||
return -1;
|
||||
|
@ -468,7 +468,7 @@ inline int set_checksum(ec_checksum_type_t ct, char *buf, int blocksize)
|
|||
assert(NULL != header);
|
||||
if (header->magic != LIBERASURECODE_FRAG_HEADER_MAGIC) {
|
||||
log_error("Invalid fragment header (set chksum)!\n");
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
header->meta.chksum_type = ct;
|
||||
|
@ -489,7 +489,7 @@ inline int set_checksum(ec_checksum_type_t ct, char *buf, int blocksize)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,10 +64,10 @@ int prepare_fragments_for_encode(ec_backend_t instance,
|
|||
ret = -ENOMEM;
|
||||
goto out_error;
|
||||
}
|
||||
|
||||
|
||||
/* Copy existing data into clean, zero'd out buffer */
|
||||
encoded_data[i] = get_data_ptr_from_fragment(fragment);
|
||||
|
||||
|
||||
if (data_len > 0) {
|
||||
memcpy(encoded_data[i] + data_offset, orig_data, copy_size);
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ out_error:
|
|||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Note that the caller should always check realloc_bm during success or
|
||||
* failure to free buffers allocated here. We could free up in this function,
|
||||
* but it is internal to this library and only used in a few places. In any
|
||||
|
@ -244,7 +244,7 @@ int get_fragment_partition(
|
|||
|
||||
/*
|
||||
* Fill in data and parity with available fragments
|
||||
*/
|
||||
*/
|
||||
for (i = 0; i < num_fragments; i++) {
|
||||
index = get_fragment_idx(fragments[i]);
|
||||
if (index < 0 || index > (k + m)) {
|
||||
|
@ -296,7 +296,7 @@ int fragments_to_string(int k, int m,
|
|||
* This is not necessarily an error condition, so *do not log here*
|
||||
* We can maybe debug log, if necessary.
|
||||
*/
|
||||
goto out;
|
||||
goto out;
|
||||
}
|
||||
|
||||
data = (char **) get_aligned_buffer16(sizeof(char *) * k);
|
||||
|
@ -304,9 +304,9 @@ int fragments_to_string(int k, int m,
|
|||
if (NULL == data) {
|
||||
log_error("Could not allocate buffer for data!!");
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < num_fragments; i++) {
|
||||
index = get_fragment_idx(fragments[i]);
|
||||
data_size = get_fragment_payload_size(fragments[i]);
|
||||
|
@ -326,7 +326,7 @@ int fragments_to_string(int k, int m,
|
|||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Skip parity fragments, put data fragments in index order */
|
||||
if (index >= k) {
|
||||
continue;
|
||||
|
@ -355,7 +355,7 @@ int fragments_to_string(int k, int m,
|
|||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
/* Pass the original data length back */
|
||||
*payload_len = orig_data_size;
|
||||
|
||||
|
|
|
@ -127,9 +127,9 @@ alg_sig_t *init_alg_sig_w8(void *jerasure_sohandle, int sig_len)
|
|||
alg_sig_handle->tbl3_l = (int*)malloc(sizeof(int) * num_gf_lr_table_syms);
|
||||
alg_sig_handle->tbl3_r = (int*)malloc(sizeof(int) * num_gf_lr_table_syms);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Note that \alpha = 2
|
||||
* Note that \alpha = 2
|
||||
* Note that \beta = 4 (\alpha ^ 2)
|
||||
* Note that \gamme = 8 (\alpha ^ 3)
|
||||
*/
|
||||
|
@ -140,7 +140,7 @@ alg_sig_t *init_alg_sig_w8(void *jerasure_sohandle, int sig_len)
|
|||
|
||||
alg_sig_handle->tbl2_l[i] = alg_sig_handle->mult_routines.galois_single_multiply((unsigned char) (i << 4) & 0xf0, beta, w);
|
||||
alg_sig_handle->tbl2_r[i] = alg_sig_handle->mult_routines.galois_single_multiply((unsigned char) i, beta, w);
|
||||
|
||||
|
||||
alg_sig_handle->tbl3_l[i] = alg_sig_handle->mult_routines.galois_single_multiply((unsigned char) (i << 4) & 0xf0, gamma, w);
|
||||
alg_sig_handle->tbl3_r[i] = alg_sig_handle->mult_routines.galois_single_multiply((unsigned char) i, gamma, w);
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ alg_sig_t *init_alg_sig_w16(void *jerasure_sohandle, int sig_len)
|
|||
if (NULL == jerasure_sohandle) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
alg_sig_handle = (alg_sig_t *)malloc(sizeof(alg_sig_t));
|
||||
if (NULL == alg_sig_handle) {
|
||||
return NULL;
|
||||
|
@ -191,9 +191,9 @@ alg_sig_t *init_alg_sig_w16(void *jerasure_sohandle, int sig_len)
|
|||
alg_sig_handle->tbl3_l = (int*)malloc(sizeof(int) * num_gf_lr_table_syms);
|
||||
alg_sig_handle->tbl3_r = (int*)malloc(sizeof(int) * num_gf_lr_table_syms);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Note that \alpha = 2
|
||||
* Note that \alpha = 2
|
||||
* Note that \beta = 4 (\alpha ^ 2 MOD 2^16)
|
||||
* Note that \gamme = 8 (\alpha ^ 3 MOD 2^16)
|
||||
*/
|
||||
|
@ -204,7 +204,7 @@ alg_sig_t *init_alg_sig_w16(void *jerasure_sohandle, int sig_len)
|
|||
if (num_components >= 4) {
|
||||
alg_sig_handle->tbl2_l[i] = alg_sig_handle->mult_routines.galois_single_multiply((unsigned short) (i << 8), beta, w);
|
||||
alg_sig_handle->tbl2_r[i] = alg_sig_handle->mult_routines.galois_single_multiply((unsigned short) i, beta, w);
|
||||
|
||||
|
||||
alg_sig_handle->tbl3_l[i] = alg_sig_handle->mult_routines.galois_single_multiply((unsigned short) (i << 8), gamma, w);
|
||||
alg_sig_handle->tbl3_r[i] = alg_sig_handle->mult_routines.galois_single_multiply((unsigned short) i, gamma, w);
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ alg_sig_t *init_alg_sig(int sig_len, int gf_w)
|
|||
}
|
||||
|
||||
while (valid_pairs[i][0] > -1) {
|
||||
if (gf_w == valid_pairs[i][0] &&
|
||||
if (gf_w == valid_pairs[i][0] &&
|
||||
sig_len == valid_pairs[i][1]) {
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue