-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.h.in
216 lines (161 loc) · 3.48 KB
/
config.h.in
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#ifndef _CONFIG_H
#define _CONFIG_H
#undef HAVE_STDDEF_H
#undef HAVE_STDARG_H
#undef HAVE_STDINT_H
#undef HAVE_STDLIB_H
#undef HAVE_STDIO_H
#undef HAVE_STRING_H
#undef HAVE_MATH_H
#undef HAVE_FCNTL_H
#undef HAVE_UNISTD_H
#undef HAVE_ERRNO_H
#undef HAVE_SCHED_H
#undef HAVE_SYS_TYPES_H
#undef HAVE_ZIP_H
#undef HAVE_FFI_H
#undef HAVE_GC_H
#undef DEBUG
#undef CONFIG_SYSROOT
#undef APP_NAME
#undef APP_VERSION
#undef APP_COPY
#undef APP_CC
#define APP_CDATE __DATE__
#define APP_CTIME __TIME__
#define APP_CC_VERSION __VERSION__
#define APP_VERSION_FORMAT \
"%s %s\nCopyright (C) %s\nBuilt with %s %s (%s:%s)\n"
#define APP_VERSION_ARGS \
APP_NAME, APP_VERSION, APP_COPY, APP_CC, APP_CC_VERSION, \
APP_CDATE, APP_CTIME
#if HAVE_STDDEF_H
#include <stddef.h>
#else
#error "stddef.h not found (freestanding header)"
#endif
#if HAVE_STDARG_H
#include <stdarg.h>
#else
#error "stdarg.h not found (freestanding header)"
#endif
#if HAVE_STDINT_H
#include <stdint.h>
#else
#error "stdint.h not found (freestanding header)"
#endif
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#else
typedef int pid_t;
typedef int off_t;
typedef int ssize_t;
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#else
void* calloc(size_t, size_t);
void free(void*);
void abort(void);
void exit(int);
#endif
#if HAVE_STDIO_H
#include <stdio.h>
#else
int printf(const char*, ...);
#endif
#if HAVE_MATH_H
#include <math.h>
#else
double fmod(double, double);
#endif
#if HAVE_FCNTL_H
#include <fcntl.h>
#else
#define O_RDONLY 0
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#endif
#if HAVE_ZIP_H
#define CONFIG_JAR 1
#include <zip.h>
#endif
#if HAVE_FFI_H
#define CONFIG_JNI 1
#include <ffi.h>
#endif
#if HAVE_GC_H
#include <gc.h>
static inline void* __gc_calloc(size_t x, size_t y) {
void* p = GC_malloc_uncollectable(x * y);
if(!p)
return NULL;
register int i = x * y;
char* d;
for(d = p; i--; d++)
*d = 0;
return p;
}
#define strdup(s) GC_STRDUP(s)
#define __calloc __gc_calloc
#define __free GC_FREE
#else
#define __calloc calloc
#define __free free
#endif
#if HAVE_STRING_H
#include <string.h>
#else
void* memset(void* s1, int value, size_t size);
void* memcpy(void* s1, const void* s2, size_t size);
char* strcpy(char* s1, const char* s2);
size_t strlen(const char* s);
char* strdup(const char* s);
char* strcat(char*, const char*);
int strcmp(const char* s1, const char* s2);
int strncmp(const char* s1, const char* s2, size_t n);
double fmod(double x, double y);
#endif
#if HAVE_ERRNO_H
#include <errno.h>
#else
extern int errno;
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#else
int close(int);
off_t lseek(int, off_t, int);
ssize_t read(int, void*, size_t);
int open(const char*, int, ...);
pid_t getpid();
#endif
#if HAVE_SCHED_H
#include <sched.h>
#else
int sched_yield(void);
#endif
#if DEBUG
#define LOG(x) \
{ avm->printf("%s: %s\n", APP_NAME, x); }
#define LOGF(x, y...) \
{ avm->printf("%s: " x "\n", APP_NAME, y); }
#define ASSERT(x) \
{ if(unlikely(!(x))) { LOGF("Assertion \"%s\" failed in %s:%d", #x, __FILE__, __LINE__); abort(); } }
#else
#define LOG(x)
#define LOGF(x, y...)
#define ASSERT(x)
#endif
#define PRINTF(x, y...) \
{ avm->printf(x, y); }
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wnonnull"
#endif
#define INITIALIZE_PATH() { \
avm_config_path_add(CONFIG_SYSROOT "/usr/lib/avm"); \
avm_config_path_add(CONFIG_SYSROOT "/usr/local/lib/avm"); \
avm_config_path_add(CONFIG_SYSROOT "/usr/share/java"); \
}
#endif