RDFS
The Rice Comp413 2017 class' continuation on the work of the 2016 RDFS.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
isal_load.h
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include <dlfcn.h>
19 #include <errno.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <sys/time.h>
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 
27 #ifndef ISAL_INCLUDE_ISAL_LOAD_H_
28 #define ISAL_INCLUDE_ISAL_LOAD_H_
29 
30 
31 // For gf_util.h
32 typedef unsigned char (*__d_gf_mul)(unsigned char, unsigned char);
33 
34 typedef unsigned char (*__d_gf_inv)(unsigned char);
35 
36 typedef void (*__d_gf_gen_rs_matrix)(unsigned char *, int, int);
37 
38 typedef void (*__d_gf_gen_cauchy_matrix)(unsigned char *, int, int);
39 
40 typedef int (*__d_gf_invert_matrix)(unsigned char *, unsigned char *,
41  const int);
42 
43 typedef int (*__d_gf_vect_mul)(int, unsigned char *, void *, void *);
44 
45 // For erasure_code.h
46 typedef void (*__d_ec_init_tables)(int, int, unsigned char *, unsigned char *);
47 
48 typedef void (*__d_ec_encode_data)(int, int, int, unsigned char *,
49  unsigned char **, unsigned char **);
50 
51 typedef void (*__d_ec_encode_data_update)(int, int, int, int, unsigned char *,
52  unsigned char *, unsigned char **);
53 
54 typedef struct __IsaLibLoader {
55  // The loaded library handle
56  void *libec;
57  char *libname;
58 
59  __d_gf_mul gf_mul;
60  __d_gf_inv gf_inv;
61  __d_gf_gen_rs_matrix gf_gen_rs_matrix;
62  __d_gf_gen_cauchy_matrix gf_gen_cauchy_matrix;
63  __d_gf_invert_matrix gf_invert_matrix;
64  __d_gf_vect_mul gf_vect_mul;
65  __d_ec_init_tables ec_init_tables;
66  __d_ec_encode_data ec_encode_data;
67  __d_ec_encode_data_update ec_encode_data_update;
68 } IsaLibLoader;
69 
70 extern IsaLibLoader *isaLoader;
71 
76 static __attribute__((unused))
77 void *myDlsym(void *handle, const char *symbol) {
78  void *func_ptr = dlsym(handle, symbol);
79  return func_ptr;
80 }
81 
82 /* A helper macro to dlsym the requisite dynamic symbol in NON-JNI env. */
83 #define EC_LOAD_DYNAMIC_SYMBOL(func_ptr, symbol) \
84  if ((func_ptr = myDlsym(isaLoader->libec, symbol)) == NULL) { \
85  return "Failed to load symbol" symbol; \
86  }
87 
94 void load_erasurecode_lib(char *err, size_t err_len);
95 
96 #endif // ISAL_INCLUDE_ISAL_LOAD_H_
Definition: isal_load.h:54