liberasurecode  1.6.2
Erasure Code API library
isa_l_rs_cauchy.c
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Kevin M Greenan
3  * Copyright 2014 Tushar Gohad
4  * Copyright 2016 Kota Tsuyuzaki
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * Redistributions of source code must retain the above copyright notice, this
10  * list of conditions and the following disclaimer.
11  *
12  * Redistributions in binary form must reproduce the above copyright notice, this
13  * list of conditions and the following disclaimer in the documentation and/or
14  * other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY
15  * THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
16  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18  * EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
19  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * isa_l_rs_cauchy backend implementation
27  *
28  * vi: set noai tw=79 ts=4 sw=4:
29  */
30 
31 #include <stdlib.h>
32 #include "erasurecode_backend.h"
33 #include "isa_l_common.h"
34 
35 #define ISA_L_RS_CAUCHY_LIB_MAJOR 2
36 #define ISA_L_RS_CAUCHY_LIB_MINOR 14
37 #define ISA_L_RS_CAUCHY_LIB_REV 1
38 #define ISA_L_RS_CAUCHY_LIB_VER_STR "2.14"
39 #define ISA_L_RS_CAUCHY_LIB_NAME "isa_l_rs_cauchy"
40 #if defined(__MACOS__) || defined(__MACOSX__) || defined(__OSX__) || defined(__APPLE__)
41 #define ISA_L_RS_CAUCHY_SO_NAME "libisal.dylib"
42 #else
43 #define ISA_L_RS_CAUCHY_SO_NAME "libisal.so.2"
44 #endif
45 
46 /* Forward declarations */
47 struct ec_backend_op_stubs isa_l_rs_cauchy_ops;
48 struct ec_backend isa_l_rs_cauchy;
49 struct ec_backend_common backend_isa_l_rs_cauchy;
50 
51 static void * isa_l_rs_cauchy_init(struct ec_backend_args *args,
52  void *backend_sohandle)
53 {
54  return isa_l_common_init(args, backend_sohandle, "gf_gen_cauchy1_matrix");
55 }
56 
57 /*
58  * For the time being, we only claim compatibility with versions that
59  * match exactly
60  */
61 static bool isa_l_rs_cauchy_is_compatible_with(uint32_t version) {
62  return version == backend_isa_l_rs_cauchy.ec_backend_version;
63 }
64 
65 struct ec_backend_op_stubs isa_l_rs_cauchy_op_stubs = {
66  .INIT = isa_l_rs_cauchy_init,
67  .EXIT = isa_l_exit,
68  .ENCODE = isa_l_encode,
69  .DECODE = isa_l_decode,
70  .FRAGSNEEDED = isa_l_min_fragments,
71  .RECONSTRUCT = isa_l_reconstruct,
72  .ELEMENTSIZE = isa_l_element_size,
73  .ISCOMPATIBLEWITH = isa_l_rs_cauchy_is_compatible_with,
74  .GETMETADATASIZE = get_backend_metadata_size_zero,
75  .GETENCODEOFFSET = get_encode_offset_zero,
76 };
77 
78 struct ec_backend_common backend_isa_l_rs_cauchy = {
79  .id = EC_BACKEND_ISA_L_RS_CAUCHY,
81  .soname = ISA_L_RS_CAUCHY_SO_NAME,
82  .soversion = ISA_L_RS_CAUCHY_LIB_VER_STR,
84  .ec_backend_version = _VERSION(ISA_L_RS_CAUCHY_LIB_MAJOR,
87 };
isa_l_reconstruct
int isa_l_reconstruct(void *desc, char **data, char **parity, int *missing_idxs, int destination_idx, int blocksize)
Definition: isa_l_common.c:283
isa_l_rs_cauchy_init
static void * isa_l_rs_cauchy_init(struct ec_backend_args *args, void *backend_sohandle)
Definition: isa_l_rs_cauchy.c:51
isa_l_element_size
int isa_l_element_size(void *desc)
Return the element-size, which is the number of bits stored on a given device, per codeword.
Definition: isa_l_common.c:427
ISA_L_RS_CAUCHY_LIB_MINOR
#define ISA_L_RS_CAUCHY_LIB_MINOR
Definition: isa_l_rs_cauchy.c:36
isa_l_rs_cauchy_ops
struct ec_backend_op_stubs isa_l_rs_cauchy_ops
Definition: isa_l_rs_cauchy.c:47
isa_l_rs_cauchy_is_compatible_with
static bool isa_l_rs_cauchy_is_compatible_with(uint32_t version)
Definition: isa_l_rs_cauchy.c:61
isa_l_common_init
void * isa_l_common_init(struct ec_backend_args *args, void *backend_sohandle, const char *gen_matrix_func_name)
Definition: isa_l_common.c:446
isa_l_encode
int isa_l_encode(void *desc, char **data, char **parity, int blocksize)
Definition: isa_l_common.c:39
isa_l_exit
int isa_l_exit(void *desc)
Definition: isa_l_common.c:432
backend_isa_l_rs_cauchy
struct ec_backend_common backend_isa_l_rs_cauchy
Definition: isa_l_rs_cauchy.c:49
isa_l_rs_cauchy_op_stubs
struct ec_backend_op_stubs isa_l_rs_cauchy_op_stubs
Definition: isa_l_rs_cauchy.c:65
ISA_L_RS_CAUCHY_LIB_NAME
#define ISA_L_RS_CAUCHY_LIB_NAME
Definition: isa_l_rs_cauchy.c:39
ISA_L_RS_CAUCHY_SO_NAME
#define ISA_L_RS_CAUCHY_SO_NAME
Definition: isa_l_rs_cauchy.c:43
ISA_L_RS_CAUCHY_LIB_MAJOR
#define ISA_L_RS_CAUCHY_LIB_MAJOR
Definition: isa_l_rs_cauchy.c:35
ISA_L_RS_CAUCHY_LIB_VER_STR
#define ISA_L_RS_CAUCHY_LIB_VER_STR
Definition: isa_l_rs_cauchy.c:38
isa_l_min_fragments
int isa_l_min_fragments(void *desc, int *missing_idxs, int *fragments_to_exclude, int *fragments_needed)
Definition: isa_l_common.c:395
ISA_L_RS_CAUCHY_LIB_REV
#define ISA_L_RS_CAUCHY_LIB_REV
Definition: isa_l_rs_cauchy.c:37
isa_l_rs_cauchy
struct ec_backend isa_l_rs_cauchy
Definition: isa_l_rs_cauchy.c:48
isa_l_decode
int isa_l_decode(void *desc, char **data, char **parity, int *missing_idxs, int blocksize)
Definition: isa_l_common.c:179