summaryrefslogtreecommitdiff
path: root/include/erasurecode/erasurecode_stdinc.h
blob: aaa9e2bf7f5d91e979fac0c896f4b43a18b84e14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/* 
 * <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_

#ifndef _EXCLUDE_LIBERASURE_CODE_H_
#include "config_liberasurecode.h"
#endif

#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif
#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>
# include <stdbool.h>
# include <unistd.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
# if defined(HAVE_UNISTD_H)
#  include <unistd.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
#ifdef HAVE_DLFCN_H
# include <dlfcn.h>
#endif
#ifdef HAVE_DLFCN_H
# include <limits.h>
#endif
#ifdef HAVE_PTHREAD_H
# include <pthread.h>
#define RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER
#define rwlock_t pthread_rwlock_t
#define rwlock_rdlock pthread_rwlock_rdlock
#define rwlock_wrlock pthread_rwlock_wrlock
#define rwlock_tryrdlock pthread_rwlock_tryrdlock
#define rwlock_trywrlock pthread_rwlock_trywrlock
#define rwlock_unlock pthread_rwlock_unlock
#define rwlock_destroy pthread_rwlock_destroy
#endif
#ifdef HAVE_ERRNO_H
# include <errno.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  // MACOSX

#endif // _ERASURECODE_STDINC_H_