Start liberasurecode API definition
Signed-off-by: Tushar Gohad <tushar.gohad@intel.com>
This commit is contained in:
112
include/erasurecode.h
Normal file
112
include/erasurecode.h
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* <Copyright>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY
|
||||
* THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _ERASURECODE_H_
|
||||
#define _ERASURECODE_H_
|
||||
|
||||
#include "erasurecode_version.h"
|
||||
#include "erasurecode_stdinc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined (__GNUC__) && __GNUC__ > 3
|
||||
#define dl_restrict __restrict
|
||||
#else
|
||||
#define dl_restrict
|
||||
#endif
|
||||
|
||||
/* liberasurecode API header */
|
||||
|
||||
typedef enum {
|
||||
EC_BACKEND_NULL = 0,
|
||||
EC_BACKEND_RS_VAND = 1,
|
||||
EC_BACKEND_RS_CAUCHY_ORIG = 2,
|
||||
EC_BACKEND_FLAT_XOR_3 = 3,
|
||||
EC_BACKEND_FLAT_XOR_4 = 4,
|
||||
EC_BACKENDS_MAX,
|
||||
} ec_backend_id_t;
|
||||
|
||||
typedef void * ec_backend_handle_t;
|
||||
|
||||
struct ec_backend_ops {
|
||||
int (*init)(TBD);
|
||||
int (*exit)(TBD);
|
||||
|
||||
ec_backend_handle_t (*open)(TBD);
|
||||
void (*close)(ec_backend_handle_t handle);
|
||||
|
||||
int (*encode)(TBD);
|
||||
int (*decode)(TBD);
|
||||
int (*reconstruct)(TBD);
|
||||
int (*get_fragments_needed)(TBD);
|
||||
int (*get_fragment_metadata)(TBD);
|
||||
int (*verify_fragment_metadata)(TBD);
|
||||
int (*verify_stripe_metadata)(TBD);
|
||||
};
|
||||
typedef struct ec_backend_ops ec_backend_ops_t;
|
||||
|
||||
struct ec_backend_private {
|
||||
uint32_t flags;
|
||||
/* other common/private EC backend members go here */
|
||||
};
|
||||
typedef struct ec_backend_private ec_backend_private_t;
|
||||
|
||||
|
||||
#define MAX_BASENAMELEN 64
|
||||
#define MAX_LIBNAMELEN 64
|
||||
#define MAX_LIBVERLEN 64
|
||||
struct ec_backend {
|
||||
ec_backend_id_t id; /* EC backend id */
|
||||
char name[MAX_BASENAMELEN]; /* EC backend common name */
|
||||
char soname[MAX_LIBNAMELEN]; /* EC backend shared library path */
|
||||
char soversion[MAX_LIBVERLEN]; /* EC backend shared library version */
|
||||
ec_backend_handle_t handle; /* EC backend shared library handle */
|
||||
uint8_t users; /* EC backend number of active references */
|
||||
|
||||
ec_backend_ops_t ops; /* EC backend ops table */
|
||||
ec_backend_private_t private; /* EC backend private data */
|
||||
|
||||
SLIST_ENTRY(ec_backend) link;
|
||||
};
|
||||
typedef struct ec_backend ec_backend_t;
|
||||
|
||||
/* Error codes */
|
||||
typedef enum {
|
||||
EBACKENDNOTSUPP = 200,
|
||||
EECMETHODNOTIMPL = 201,
|
||||
} LIBERASURECODE_ERROR_CODES;
|
||||
|
||||
/* Backend registration interface */
|
||||
int liberasurecode_backend_register(ec_backend_t *backend);
|
||||
int liberasurecode_backend_unregister(ec_backend_t *backend);
|
||||
|
||||
/*
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _ERASURECODE_H_
|
||||
42
include/erasurecode_internal.h
Normal file
42
include/erasurecode_internal.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* <Copyright>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY
|
||||
* THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _ERASURECODE_INTERNAL_H_
|
||||
#define _ERASURECODE_INTERNAL_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "erasurecode.h"
|
||||
|
||||
/* Init/exit routines */
|
||||
int liberasurecode_backend_init(ec_backend_t *backend);
|
||||
int liberasurecode_backend_exit(ec_backend_t *backend);
|
||||
|
||||
/* Backend query interface */
|
||||
ec_backend_t liberasurecode_backend_get_by_name(const char *name);
|
||||
ec_backend_t liberasurecode_backend_get_by_soname(const char *soname);
|
||||
|
||||
#endif // _ERASURECODE_INTERNAL_H_
|
||||
131
include/erasurecode_stdinc.h
Normal file
131
include/erasurecode_stdinc.h
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* <Copyright>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY
|
||||
* THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _ERASURECODE_STDINC_H
|
||||
#define _ERASURECODE_STDINC_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#if defined(STDC_HEADERS)
|
||||
# include <stdlib.h>
|
||||
# include <stddef.h>
|
||||
# include <stdarg.h>
|
||||
#else
|
||||
# if defined(HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
# elif defined(HAVE_MALLOC_H)
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
# if defined(HAVE_STDDEF_H)
|
||||
# include <stddef.h>
|
||||
# endif
|
||||
# if defined(HAVE_STDARG_H)
|
||||
# include <stdarg.h>
|
||||
# endif
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
|
||||
# include <memory.h>
|
||||
# endif
|
||||
# include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#if defined(HAVE_INTTYPES_H)
|
||||
# include <inttypes.h>
|
||||
#elif defined(HAVE_STDINT_H)
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_CTYPE_H
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
|
||||
# include <iconv.h>
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||
# define DECLSPEC __attribute__ ((visibility("default")))
|
||||
#else
|
||||
# define DECLSPEC
|
||||
#endif
|
||||
|
||||
// FIXME - need to move these to the main liberasurecode header
|
||||
#ifdef HAVE_MALLOC
|
||||
#define ERASURECODE_malloc malloc
|
||||
#else
|
||||
extern DECLSPEC void * ERASURECODE_malloc(size_t size);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CALLOC
|
||||
#define ERASURECODE_calloc calloc
|
||||
#else
|
||||
extern DECLSPEC void * ERASURECODE_calloc(size_t nmemb, size_t size);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_REALLOC
|
||||
#define ERASURECODE_realloc realloc
|
||||
#else
|
||||
extern DECLSPEC void * ERASURECODE_realloc(void *mem, size_t size);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FREE
|
||||
#define ERASURECODE_free free
|
||||
#else
|
||||
extern DECLSPEC void ERASURECODE_free(void *mem);
|
||||
#endif
|
||||
|
||||
/* Redefine main() on MacOS */
|
||||
|
||||
#if defined(__MACOS__) || defined(__MACOSX__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define C_LINKAGE "C"
|
||||
#else
|
||||
#define C_LINKAGE
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/** The application's main() function must be called with C linkage,
|
||||
* and should be declared like this:
|
||||
* @code
|
||||
* #ifdef __cplusplus
|
||||
* extern "C"
|
||||
* #endif
|
||||
* int main(int argc, char *argv[])
|
||||
* {
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
#define main EC_main
|
||||
|
||||
/** The prototype for the application's main() function */
|
||||
extern C_LINKAGE int EC_main(int argc, char *argv[]);
|
||||
|
||||
#endif // _ERASURECODE_STDINC_H
|
||||
37
include/erasurecode_version.h
Normal file
37
include/erasurecode_version.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* <Copyright>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY
|
||||
* THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _ERASURECODE_VERSION_H_
|
||||
#define _ERASURECODE_VERSION_H_
|
||||
|
||||
#define MAJOR = 0
|
||||
#define MINOR = 9
|
||||
#define REV = 4
|
||||
#define VERSION(x, y, z) ((x << 16) | (y << 8) | (z))
|
||||
|
||||
#define LIBERASURECODE_VERSION VERSION(MAJOR, MINOR, REV)
|
||||
|
||||
#endif // _ERASURECODE_VERSION_H_
|
||||
|
||||
|
||||
Reference in New Issue
Block a user