ffi 1.9.23 → 1.9.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +66 -0
  3. data/Rakefile +1 -1
  4. data/ext/ffi_c/Call.c +5 -2
  5. data/ext/ffi_c/Function.c +8 -5
  6. data/ext/ffi_c/Thread.c +1 -0
  7. data/ext/ffi_c/extconf.rb +1 -0
  8. data/ext/ffi_c/libffi/.appveyor.yml +6 -4
  9. data/ext/ffi_c/libffi/.github/issue_template.md +10 -0
  10. data/ext/ffi_c/libffi/.gitignore +2 -0
  11. data/ext/ffi_c/libffi/.travis.yml +20 -16
  12. data/ext/ffi_c/libffi/.travis/ar-lib +270 -0
  13. data/ext/ffi_c/libffi/.travis/build.sh +34 -0
  14. data/ext/ffi_c/libffi/.travis/compile +351 -0
  15. data/ext/ffi_c/libffi/.travis/install.sh +11 -3
  16. data/ext/ffi_c/libffi/.travis/moxie-sim.exp +60 -0
  17. data/ext/ffi_c/libffi/.travis/site.exp +18 -0
  18. data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +352 -0
  19. data/ext/ffi_c/libffi/Makefile.am +4 -45
  20. data/ext/ffi_c/libffi/{README → README.md} +237 -230
  21. data/ext/ffi_c/libffi/configure.ac +10 -8
  22. data/ext/ffi_c/libffi/configure.host +5 -0
  23. data/ext/ffi_c/libffi/include/ffi.h.in +48 -26
  24. data/ext/ffi_c/libffi/include/ffi_common.h +2 -0
  25. data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +18 -16
  26. data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +21 -8
  27. data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +4 -4
  28. data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +9 -7
  29. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +8 -5
  30. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +5 -5
  31. data/ext/ffi_c/libffi/m4/ax_enable_builddir.m4 +7 -6
  32. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +99 -61
  33. data/ext/ffi_c/libffi/m4/ax_gcc_x86_cpuid.m4 +18 -8
  34. data/ext/ffi_c/libffi/m4/ax_require_defined.m4 +37 -0
  35. data/ext/ffi_c/libffi/msvcc.sh +82 -14
  36. data/ext/ffi_c/libffi/src/aarch64/ffi.c +8 -31
  37. data/ext/ffi_c/libffi/src/closures.c +31 -1
  38. data/ext/ffi_c/libffi/src/ia64/ffi.c +24 -6
  39. data/ext/ffi_c/libffi/src/ia64/ffitarget.h +2 -1
  40. data/ext/ffi_c/libffi/src/ia64/unix.S +6 -1
  41. data/ext/ffi_c/libffi/src/mips/ffi.c +29 -12
  42. data/ext/ffi_c/libffi/src/mips/ffitarget.h +7 -12
  43. data/ext/ffi_c/libffi/src/moxie/eabi.S +1 -1
  44. data/ext/ffi_c/libffi/src/moxie/ffi.c +18 -5
  45. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +45 -16
  46. data/ext/ffi_c/libffi/src/riscv/ffi.c +445 -0
  47. data/ext/ffi_c/libffi/src/riscv/ffitarget.h +68 -0
  48. data/ext/ffi_c/libffi/src/riscv/sysv.S +214 -0
  49. data/ext/ffi_c/libffi/src/types.c +3 -1
  50. data/ext/ffi_c/libffi/src/x86/ffi.c +18 -0
  51. data/ext/ffi_c/libffi/src/x86/ffi64.c +15 -9
  52. data/ext/ffi_c/libffi/src/x86/ffitarget.h +8 -2
  53. data/ext/ffi_c/libffi/src/x86/ffiw64.c +30 -9
  54. data/ext/ffi_c/libffi/src/xtensa/sysv.S +6 -1
  55. data/ext/ffi_c/libffi/testsuite/Makefile.am +108 -77
  56. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +195 -5
  57. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/Makefile +28 -0
  58. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/README +78 -0
  59. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/alignof.h +50 -0
  60. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +58 -0
  61. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1745 -0
  62. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2885 -0
  63. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +743 -0
  64. data/ext/ffi_c/libffi/testsuite/libffi.call/align_stdcall.c +46 -0
  65. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +14 -1
  66. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +3 -1
  67. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct10.c +1 -0
  68. data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +57 -0
  69. data/ext/ffi_c/libffi/testsuite/libffi.call/unwindtest.cc +1 -1
  70. data/ext/ffi_c/libffi/testsuite/libffi.call/unwindtest_ffi_call.cc +1 -1
  71. data/lib/ffi/library.rb +2 -4
  72. data/lib/ffi/platform/mips64-linux/types.conf +104 -0
  73. data/lib/ffi/platform/mipsisa32r6-linux/types.conf +102 -0
  74. data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +102 -0
  75. data/lib/ffi/platform/mipsisa64r6-linux/types.conf +104 -0
  76. data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +104 -0
  77. data/lib/ffi/version.rb +1 -1
  78. metadata +29 -3
