]> gitweb.factorcode.org Git - factor.git/blob - vm/ffi_test.h
audio.engine.test: cleanup using
[factor.git] / vm / ffi_test.h
1 #if defined(_MSC_VER)
2 #define FACTOR_STDCALL(return_type) return_type __stdcall
3 #define FACTOR_FASTCALL(return_type) return_type __fastcall
4 #elif defined(i386) || defined(__i386) || defined(__i386__)
5 #define FACTOR_STDCALL(return_type) __attribute__((stdcall)) return_type
6 #define FACTOR_FASTCALL(return_type) __attribute__((fastcall)) return_type
7 #else
8 #define FACTOR_STDCALL(return_type) return_type
9 #define FACTOR_FASTCALL(return_type) return_type
10 #endif
11
12 #if defined(__APPLE__)
13 #define FACTOR_EXPORT __attribute__((visibility("default")))
14 #else
15 #define FACTOR_EXPORT
16 #endif
17
18 FACTOR_EXPORT void ffi_test_0(void);
19 FACTOR_EXPORT int ffi_test_1(void);
20 FACTOR_EXPORT int ffi_test_2(int x, int y);
21 FACTOR_EXPORT int ffi_test_3(int x, int y, int z, int t);
22 FACTOR_EXPORT float ffi_test_4(void);
23 FACTOR_EXPORT double ffi_test_5(void);
24 FACTOR_EXPORT double ffi_test_6(float x, float y);
25 FACTOR_EXPORT double ffi_test_7(double x, double y);
26 FACTOR_EXPORT double ffi_test_8(double x, float y, double z, float t, int w);
27 FACTOR_EXPORT int ffi_test_9(int a, int b, int c, int d, int e, int f, int g);
28 FACTOR_EXPORT int ffi_test_10(int a, int b, double c, int d, float e, int f,
29                               int g, int h);
30 struct foo {
31   int x, y;
32 };
33 FACTOR_EXPORT int ffi_test_11(int a, struct foo b, int c);
34 struct rect {
35   float x, y, w, h;
36 };
37 FACTOR_EXPORT int ffi_test_12(int a, int b, struct rect c, int d, int e, int f);
38 FACTOR_EXPORT int ffi_test_13(int a, int b, int c, int d, int e, int f, int g,
39                               int h, int i, int j, int k);
40 FACTOR_EXPORT struct foo ffi_test_14(int x, int y);
41 FACTOR_EXPORT char* ffi_test_15(char* x, char* y);
42 struct bar {
43   long x, y, z;
44 };
45 FACTOR_EXPORT struct bar ffi_test_16(long x, long y, long z);
46 struct tiny {
47   int x;
48 };
49 FACTOR_EXPORT struct tiny ffi_test_17(int x);
50 FACTOR_EXPORT FACTOR_STDCALL(int) ffi_test_18(int x, int y, int z, int t);
51 FACTOR_EXPORT FACTOR_STDCALL(struct bar) ffi_test_19(long x, long y, long z);
52 FACTOR_EXPORT void ffi_test_20(double x1, double x2, double x3, double y1,
53                                double y2, double y3, double z1, double z2,
54                                double z3);
55 FACTOR_EXPORT long long ffi_test_21(long x, long y);
56 FACTOR_EXPORT long ffi_test_22(long x, long long y, long long z);
57 FACTOR_EXPORT float ffi_test_23(float x[3], float y[3]);
58 struct test_struct_1 {
59   char x;
60 };
61 FACTOR_EXPORT struct test_struct_1 ffi_test_24(void);
62 struct test_struct_2 {
63   char x, y;
64 };
65 FACTOR_EXPORT struct test_struct_2 ffi_test_25(void);
66 struct test_struct_3 {
67   char x, y, z;
68 };
69 FACTOR_EXPORT struct test_struct_3 ffi_test_26(void);
70 struct test_struct_4 {
71   char x, y, z, a;
72 };
73 FACTOR_EXPORT struct test_struct_4 ffi_test_27(void);
74 struct test_struct_5 {
75   char x, y, z, a, b;
76 };
77 FACTOR_EXPORT struct test_struct_5 ffi_test_28(void);
78 struct test_struct_6 {
79   char x, y, z, a, b, c;
80 };
81 FACTOR_EXPORT struct test_struct_6 ffi_test_29(void);
82 struct test_struct_7 {
83   char x, y, z, a, b, c, d;
84 };
85 FACTOR_EXPORT struct test_struct_7 ffi_test_30(void);
86 FACTOR_EXPORT int ffi_test_31(int x0, int x1, int x2, int x3, int x4, int x5,
87                               int x6, int x7, int x8, int x9, int x10, int x11,
88                               int x12, int x13, int x14, int x15, int x16,
89                               int x17, int x18, int x19, int x20, int x21,
90                               int x22, int x23, int x24, int x25, int x26,
91                               int x27, int x28, int x29, int x30, int x31,
92                               int x32, int x33, int x34, int x35, int x36,
93                               int x37, int x38, int x39, int x40, int x41);
94 FACTOR_EXPORT float ffi_test_31_point_5(
95     float x0, float x1, float x2, float x3, float x4, float x5, float x6,
96     float x7, float x8, float x9, float x10, float x11, float x12, float x13,
97     float x14, float x15, float x16, float x17, float x18, float x19, float x20,
98     float x21, float x22, float x23, float x24, float x25, float x26, float x27,
99     float x28, float x29, float x30, float x31, float x32, float x33, float x34,
100     float x35, float x36, float x37, float x38, float x39, float x40,
101     float x41);
102 struct test_struct_8 {
103   double x;
104   double y;
105 };
106 FACTOR_EXPORT double ffi_test_32(struct test_struct_8 x, int y);
107 struct test_struct_9 {
108   float x;
109   float y;
110 };
111 FACTOR_EXPORT double ffi_test_33(struct test_struct_9 x, int y);
112 struct test_struct_10 {
113   float x;
114   int y;
115 };
116 FACTOR_EXPORT double ffi_test_34(struct test_struct_10 x, int y);
117 struct test_struct_11 {
118   int x;
119   int y;
120 };
121 FACTOR_EXPORT double ffi_test_35(struct test_struct_11 x, int y);
122
123 struct test_struct_12 {
124   int a;
125   double x;
126 };
127
128 FACTOR_EXPORT double ffi_test_36(struct test_struct_12 x);
129
130 FACTOR_EXPORT void ffi_test_36_point_5(void);
131
132 FACTOR_EXPORT int ffi_test_37(int (*f)(int, int, int));
133
134 FACTOR_EXPORT unsigned long long ffi_test_38(unsigned long long x,
135                                              unsigned long long y);
136
137 struct test_struct_13 {
138   float x1, x2, x3, x4, x5, x6;
139 };
140
141 FACTOR_EXPORT int ffi_test_39(long a, long b, struct test_struct_13 s);
142
143 struct test_struct_14 {
144   double x1, x2;
145 };
146
147 FACTOR_EXPORT struct test_struct_14 ffi_test_40(double x1, double x2);
148
149 FACTOR_EXPORT struct test_struct_12 ffi_test_41(int a, double x);
150
151 struct test_struct_15 {
152   float x, y;
153 };
154
155 FACTOR_EXPORT struct test_struct_15 ffi_test_42(float x, float y);
156
157 struct test_struct_16 {
158   float x;
159   int a;
160 };
161
162 FACTOR_EXPORT struct test_struct_16 ffi_test_43(float x, int a);
163
164 FACTOR_EXPORT struct test_struct_14 ffi_test_44(void);
165
166 /* C99 features */
167 #ifndef _MSC_VER
168
169 #include <stdbool.h>
170
171 FACTOR_EXPORT _Complex float ffi_test_45(int x);
172
173 FACTOR_EXPORT _Complex double ffi_test_46(int x);
174
175 FACTOR_EXPORT _Complex float ffi_test_47(_Complex float x, _Complex double y);
176
177 struct bool_field_test {
178   char* name;
179   bool on;
180   short parents;
181 };
182
183 FACTOR_EXPORT short ffi_test_48(struct bool_field_test x);
184
185 #endif
186
187 FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_49(int x);
188 FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_50(int x, int y);
189 FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_51(int x, int y, int z);
190 FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_52(int x, float y, int z);
191 FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_53(int x, float y, int z, int w);
192 FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_54(struct test_struct_11 x, int y);
193 FACTOR_EXPORT FACTOR_FASTCALL(int)
194     ffi_test_55(struct test_struct_11 x, int y, int z);
195 FACTOR_EXPORT FACTOR_FASTCALL(int)
196     ffi_test_56(struct test_struct_11 x, int y, int z, int w);
197 FACTOR_EXPORT FACTOR_FASTCALL(struct test_struct_11) ffi_test_57(int x, int y);
198 FACTOR_EXPORT FACTOR_FASTCALL(struct test_struct_11)
199     ffi_test_58(int x, int y, int z);
200
201 FACTOR_EXPORT signed long long ffi_test_59(signed long long x);
202 FACTOR_EXPORT unsigned long long ffi_test_60(unsigned long long x);
203
204 /* C99 features */
205 #ifndef _MSC_VER
206
207 #include <stdbool.h>
208
209 struct bool_and_ptr {
210     bool b;
211     void* ptr;
212 };
213
214 FACTOR_EXPORT struct bool_and_ptr ffi_test_61(void);
215
216 #endif
217
218 struct uint_pair {
219         unsigned int a;
220         unsigned int b;
221 };
222
223 FACTOR_EXPORT struct uint_pair ffi_test_62(void);
224
225 struct ulonglong_pair {
226         unsigned long long a;
227         unsigned long long b;
228 };
229
230 FACTOR_EXPORT struct ulonglong_pair ffi_test_63(void);
231
232 FACTOR_EXPORT int ffi_test_64(int n, ...);
233 FACTOR_EXPORT double ffi_test_65(int n, ...);
234
235
236 struct test_struct_66 {
237   unsigned long mem1;
238   unsigned long mem2;
239 };
240
241 struct test_struct_68 {
242   unsigned long mem1;
243   unsigned long mem2;
244   unsigned long mem3;  
245 };
246
247 struct test_struct_69 {
248   float         mem1;
249   unsigned long mem2;
250   unsigned long mem3;  
251 };
252
253 FACTOR_EXPORT unsigned long ffi_test_66(unsigned long a, unsigned long b, unsigned long c,
254                                         struct test_struct_66 d, struct test_struct_66 e);
255
256 FACTOR_EXPORT unsigned long ffi_test_67(unsigned long a, unsigned long b, unsigned long c,
257                                         struct test_struct_66 d, struct test_struct_66 e, unsigned long f);
258
259 FACTOR_EXPORT unsigned long ffi_test_68(unsigned long a, unsigned long b, unsigned long c,
260                                         struct test_struct_66 d, struct test_struct_68 e, struct test_struct_66 f);
261
262 FACTOR_EXPORT unsigned long ffi_test_69(unsigned long a, unsigned long b, unsigned long c,
263                                         struct test_struct_66 d, struct test_struct_69 e, struct test_struct_66 f);
264
265 FACTOR_EXPORT unsigned long ffi_test_70(struct test_struct_68 a, struct test_struct_68 b, struct test_struct_66 c);
266
267
268 FACTOR_EXPORT void* bug1021_test_1(void* x, int y);
269 FACTOR_EXPORT int bug1021_test_2(int x, char* y, void *z);
270 FACTOR_EXPORT void* bug1021_test_3(int x);