@@ -0,0 +1,743 @@
1
+ /*
2
+ * Copyright 1993 Bill Triggs <Bill.Triggs@inrialpes.fr>
3
+ * Copyright 1995-2017 Bruno Haible <bruno@clisp.org>
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation; either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ /* This file defines test functions of selected signatures, that exercise
20
+ dark corners of the various ABIs. */
21
+
22
+ #include <stdio.h>
23
+
24
+ FILE* out;
25
+
26
+ #define uchar unsigned char
27
+ #define ushort unsigned short
28
+ #define uint unsigned int
29
+ #define ulong unsigned long
30
+
31
+ typedef struct { char x; } Char;
32
+ typedef struct { short x; } Short;
33
+ typedef struct { int x; } Int;
34
+ typedef struct { long x; } Long;
35
+ typedef struct { float x; } Float;
36
+ typedef struct { double x; } Double;
37
+ typedef struct { char c; float f; } A;
38
+ typedef struct { double d; int i[3]; } B;
39
+ typedef struct { long l1; long l2; } J;
40
+ typedef struct { long l1; long l2; long l3; long l4; } K;
41
+ typedef struct { long l1; long l2; long l3; long l4; long l5; long l6; } L;
42
+ typedef struct { char x1; } Size1;
43
+ typedef struct { char x1; char x2; } Size2;
44
+ typedef struct { char x1; char x2; char x3; } Size3;
45
+ typedef struct { char x1; char x2; char x3; char x4; } Size4;
46
+ typedef struct {
47
+ char x1; char x2; char x3; char x4; char x5; char x6; char x7;
48
+ } Size7;
49
+ typedef struct {
50
+ char x1; char x2; char x3; char x4; char x5; char x6; char x7; char x8;
51
+ } Size8;
52
+ typedef struct {
53
+ char x1; char x2; char x3; char x4; char x5; char x6; char x7; char x8;
54
+ char x9; char x10; char x11; char x12;
55
+ } Size12;
56
+ typedef struct {
57
+ char x1; char x2; char x3; char x4; char x5; char x6; char x7; char x8;
58
+ char x9; char x10; char x11; char x12; char x13; char x14; char x15;
59
+ } Size15;
60
+ typedef struct {
61
+ char x1; char x2; char x3; char x4; char x5; char x6; char x7; char x8;
62
+ char x9; char x10; char x11; char x12; char x13; char x14; char x15; char x16;
63
+ } Size16;
64
+ typedef struct { char c[3]; } T;
65
+ typedef struct { char c[33],c1; } X;
66
+
67
+ char c1='a', c2=127, c3=(char)128, c4=(char)255, c5=-1;
68
+ short s1=32767, s2=(short)32768, s3=3, s4=4, s5=5, s6=6, s7=7, s8=8, s9=9;
69
+ int i1=1, i2=2, i3=3, i4=4, i5=5, i6=6, i7=7, i8=8, i9=9,
70
+ i10=11, i11=12, i12=13, i13=14, i14=15, i15=16, i16=17;
71
+ long l1=1, l2=2, l3=3, l4=4, l5=5, l6=6, l7=7, l8=8, l9=9;
72
+ long long ll1 = 3875056143130689530LL;
73
+ float f1=0.1f, f2=0.2f, f3=0.3f, f4=0.4f, f5=0.5f, f6=0.6f, f7=0.7f, f8=0.8f, f9=0.9f,
74
+ f10=1.1f, f11=1.2f, f12=1.3f, f13=1.4f, f14=1.5f, f15=1.6f, f16=1.7f, f17=1.8f,
75
+ f18=1.9f, f19=2.1f, f20=2.2f, f21=2.3f, f22=2.4f, f23=2.5f, f24=2.6f;
76
+ double d1=0.1, d2=0.2, d3=0.3, d4=0.4, d5=0.5, d6=0.6, d7=0.7, d8=0.8, d9=0.9,
77
+ d10=1.1, d11=1.2, d12=1.3, d13=1.4, d14=1.5, d15=1.6, d16=1.7, d17=1.8;
78
+
79
+ uchar uc1='a', uc2=127, uc3=128, uc4=255, uc5=(uchar)-1;
80
+ ushort us1=1, us2=2, us3=3, us4=4, us5=5, us6=6, us7=7, us8=8, us9=9;
81
+ uint ui1=1, ui2=2, ui3=3, ui4=4, ui5=5, ui6=6, ui7=7, ui8=8, ui9=9;
82
+ ulong ul1=1, ul2=2, ul3=3, ul4=4, ul5=5, ul6=6, ul7=7, ul8=8, ul9=9;
83
+
84
+ char *str1="hello",str2[]="goodbye",*str3="still here?";
85
+ Char C1={'A'}, C2={'B'}, C3={'C'}, C4={'\377'}, C5={(char)(-1)};
86
+ Short S1={1}, S2={2}, S3={3}, S4={4}, S5={5}, S6={6}, S7={7}, S8={8}, S9={9};
87
+ Int I1={1}, I2={2}, I3={3}, I4={4}, I5={5}, I6={6}, I7={7}, I8={8}, I9={9};
88
+ Float F1={0.1f}, F2={0.2f}, F3={0.3f}, F4={0.4f}, F5={0.5f}, F6={0.6f}, F7={0.7f}, F8={0.8f}, F9={0.9f};
89
+ Double D1={0.1}, D2={0.2}, D3={0.3}, D4={0.4}, D5={0.5}, D6={0.6}, D7={0.7}, D8={0.8}, D9={0.9};
90
+
91
+ A A1={'a',0.1f},A2={'b',0.2f},A3={'\377',0.3f};
92
+ B B1={0.1,{1,2,3}},B2={0.2,{5,4,3}};
93
+ J J1={47,11},J2={73,55};
94
+ K K1={19,69,12,28};
95
+ L L1={561,1105,1729,2465,2821,6601}; /* A002997 */
96
+ Size1 Size1_1={'a'};
97
+ Size2 Size2_1={'a','b'};
98
+ Size3 Size3_1={'a','b','c'};
99
+ Size4 Size4_1={'a','b','c','d'};
100
+ Size7 Size7_1={'a','b','c','d','e','f','g'};
101
+ Size8 Size8_1={'a','b','c','d','e','f','g','h'};
102
+ Size12 Size12_1={'a','b','c','d','e','f','g','h','i','j','k','l'};
103
+ Size15 Size15_1={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o'};
104
+ Size16 Size16_1={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p'};
105
+ T T1={{'t','h','e'}},T2={{'f','o','x'}};
106
+ X X1={"abcdefghijklmnopqrstuvwxyzABCDEF",'G'}, X2={"123",'9'}, X3={"return-return-return",'R'};
107
+
108
+ #if defined(__GNUC__)
109
+ #define __STDCALL__ __attribute__((stdcall))
110
+ #define __THISCALL__ __attribute__((thiscall))
111
+ #define __FASTCALL__ __attribute__((fastcall))
112
+ #define __MSABI__ __attribute__((ms_abi))
113
+ #else
114
+ #define __STDCALL__ __stdcall
115
+ #define __THISCALL__ __thiscall
116
+ #define __FASTCALL__ __fastcall
117
+ #endif
118
+
119
+ #ifndef ABI_ATTR
120
+ #define ABI_ATTR
121
+ #endif
122
+
123
+ /* void tests */
124
+ void ABI_ATTR v_v (void)
125
+ {
126
+ fprintf(out,"void f(void):\n");
127
+ fflush(out);
128
+ }
129
+
130
+ /* int tests */
131
+ int ABI_ATTR i_v (void)
132
+ {
133
+ int r=99;
134
+ fprintf(out,"int f(void):");
135
+ fflush(out);
136
+ return r;
137
+ }
138
+ int ABI_ATTR i_i (int a)
139
+ {
140
+ int r=a+1;
141
+ fprintf(out,"int f(int):(%d)",a);
142
+ fflush(out);
143
+ return r;
144
+ }
145
+ int ABI_ATTR i_i2 (int a, int b)
146
+ {
147
+ int r=a+b;
148
+ fprintf(out,"int f(2*int):(%d,%d)",a,b);
149
+ fflush(out);
150
+ return r;
151
+ }
152
+ int ABI_ATTR i_i4 (int a, int b, int c, int d)
153
+ {
154
+ int r=a+b+c+d;
155
+ fprintf(out,"int f(4*int):(%d,%d,%d,%d)",a,b,c,d);
156
+ fflush(out);
157
+ return r;
158
+ }
159
+ int ABI_ATTR i_i8 (int a, int b, int c, int d, int e, int f, int g, int h)
160
+ {
161
+ int r=a+b+c+d+e+f+g+h;
162
+ fprintf(out,"int f(8*int):(%d,%d,%d,%d,%d,%d,%d,%d)",a,b,c,d,e,f,g,h);
163
+ fflush(out);
164
+ return r;
165
+ }
166
+ int ABI_ATTR i_i16 (int a, int b, int c, int d, int e, int f, int g, int h,
167
+ int i, int j, int k, int l, int m, int n, int o, int p)
168
+ {
169
+ int r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p;
170
+ fprintf(out,"int f(16*int):(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
171
+ a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p);
172
+ fflush(out);
173
+ return r;
174
+ }
175
+
176
+ /* float tests */
177
+ float ABI_ATTR f_f (float a)
178
+ {
179
+ float r=a+1.0f;
180
+ fprintf(out,"float f(float):(%g)",a);
181
+ fflush(out);
182
+ return r;
183
+ }
184
+ float ABI_ATTR f_f2 (float a, float b)
185
+ {
186
+ float r=a+b;
187
+ fprintf(out,"float f(2*float):(%g,%g)",a,b);
188
+ fflush(out);
189
+ return r;
190
+ }
191
+ float ABI_ATTR f_f4 (float a, float b, float c, float d)
192
+ {
193
+ float r=a+b+c+d;
194
+ fprintf(out,"float f(4*float):(%g,%g,%g,%g)",a,b,c,d);
195
+ fflush(out);
196
+ return r;
197
+ }
198
+ float ABI_ATTR f_f8 (float a, float b, float c, float d, float e, float f,
199
+ float g, float h)
200
+ {
201
+ float r=a+b+c+d+e+f+g+h;
202
+ fprintf(out,"float f(8*float):(%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h);
203
+ fflush(out);
204
+ return r;
205
+ }
206
+ float ABI_ATTR f_f16 (float a, float b, float c, float d, float e, float f, float g, float h,
207
+ float i, float j, float k, float l, float m, float n, float o, float p)
208
+ {
209
+ float r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p;
210
+ fprintf(out,"float f(16*float):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p);
211
+ fflush(out);
212
+ return r;
213
+ }
214
+ float ABI_ATTR f_f24 (float a, float b, float c, float d, float e, float f, float g, float h,
215
+ float i, float j, float k, float l, float m, float n, float o, float p,
216
+ float q, float s, float t, float u, float v, float w, float x, float y)
217
+ {
218
+ float r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+s+t+u+v+w+x+y;
219
+ fprintf(out,"float f(24*float):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,v,w,x,y);
220
+ fflush(out);
221
+ return r;
222
+ }
223
+
224
+ /* double tests */
225
+ double ABI_ATTR d_d (double a)
226
+ {
227
+ double r=a+1.0;
228
+ fprintf(out,"double f(double):(%g)",a);
229
+ fflush(out);
230
+ return r;
231
+ }
232
+ double ABI_ATTR d_d2 (double a, double b)
233
+ {
234
+ double r=a+b;
235
+ fprintf(out,"double f(2*double):(%g,%g)",a,b);
236
+ fflush(out);
237
+ return r;
238
+ }
239
+ double ABI_ATTR d_d4 (double a, double b, double c, double d)
240
+ {
241
+ double r=a+b+c+d;
242
+ fprintf(out,"double f(4*double):(%g,%g,%g,%g)",a,b,c,d);
243
+ fflush(out);
244
+ return r;
245
+ }
246
+ double ABI_ATTR d_d8 (double a, double b, double c, double d, double e, double f,
247
+ double g, double h)
248
+ {
249
+ double r=a+b+c+d+e+f+g+h;
250
+ fprintf(out,"double f(8*double):(%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h);
251
+ fflush(out);
252
+ return r;
253
+ }
254
+ double ABI_ATTR d_d16 (double a, double b, double c, double d, double e, double f,
255
+ double g, double h, double i, double j, double k, double l,
256
+ double m, double n, double o, double p)
257
+ {
258
+ double r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p;
259
+ fprintf(out,"double f(16*double):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p);
260
+ fflush(out);
261
+ return r;
262
+ }
263
+
264
+ /* pointer tests */
265
+ void* ABI_ATTR vp_vpdpcpsp (void* a, double* b, char* c, Int* d)
266
+ {
267
+ void* ret = (char*)b + 1;
268
+ fprintf(out,"void* f(void*,double*,char*,Int*):(0x%p,0x%p,0x%p,0x%p)",a,b,c,d);
269
+ fflush(out);
270
+ return ret;
271
+ }
272
+
273
+ /* mixed number tests */
274
+ uchar ABI_ATTR uc_ucsil (uchar a, ushort b, uint c, ulong d)
275
+ {
276
+ uchar r = (uchar)-1;
277
+ fprintf(out,"uchar f(uchar,ushort,uint,ulong):(%u,%u,%u,%lu)",a,b,c,d);
278
+ fflush(out);
279
+ return r;
280
+ }
281
+ double ABI_ATTR d_iidd (int a, int b, double c, double d)
282
+ {
283
+ double r = a+b+c+d;
284
+ fprintf(out,"double f(int,int,double,double):(%d,%d,%g,%g)",a,b,c,d);
285
+ fflush(out);
286
+ return r;
287
+ }
288
+ double ABI_ATTR d_iiidi (int a, int b, int c, double d, int e)
289
+ {
290
+ double r = a+b+c+d+e;
291
+ fprintf(out,"double f(int,int,int,double,int):(%d,%d,%d,%g,%d)",a,b,c,d,e);
292
+ fflush(out);
293
+ return r;
294
+ }
295
+ double ABI_ATTR d_idid (int a, double b, int c, double d)
296
+ {
297
+ double r = a+b+c+d;
298
+ fprintf(out,"double f(int,double,int,double):(%d,%g,%d,%g)",a,b,c,d);
299
+ fflush(out);
300
+ return r;
301
+ }
302
+ double ABI_ATTR d_fdi (float a, double b, int c)
303
+ {
304
+ double r = a+b+c;
305
+ fprintf(out,"double f(float,double,int):(%g,%g,%d)",a,b,c);
306
+ fflush(out);
307
+ return r;
308
+ }
309
+ ushort ABI_ATTR us_cdcd (char a, double b, char c, double d)
310
+ {
311
+ ushort r = (ushort)(a + b + c + d);
312
+ fprintf(out,"ushort f(char,double,char,double):('%c',%g,'%c',%g)",a,b,c,d);
313
+ fflush(out);
314
+ return r;
315
+ }
316
+
317
+ long long ABI_ATTR ll_iiilli (int a, int b, int c, long long d, int e)
318
+ {
319
+ long long r = (long long)(int)a+(long long)(int)b+(long long)(int)c+d+(long long)(int)e;
320
+ fprintf(out,"long long f(int,int,int,long long,int):(%d,%d,%d,0x%lx%08lx,%d)",a,b,c,(long)(d>>32),(long)(d&0xffffffff),e);
321
+ fflush(out);
322
+ return r;
323
+ }
324
+ long long ABI_ATTR ll_flli (float a, long long b, int c)
325
+ {
326
+ long long r = (long long)(int)a + b + (long long)c;
327
+ fprintf(out,"long long f(float,long long,int):(%g,0x%lx%08lx,0x%lx)",a,(long)(b>>32),(long)(b&0xffffffff),(long)c);
328
+ fflush(out);
329
+ return r;
330
+ }
331
+
332
+ float ABI_ATTR f_fi (float a, int z)
333
+ {
334
+ float r = a+z;
335
+ fprintf(out,"float f(float,int):(%g,%d)",a,z);
336
+ fflush(out);
337
+ return r;
338
+ }
339
+ float ABI_ATTR f_f2i (float a, float b, int z)
340
+ {
341
+ float r = a+b+z;
342
+ fprintf(out,"float f(2*float,int):(%g,%g,%d)",a,b,z);
343
+ fflush(out);
344
+ return r;
345
+ }
346
+ float ABI_ATTR f_f3i (float a, float b, float c, int z)
347
+ {
348
+ float r = a+b+c+z;
349
+ fprintf(out,"float f(3*float,int):(%g,%g,%g,%d)",a,b,c,z);
350
+ fflush(out);
351
+ return r;
352
+ }
353
+ float ABI_ATTR f_f4i (float a, float b, float c, float d, int z)
354
+ {
355
+ float r = a+b+c+d+z;
356
+ fprintf(out,"float f(4*float,int):(%g,%g,%g,%g,%d)",a,b,c,d,z);
357
+ fflush(out);
358
+ return r;
359
+ }
360
+ float ABI_ATTR f_f7i (float a, float b, float c, float d, float e, float f, float g,
361
+ int z)
362
+ {
363
+ float r = a+b+c+d+e+f+g+z;
364
+ fprintf(out,"float f(7*float,int):(%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,z);
365
+ fflush(out);
366
+ return r;
367
+ }
368
+ float ABI_ATTR f_f8i (float a, float b, float c, float d, float e, float f, float g,
369
+ float h, int z)
370
+ {
371
+ float r = a+b+c+d+e+f+g+h+z;
372
+ fprintf(out,"float f(8*float,int):(%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,z);
373
+ fflush(out);
374
+ return r;
375
+ }
376
+ float ABI_ATTR f_f12i (float a, float b, float c, float d, float e, float f, float g,
377
+ float h, float i, float j, float k, float l, int z)
378
+ {
379
+ float r = a+b+c+d+e+f+g+h+i+j+k+l+z;
380
+ fprintf(out,"float f(12*float,int):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,i,j,k,l,z);
381
+ fflush(out);
382
+ return r;
383
+ }
384
+ float ABI_ATTR f_f13i (float a, float b, float c, float d, float e, float f, float g,
385
+ float h, float i, float j, float k, float l, float m, int z)
386
+ {
387
+ float r = a+b+c+d+e+f+g+h+i+j+k+l+m+z;
388
+ fprintf(out,"float f(13*float,int):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,i,j,k,l,m,z);
389
+ fflush(out);
390
+ return r;
391
+ }
392
+
393
+ double ABI_ATTR d_di (double a, int z)
394
+ {
395
+ double r = a+z;
396
+ fprintf(out,"double f(double,int):(%g,%d)",a,z);
397
+ fflush(out);
398
+ return r;
399
+ }
400
+ double ABI_ATTR d_d2i (double a, double b, int z)
401
+ {
402
+ double r = a+b+z;
403
+ fprintf(out,"double f(2*double,int):(%g,%g,%d)",a,b,z);
404
+ fflush(out);
405
+ return r;
406
+ }
407
+ double ABI_ATTR d_d3i (double a, double b, double c, int z)
408
+ {
409
+ double r = a+b+c+z;
410
+ fprintf(out,"double f(3*double,int):(%g,%g,%g,%d)",a,b,c,z);
411
+ fflush(out);
412
+ return r;
413
+ }
414
+ double ABI_ATTR d_d4i (double a, double b, double c, double d, int z)
415
+ {
416
+ double r = a+b+c+d+z;
417
+ fprintf(out,"double f(4*double,int):(%g,%g,%g,%g,%d)",a,b,c,d,z);
418
+ fflush(out);
419
+ return r;
420
+ }
421
+ double ABI_ATTR d_d7i (double a, double b, double c, double d, double e, double f,
422
+ double g, int z)
423
+ {
424
+ double r = a+b+c+d+e+f+g+z;
425
+ fprintf(out,"double f(7*double,int):(%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,z);
426
+ fflush(out);
427
+ return r;
428
+ }
429
+ double ABI_ATTR d_d8i (double a, double b, double c, double d, double e, double f,
430
+ double g, double h, int z)
431
+ {
432
+ double r = a+b+c+d+e+f+g+h+z;
433
+ fprintf(out,"double f(8*double,int):(%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,z);
434
+ fflush(out);
435
+ return r;
436
+ }
437
+ double ABI_ATTR d_d12i (double a, double b, double c, double d, double e, double f,
438
+ double g, double h, double i, double j, double k, double l,
439
+ int z)
440
+ {
441
+ double r = a+b+c+d+e+f+g+h+i+j+k+l+z;
442
+ fprintf(out,"double f(12*double,int):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,i,j,k,l,z);
443
+ fflush(out);
444
+ return r;
445
+ }
446
+ double ABI_ATTR d_d13i (double a, double b, double c, double d, double e, double f,
447
+ double g, double h, double i, double j, double k, double l,
448
+ double m, int z)
449
+ {
450
+ double r = a+b+c+d+e+f+g+h+i+j+k+l+m+z;
451
+ fprintf(out,"double f(13*double,int):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%d)",a,b,c,d,e,f,g,h,i,j,k,l,m,z);
452
+ fflush(out);
453
+ return r;
454
+ }
455
+
456
+ /* small structure return tests */
457
+ Size1 ABI_ATTR S1_v (void)
458
+ {
459
+ fprintf(out,"Size1 f(void):");
460
+ fflush(out);
461
+ return Size1_1;
462
+ }
463
+ Size2 ABI_ATTR S2_v (void)
464
+ {
465
+ fprintf(out,"Size2 f(void):");
466
+ fflush(out);
467
+ return Size2_1;
468
+ }
469
+ Size3 ABI_ATTR S3_v (void)
470
+ {
471
+ fprintf(out,"Size3 f(void):");
472
+ fflush(out);
473
+ return Size3_1;
474
+ }
475
+ Size4 ABI_ATTR S4_v (void)
476
+ {
477
+ fprintf(out,"Size4 f(void):");
478
+ fflush(out);
479
+ return Size4_1;
480
+ }
481
+ Size7 ABI_ATTR S7_v (void)
482
+ {
483
+ fprintf(out,"Size7 f(void):");
484
+ fflush(out);
485
+ return Size7_1;
486
+ }
487
+ Size8 ABI_ATTR S8_v (void)
488
+ {
489
+ fprintf(out,"Size8 f(void):");
490
+ fflush(out);
491
+ return Size8_1;
492
+ }
493
+ Size12 ABI_ATTR S12_v (void)
494
+ {
495
+ fprintf(out,"Size12 f(void):");
496
+ fflush(out);
497
+ return Size12_1;
498
+ }
499
+ Size15 ABI_ATTR S15_v (void)
500
+ {
501
+ fprintf(out,"Size15 f(void):");
502
+ fflush(out);
503
+ return Size15_1;
504
+ }
505
+ Size16 ABI_ATTR S16_v (void)
506
+ {
507
+ fprintf(out,"Size16 f(void):");
508
+ fflush(out);
509
+ return Size16_1;
510
+ }
511
+
512
+ /* structure tests */
513
+ Int ABI_ATTR I_III (Int a, Int b, Int c)
514
+ {
515
+ Int r;
516
+ r.x = a.x + b.x + c.x;
517
+ fprintf(out,"Int f(Int,Int,Int):({%d},{%d},{%d})",a.x,b.x,c.x);
518
+ fflush(out);
519
+ return r;
520
+ }
521
+ Char ABI_ATTR C_CdC (Char a, double b, Char c)
522
+ {
523
+ Char r;
524
+ r.x = (a.x + c.x)/2;
525
+ fprintf(out,"Char f(Char,double,Char):({'%c'},%g,{'%c'})",a.x,b,c.x);
526
+ fflush(out);
527
+ return r;
528
+ }
529
+ Float ABI_ATTR F_Ffd (Float a, float b, double c)
530
+ {
531
+ Float r;
532
+ r.x = (float) (a.x + b + c);
533
+ fprintf(out,"Float f(Float,float,double):({%g},%g,%g)",a.x,b,c);
534
+ fflush(out);
535
+ return r;
536
+ }
537
+ Double ABI_ATTR D_fDd (float a, Double b, double c)
538
+ {
539
+ Double r;
540
+ r.x = a + b.x + c;
541
+ fprintf(out,"Double f(float,Double,double):(%g,{%g},%g)",a,b.x,c);
542
+ fflush(out);
543
+ return r;
544
+ }
545
+ Double ABI_ATTR D_Dfd (Double a, float b, double c)
546
+ {
547
+ Double r;
548
+ r.x = a.x + b + c;
549
+ fprintf(out,"Double f(Double,float,double):({%g},%g,%g)",a.x,b,c);
550
+ fflush(out);
551
+ return r;
552
+ }
553
+ J ABI_ATTR J_JiJ (J a, int b, J c)
554
+ {
555
+ J r;
556
+ r.l1 = a.l1+c.l1; r.l2 = a.l2+b+c.l2;
557
+ fprintf(out,"J f(J,int,J):({%ld,%ld},%d,{%ld,%ld})",a.l1,a.l2,b,c.l1,c.l2);
558
+ fflush(out);
559
+ return r;
560
+ }
561
+ T ABI_ATTR T_TcT (T a, char b, T c)
562
+ {
563
+ T r;
564
+ r.c[0]='b'; r.c[1]=c.c[1]; r.c[2]=c.c[2];
565
+ fprintf(out,"T f(T,char,T):({\"%c%c%c\"},'%c',{\"%c%c%c\"})",a.c[0],a.c[1],a.c[2],b,c.c[0],c.c[1],c.c[2]);
566
+ fflush(out);
567
+ return r;
568
+ }
569
+ X ABI_ATTR X_BcdB (B a, char b, double c, B d)
570
+ {
571
+ static X xr={"return val",'R'};
572
+ X r;
573
+ r = xr;
574
+ r.c1 = b;
575
+ fprintf(out,"X f(B,char,double,B):({%g,{%d,%d,%d}},'%c',%g,{%g,{%d,%d,%d}})",
576
+ a.d,a.i[0],a.i[1],a.i[2],b,c,d.d,d.i[0],d.i[1],d.i[2]);
577
+ fflush(out);
578
+ return r;
579
+ }
580
+
581
+ /* Test for cases where some argument (especially structure, 'long long', or
582
+ 'double') may be passed partially in general-purpose argument registers
583
+ and partially on the stack. Different ABIs pass between 4 and 8 arguments
584
+ (or none) in general-purpose argument registers. */
585
+
586
+ long ABI_ATTR l_l0K (K b, long c)
587
+ {
588
+ long r = b.l1 + b.l2 + b.l3 + b.l4 + c;
589
+ fprintf(out,"long f(K,long):(%ld,%ld,%ld,%ld,%ld)",b.l1,b.l2,b.l3,b.l4,c);
590
+ fflush(out);
591
+ return r;
592
+ }
593
+ long ABI_ATTR l_l1K (long a1, K b, long c)
594
+ {
595
+ long r = a1 + b.l1 + b.l2 + b.l3 + b.l4 + c;
596
+ fprintf(out,"long f(long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld)",a1,b.l1,b.l2,b.l3,b.l4,c);
597
+ fflush(out);
598
+ return r;
599
+ }
600
+ long ABI_ATTR l_l2K (long a1, long a2, K b, long c)
601
+ {
602
+ long r = a1 + a2 + b.l1 + b.l2 + b.l3 + b.l4 + c;
603
+ fprintf(out,"long f(2*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,b.l1,b.l2,b.l3,b.l4,c);
604
+ fflush(out);
605
+ return r;
606
+ }
607
+ long ABI_ATTR l_l3K (long a1, long a2, long a3, K b, long c)
608
+ {
609
+ long r = a1 + a2 + a3 + b.l1 + b.l2 + b.l3 + b.l4 + c;
610
+ fprintf(out,"long f(3*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,b.l1,b.l2,b.l3,b.l4,c);
611
+ fflush(out);
612
+ return r;
613
+ }
614
+ long ABI_ATTR l_l4K (long a1, long a2, long a3, long a4, K b, long c)
615
+ {
616
+ long r = a1 + a2 + a3 + a4 + b.l1 + b.l2 + b.l3 + b.l4 + c;
617
+ fprintf(out,"long f(4*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,b.l1,b.l2,b.l3,b.l4,c);
618
+ fflush(out);
619
+ return r;
620
+ }
621
+ long ABI_ATTR l_l5K (long a1, long a2, long a3, long a4, long a5, K b, long c)
622
+ {
623
+ long r = a1 + a2 + a3 + a4 + a5 + b.l1 + b.l2 + b.l3 + b.l4 + c;
624
+ fprintf(out,"long f(5*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,b.l1,b.l2,b.l3,b.l4,c);
625
+ fflush(out);
626
+ return r;
627
+ }
628
+ long ABI_ATTR l_l6K (long a1, long a2, long a3, long a4, long a5, long a6, K b, long c)
629
+ {
630
+ long r = a1 + a2 + a3 + a4 + a5 + a6 + b.l1 + b.l2 + b.l3 + b.l4 + c;
631
+ fprintf(out,"long f(6*long,K,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a1,a2,a3,a4,a5,a6,b.l1,b.l2,b.l3,b.l4,c);
632
+ fflush(out);
633
+ return r;
634
+ }
635
+ /* These tests is crafted on the knowledge that for all known ABIs:
636
+ * 17 > number of floating-point argument registers,
637
+ * 3 < number of general-purpose argument registers < 3 + 6. */
638
+ float ABI_ATTR f_f17l3L (float a, float b, float c, float d, float e, float f, float g,
639
+ float h, float i, float j, float k, float l, float m, float n,
640
+ float o, float p, float q,
641
+ long s, long t, long u, L z)
642
+ {
643
+ float r = a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+s+t+u+z.l1+z.l2+z.l3+z.l4+z.l5+z.l6;
644
+ fprintf(out,"float f(17*float,3*int,L):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,z.l1,z.l2,z.l3,z.l4,z.l5,z.l6);
645
+ fflush(out);
646
+ return r;
647
+ }
648
+ double ABI_ATTR d_d17l3L (double a, double b, double c, double d, double e, double f,
649
+ double g, double h, double i, double j, double k, double l,
650
+ double m, double n, double o, double p, double q,
651
+ long s, long t, long u, L z)
652
+ {
653
+ double r = a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+s+t+u+z.l1+z.l2+z.l3+z.l4+z.l5+z.l6;
654
+ fprintf(out,"double f(17*double,3*int,L):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,z.l1,z.l2,z.l3,z.l4,z.l5,z.l6);
655
+ fflush(out);
656
+ return r;
657
+ }
658
+
659
+ long long ABI_ATTR ll_l2ll (long a1, long a2, long long b, long c)
660
+ {
661
+ long long r = (long long) (a1 + a2) + b + c;
662
+ fprintf(out,"long long f(2*long,long long,long):(%ld,%ld,0x%lx%08lx,%ld)",a1,a2,(long)(b>>32),(long)(b&0xffffffff),c);
663
+ fflush(out);
664
+ return r;
665
+ }
666
+ long long ABI_ATTR ll_l3ll (long a1, long a2, long a3, long long b, long c)
667
+ {
668
+ long long r = (long long) (a1 + a2 + a3) + b + c;
669
+ fprintf(out,"long long f(3*long,long long,long):(%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,(long)(b>>32),(long)(b&0xffffffff),c);
670
+ fflush(out);
671
+ return r;
672
+ }
673
+ long long ABI_ATTR ll_l4ll (long a1, long a2, long a3, long a4, long long b, long c)
674
+ {
675
+ long long r = (long long) (a1 + a2 + a3 + a4) + b + c;
676
+ fprintf(out,"long long f(4*long,long long,long):(%ld,%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,a4,(long)(b>>32),(long)(b&0xffffffff),c);
677
+ fflush(out);
678
+ return r;
679
+ }
680
+ long long ABI_ATTR ll_l5ll (long a1, long a2, long a3, long a4, long a5, long long b, long c)
681
+ {
682
+ long long r = (long long) (a1 + a2 + a3 + a4 + a5) + b + c;
683
+ fprintf(out,"long long f(5*long,long long,long):(%ld,%ld,%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,a4,a5,(long)(b>>32),(long)(b&0xffffffff),c);
684
+ fflush(out);
685
+ return r;
686
+ }
687
+ long long ABI_ATTR ll_l6ll (long a1, long a2, long a3, long a4, long a5, long a6, long long b, long c)
688
+ {
689
+ long long r = (long long) (a1 + a2 + a3 + a4 + a5 + a6) + b + c;
690
+ fprintf(out,"long long f(6*long,long long,long):(%ld,%ld,%ld,%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,a4,a5,a6,(long)(b>>32),(long)(b&0xffffffff),c);
691
+ fflush(out);
692
+ return r;
693
+ }
694
+ long long ABI_ATTR ll_l7ll (long a1, long a2, long a3, long a4, long a5, long a6, long a7, long long b, long c)
695
+ {
696
+ long long r = (long long) (a1 + a2 + a3 + a4 + a5 + a6 + a7) + b + c;
697
+ fprintf(out,"long long f(7*long,long long,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,0x%lx%08lx,%ld)",a1,a2,a3,a4,a5,a6,a7,(long)(b>>32),(long)(b&0xffffffff),c);
698
+ fflush(out);
699
+ return r;
700
+ }
701
+
702
+ double ABI_ATTR d_l2d (long a1, long a2, double b, long c)
703
+ {
704
+ double r = (double) (a1 + a2) + b + c;
705
+ fprintf(out,"double f(2*long,double,long):(%ld,%ld,%g,%ld)",a1,a2,b,c);
706
+ fflush(out);
707
+ return r;
708
+ }
709
+ double ABI_ATTR d_l3d (long a1, long a2, long a3, double b, long c)
710
+ {
711
+ double r = (double) (a1 + a2 + a3) + b + c;
712
+ fprintf(out,"double f(3*long,double,long):(%ld,%ld,%ld,%g,%ld)",a1,a2,a3,b,c);
713
+ fflush(out);
714
+ return r;
715
+ }
716
+ double ABI_ATTR d_l4d (long a1, long a2, long a3, long a4, double b, long c)
717
+ {
718
+ double r = (double) (a1 + a2 + a3 + a4) + b + c;
719
+ fprintf(out,"double f(4*long,double,long):(%ld,%ld,%ld,%ld,%g,%ld)",a1,a2,a3,a4,b,c);
720
+ fflush(out);
721
+ return r;
722
+ }
723
+ double ABI_ATTR d_l5d (long a1, long a2, long a3, long a4, long a5, double b, long c)
724
+ {
725
+ double r = (double) (a1 + a2 + a3 + a4 + a5) + b + c;
726
+ fprintf(out,"double f(5*long,double,long):(%ld,%ld,%ld,%ld,%ld,%g,%ld)",a1,a2,a3,a4,a5,b,c);
727
+ fflush(out);
728
+ return r;
729
+ }
730
+ double ABI_ATTR d_l6d (long a1, long a2, long a3, long a4, long a5, long a6, double b, long c)
731
+ {
732
+ double r = (double) (a1 + a2 + a3 + a4 + a5 + a6) + b + c;
733
+ fprintf(out,"double f(6*long,double,long):(%ld,%ld,%ld,%ld,%ld,%ld,%g,%ld)",a1,a2,a3,a4,a5,a6,b,c);
734
+ fflush(out);
735
+ return r;
736
+ }
737
+ double ABI_ATTR d_l7d (long a1, long a2, long a3, long a4, long a5, long a6, long a7, double b, long c)
738
+ {
739
+ double r = (double) (a1 + a2 + a3 + a4 + a5 + a6 + a7) + b + c;
740
+ fprintf(out,"double f(7*long,double,long):(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%g,%ld)",a1,a2,a3,a4,a5,a6,a7,b,c);
741
+ fflush(out);
742
+ return r;
743
+ }