ffi 1.17.1 → 1.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +8 -0
  4. data/Gemfile +3 -1
  5. data/Rakefile +1 -1
  6. data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +48 -60
  7. data/ext/ffi_c/libffi/Makefile.am +4 -3
  8. data/ext/ffi_c/libffi/Makefile.in +5 -25
  9. data/ext/ffi_c/libffi/README.md +19 -2
  10. data/ext/ffi_c/libffi/acinclude.m4 +6 -0
  11. data/ext/ffi_c/libffi/config.guess +80 -22
  12. data/ext/ffi_c/libffi/config.sub +161 -80
  13. data/ext/ffi_c/libffi/configure +968 -1266
  14. data/ext/ffi_c/libffi/configure.ac +9 -8
  15. data/ext/ffi_c/libffi/configure.host +0 -5
  16. data/ext/ffi_c/libffi/doc/Makefile.in +1 -0
  17. data/ext/ffi_c/libffi/doc/libffi.texi +3 -3
  18. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  19. data/ext/ffi_c/libffi/fficonfig.h.in +9 -9
  20. data/ext/ffi_c/libffi/include/Makefile.in +1 -0
  21. data/ext/ffi_c/libffi/include/ffi_cfi.h +2 -0
  22. data/ext/ffi_c/libffi/include/ffi_common.h +17 -0
  23. data/ext/ffi_c/libffi/man/Makefile.in +1 -0
  24. data/ext/ffi_c/libffi/src/aarch64/ffi.c +7 -4
  25. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +2 -2
  26. data/ext/ffi_c/libffi/src/aarch64/internal.h +63 -17
  27. data/ext/ffi_c/libffi/src/aarch64/sysv.S +16 -12
  28. data/ext/ffi_c/libffi/src/arc/arcompact.S +2 -2
  29. data/ext/ffi_c/libffi/src/arc/ffi.c +6 -2
  30. data/ext/ffi_c/libffi/src/closures.c +3 -3
  31. data/ext/ffi_c/libffi/src/dlmalloc.c +1 -0
  32. data/ext/ffi_c/libffi/src/mips/ffitarget.h +2 -4
  33. data/ext/ffi_c/libffi/src/mips/n32.S +4 -0
  34. data/ext/ffi_c/libffi/src/mips/o32.S +4 -0
  35. data/ext/ffi_c/libffi/src/or1k/ffi.c +2 -2
  36. data/ext/ffi_c/libffi/src/powerpc/ffi.c +13 -0
  37. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +26 -19
  38. data/ext/ffi_c/libffi/src/powerpc/ffi_sysv.c +26 -16
  39. data/ext/ffi_c/libffi/src/powerpc/internal.h +10 -0
  40. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +47 -0
  41. data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +24 -0
  42. data/ext/ffi_c/libffi/src/prep_cif.c +1 -4
  43. data/ext/ffi_c/libffi/src/s390/ffi.c +28 -1
  44. data/ext/ffi_c/libffi/src/s390/internal.h +11 -0
  45. data/ext/ffi_c/libffi/src/s390/sysv.S +38 -0
  46. data/ext/ffi_c/libffi/src/sparc/ffi.c +16 -0
  47. data/ext/ffi_c/libffi/src/wasm32/ffi.c +10 -262
  48. data/ext/ffi_c/libffi/src/x86/ffi.c +4 -1
  49. data/ext/ffi_c/libffi/src/x86/ffi64.c +4 -1
  50. data/ext/ffi_c/libffi/testsuite/Makefile.am +4 -3
  51. data/ext/ffi_c/libffi/testsuite/Makefile.in +5 -3
  52. data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +4 -24
  53. data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +8 -25
  54. data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +3 -28
  55. data/ext/ffi_c/libffi/testsuite/libffi.call/callback.c +2 -2
  56. data/ext/ffi_c/libffi/testsuite/libffi.call/callback2.c +2 -2
  57. data/ext/ffi_c/libffi/testsuite/libffi.call/callback3.c +2 -2
  58. data/ext/ffi_c/libffi/testsuite/libffi.call/callback4.c +2 -2
  59. data/ext/ffi_c/libffi/testsuite/libffi.call/overread.c +54 -0
  60. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_int_float.c +88 -0
  61. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +1 -0
  62. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +1 -0
  63. data/ext/ffi_c/libffi/testsuite/libffi.call/x32.c +31 -0
  64. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshortchar.c +1 -1
  65. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushortchar.c +1 -1
  66. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_int.c +1 -1
  67. data/lib/ffi/version.rb +1 -1
  68. data.tar.gz.sig +0 -0
  69. metadata +6 -6
  70. metadata.gz.sig +0 -0
  71. data/ext/ffi_c/libffi/.circleci/config.yml +0 -156
  72. data/ext/ffi_c/libffi/src/nios2/ffi.c +0 -304
  73. data/ext/ffi_c/libffi/src/nios2/ffitarget.h +0 -52
  74. data/ext/ffi_c/libffi/src/nios2/sysv.S +0 -136
@@ -1,304 +0,0 @@
1
- /* libffi support for Altera Nios II.
2
-
3
- Copyright (c) 2013 Mentor Graphics.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- ``Software''), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
23
-
24
-
25
- #include <ffi.h>
26
- #include <ffi_common.h>
27
-
28
- #include <stdlib.h>
29
-
30
- /* The Nios II Processor Reference Handbook defines the procedure call
31
- ABI as follows.
32
-
33
- Arguments are passed as if a structure containing the types of
34
- the arguments were constructed. The first 16 bytes are passed in r4
35
- through r7, the remainder on the stack. The first 16 bytes of a function
36
- taking variable arguments are passed in r4-r7 in the same way.
37
-
38
- Return values of types up to 8 bytes are returned in r2 and r3. For
39
- return values greater than 8 bytes, the caller must allocate memory for
40
- the result and pass the address as if it were argument 0.
41
-
42
- While this isn't specified explicitly in the ABI documentation, GCC
43
- promotes integral arguments smaller than int size to 32 bits.
44
-
45
- Also of note, the ABI specifies that all structure objects are
46
- aligned to 32 bits even if all their fields have a smaller natural
47
- alignment. See FFI_AGGREGATE_ALIGNMENT. */
48
-
49
-
50
- /* Declare the assembly language hooks. */
51
-
52
- extern UINT64 ffi_call_sysv (void (*) (char *, extended_cif *),
53
- extended_cif *,
54
- unsigned,
55
- void (*fn) (void));
56
- extern void ffi_closure_sysv (void);
57
-
58
- /* Perform machine-dependent cif processing. */
59
-
60
- ffi_status ffi_prep_cif_machdep (ffi_cif *cif)
61
- {
62
- /* We always want at least 16 bytes in the parameter block since it
63
- simplifies the low-level call function. Also round the parameter
64
- block size up to a multiple of 4 bytes to preserve
65
- 32-bit alignment of the stack pointer. */
66
- if (cif->bytes < 16)
67
- cif->bytes = 16;
68
- else
69
- cif->bytes = (cif->bytes + 3) & ~3;
70
-
71
- return FFI_OK;
72
- }
73
-
74
-
75
- /* ffi_prep_args is called by the assembly routine to transfer arguments
76
- to the stack using the pointers in the ecif array.
77
- Note that the stack buffer is big enough to fit all the arguments,
78
- but the first 16 bytes will be copied to registers for the actual
79
- call. */
80
-
81
- void ffi_prep_args (char *stack, extended_cif *ecif)
82
- {
83
- char *argp = stack;
84
- unsigned int i;
85
-
86
- /* The implicit return value pointer is passed as if it were a hidden
87
- first argument. */
88
- if (ecif->cif->rtype->type == FFI_TYPE_STRUCT
89
- && ecif->cif->rtype->size > 8)
90
- {
91
- (*(void **) argp) = ecif->rvalue;
92
- argp += 4;
93
- }
94
-
95
- for (i = 0; i < ecif->cif->nargs; i++)
96
- {
97
- void *avalue = ecif->avalue[i];
98
- ffi_type *atype = ecif->cif->arg_types[i];
99
- size_t size = atype->size;
100
- size_t alignment = atype->alignment;
101
-
102
- /* Align argp as appropriate for the argument type. */
103
- if ((alignment - 1) & (unsigned) argp)
104
- argp = (char *) FFI_ALIGN (argp, alignment);
105
-
106
- /* Copy the argument, promoting integral types smaller than a
107
- word to word size. */
108
- if (size < sizeof (int))
109
- {
110
- size = sizeof (int);
111
- switch (atype->type)
112
- {
113
- case FFI_TYPE_SINT8:
114
- *(signed int *) argp = (signed int) *(SINT8 *) avalue;
115
- break;
116
-
117
- case FFI_TYPE_UINT8:
118
- *(unsigned int *) argp = (unsigned int) *(UINT8 *) avalue;
119
- break;
120
-
121
- case FFI_TYPE_SINT16:
122
- *(signed int *) argp = (signed int) *(SINT16 *) avalue;
123
- break;
124
-
125
- case FFI_TYPE_UINT16:
126
- *(unsigned int *) argp = (unsigned int) *(UINT16 *) avalue;
127
- break;
128
-
129
- case FFI_TYPE_STRUCT:
130
- memcpy (argp, avalue, atype->size);
131
- break;
132
-
133
- default:
134
- FFI_ASSERT(0);
135
- }
136
- }
137
- else if (size == sizeof (int))
138
- *(unsigned int *) argp = (unsigned int) *(UINT32 *) avalue;
139
- else
140
- memcpy (argp, avalue, size);
141
- argp += size;
142
- }
143
- }
144
-
145
-
146
- /* Call FN using the prepared CIF. RVALUE points to space allocated by
147
- the caller for the return value, and AVALUE is an array of argument
148
- pointers. */
149
-
150
- void ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue)
151
- {
152
-
153
- extended_cif ecif;
154
- UINT64 result;
155
-
156
- /* If bigret is true, this is the case where a return value of larger
157
- than 8 bytes is handled by being passed by reference as an implicit
158
- argument. */
159
- int bigret = (cif->rtype->type == FFI_TYPE_STRUCT
160
- && cif->rtype->size > 8);
161
-
162
- ecif.cif = cif;
163
- ecif.avalue = avalue;
164
-
165
- /* Allocate space for return value if this is the pass-by-reference case
166
- and the caller did not provide a buffer. */
167
- if (rvalue == NULL && bigret)
168
- ecif.rvalue = alloca (cif->rtype->size);
169
- else
170
- ecif.rvalue = rvalue;
171
-
172
- result = ffi_call_sysv (ffi_prep_args, &ecif, cif->bytes, fn);
173
-
174
- /* Now result contains the 64 bit contents returned from fn in
175
- r2 and r3. Copy the value of the appropriate size to the user-provided
176
- rvalue buffer. */
177
- if (rvalue && !bigret)
178
- switch (cif->rtype->size)
179
- {
180
- case 1:
181
- *(UINT8 *)rvalue = (UINT8) result;
182
- break;
183
- case 2:
184
- *(UINT16 *)rvalue = (UINT16) result;
185
- break;
186
- case 4:
187
- *(UINT32 *)rvalue = (UINT32) result;
188
- break;
189
- case 8:
190
- *(UINT64 *)rvalue = (UINT64) result;
191
- break;
192
- default:
193
- memcpy (rvalue, (void *)&result, cif->rtype->size);
194
- break;
195
- }
196
- }
197
-
198
- /* This function is invoked from the closure trampoline to invoke
199
- CLOSURE with argument block ARGS. Parse ARGS according to
200
- CLOSURE->cfi and invoke CLOSURE->fun. */
201
-
202
- static UINT64
203
- ffi_closure_helper (unsigned char *args,
204
- ffi_closure *closure)
205
- {
206
- ffi_cif *cif = closure->cif;
207
- unsigned char *argp = args;
208
- void **parsed_args = alloca (cif->nargs * sizeof (void *));
209
- UINT64 result;
210
- void *retptr;
211
- unsigned int i;
212
-
213
- /* First figure out what to do about the return type. If this is the
214
- big-structure-return case, the first arg is the hidden return buffer
215
- allocated by the caller. */
216
- if (cif->rtype->type == FFI_TYPE_STRUCT
217
- && cif->rtype->size > 8)
218
- {
219
- retptr = *((void **) argp);
220
- argp += 4;
221
- }
222
- else
223
- retptr = (void *) &result;
224
-
225
- /* Fill in the array of argument pointers. */
226
- for (i = 0; i < cif->nargs; i++)
227
- {
228
- size_t size = cif->arg_types[i]->size;
229
- size_t alignment = cif->arg_types[i]->alignment;
230
-
231
- /* Align argp as appropriate for the argument type. */
232
- if ((alignment - 1) & (unsigned) argp)
233
- argp = (char *) FFI_ALIGN (argp, alignment);
234
-
235
- /* Arguments smaller than an int are promoted to int. */
236
- if (size < sizeof (int))
237
- size = sizeof (int);
238
-
239
- /* Store the pointer. */
240
- parsed_args[i] = argp;
241
- argp += size;
242
- }
243
-
244
- /* Call the user-supplied function. */
245
- (closure->fun) (cif, retptr, parsed_args, closure->user_data);
246
- return result;
247
- }
248
-
249
-
250
- /* Initialize CLOSURE with a trampoline to call FUN with
251
- CIF and USER_DATA. */
252
- ffi_status
253
- ffi_prep_closure_loc (ffi_closure* closure,
254
- ffi_cif* cif,
255
- void (*fun) (ffi_cif*, void*, void**, void*),
256
- void *user_data,
257
- void *codeloc)
258
- {
259
- unsigned int *tramp = (unsigned int *) &closure->tramp[0];
260
- int i;
261
-
262
- if (cif->abi != FFI_SYSV)
263
- return FFI_BAD_ABI;
264
-
265
- /* The trampoline looks like:
266
- movhi r8, %hi(ffi_closure_sysv)
267
- ori r8, r8, %lo(ffi_closure_sysv)
268
- movhi r9, %hi(ffi_closure_helper)
269
- ori r0, r9, %lo(ffi_closure_helper)
270
- movhi r10, %hi(closure)
271
- ori r10, r10, %lo(closure)
272
- jmp r8
273
- and then ffi_closure_sysv retrieves the closure pointer out of r10
274
- in addition to the arguments passed in the normal way for the call,
275
- and invokes ffi_closure_helper. We encode the pointer to
276
- ffi_closure_helper in the trampoline because making a PIC call
277
- to it in ffi_closure_sysv would be messy (it would have to indirect
278
- through the GOT). */
279
-
280
- #define HI(x) ((((unsigned int) (x)) >> 16) & 0xffff)
281
- #define LO(x) (((unsigned int) (x)) & 0xffff)
282
- tramp[0] = (0 << 27) | (8 << 22) | (HI (ffi_closure_sysv) << 6) | 0x34;
283
- tramp[1] = (8 << 27) | (8 << 22) | (LO (ffi_closure_sysv) << 6) | 0x14;
284
- tramp[2] = (0 << 27) | (9 << 22) | (HI (ffi_closure_helper) << 6) | 0x34;
285
- tramp[3] = (9 << 27) | (9 << 22) | (LO (ffi_closure_helper) << 6) | 0x14;
286
- tramp[4] = (0 << 27) | (10 << 22) | (HI (closure) << 6) | 0x34;
287
- tramp[5] = (10 << 27) | (10 << 22) | (LO (closure) << 6) | 0x14;
288
- tramp[6] = (8 << 27) | (0x0d << 11) | 0x3a;
289
- #undef HI
290
- #undef LO
291
-
292
- /* Flush the caches.
293
- See Example 9-4 in the Nios II Software Developer's Handbook. */
294
- for (i = 0; i < 7; i++)
295
- asm volatile ("flushd 0(%0); flushi %0" :: "r"(tramp + i) : "memory");
296
- asm volatile ("flushp" ::: "memory");
297
-
298
- closure->cif = cif;
299
- closure->fun = fun;
300
- closure->user_data = user_data;
301
-
302
- return FFI_OK;
303
- }
304
-
@@ -1,52 +0,0 @@
1
- /* libffi target includes for Altera Nios II.
2
-
3
- Copyright (c) 2013 Mentor Graphics.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- ``Software''), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
23
-
24
-
25
- #ifndef LIBFFI_TARGET_H
26
- #define LIBFFI_TARGET_H
27
-
28
- #ifndef LIBFFI_H
29
- #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
30
- #endif
31
-
32
- #ifndef LIBFFI_ASM
33
- typedef unsigned long ffi_arg;
34
- typedef signed long ffi_sarg;
35
-
36
- typedef enum ffi_abi {
37
- FFI_FIRST_ABI = 0,
38
- FFI_SYSV,
39
- FFI_LAST_ABI,
40
- FFI_DEFAULT_ABI = FFI_SYSV
41
- } ffi_abi;
42
- #endif
43
-
44
- /* Structures have a 4-byte alignment even if all the fields have lesser
45
- alignment requirements. */
46
- #define FFI_AGGREGATE_ALIGNMENT 4
47
-
48
- #define FFI_CLOSURES 1
49
- #define FFI_TRAMPOLINE_SIZE 28 /* 7 instructions */
50
- #define FFI_NATIVE_RAW_API 0
51
-
52
- #endif
@@ -1,136 +0,0 @@
1
- /* Low-level libffi support for Altera Nios II.
2
-
3
- Copyright (c) 2013 Mentor Graphics.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- ``Software''), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
23
-
24
- /* This function is declared on the C side as
25
-
26
- extern UINT64 ffi_call_sysv (void (*arghook) (char *, extended_cif *),
27
- extended_cif *ecif,
28
- unsigned nbytes,
29
- void (*fn) (void));
30
-
31
- On input, the arguments appear as
32
- r4 = arghook
33
- r5 = ecif
34
- r6 = nbytes
35
- r7 = fn
36
- */
37
-
38
- .section .text
39
- .align 2
40
- .global ffi_call_sysv
41
- .type ffi_call_sysv, @function
42
-
43
- ffi_call_sysv:
44
- .cfi_startproc
45
-
46
- /* Create the stack frame, saving r16 so we can use it locally. */
47
- addi sp, sp, -12
48
- .cfi_def_cfa_offset 12
49
- stw ra, 8(sp)
50
- stw fp, 4(sp)
51
- stw r16, 0(sp)
52
- .cfi_offset 31, -4
53
- .cfi_offset 28, -8
54
- .cfi_offset 16, -12
55
- mov fp, sp
56
- .cfi_def_cfa_register 28
57
- mov r16, r7
58
-
59
- /* Adjust the stack pointer to create the argument buffer
60
- nbytes long. */
61
- sub sp, sp, r6
62
-
63
- /* Call the arghook function. */
64
- mov r2, r4 /* fn */
65
- mov r4, sp /* argbuffer */
66
- callr r2 /* r5 already contains ecif */
67
-
68
- /* Pop off the first 16 bytes of the argument buffer on the stack,
69
- transferring the contents to the argument registers. */
70
- ldw r4, 0(sp)
71
- ldw r5, 4(sp)
72
- ldw r6, 8(sp)
73
- ldw r7, 12(sp)
74
- addi sp, sp, 16
75
-
76
- /* Call the user function, which leaves its result in r2 and r3. */
77
- callr r16
78
-
79
- /* Pop off the stack frame. */
80
- mov sp, fp
81
- ldw ra, 8(sp)
82
- ldw fp, 4(sp)
83
- ldw r16, 0(sp)
84
- addi sp, sp, 12
85
- ret
86
- .cfi_endproc
87
- .size ffi_call_sysv, .-ffi_call_sysv
88
-
89
-
90
- /* Closure trampolines jump here after putting the C helper address
91
- in r9 and the closure pointer in r10. The user-supplied arguments
92
- to the closure are in the normal places, in r4-r7 and on the
93
- stack. Push the register arguments on the stack too and then call the
94
- C helper function to deal with them. */
95
-
96
- .section .text
97
- .align 2
98
- .global ffi_closure_sysv
99
- .type ffi_closure_sysv, @function
100
-
101
- ffi_closure_sysv:
102
- .cfi_startproc
103
-
104
- /* Create the stack frame, pushing the register args on the stack
105
- just below the stack args. This is the same trick illustrated
106
- in Figure 7-3 in the Nios II Processor Reference Handbook, used
107
- for variable arguments and structures passed by value. */
108
- addi sp, sp, -20
109
- .cfi_def_cfa_offset 20
110
- stw ra, 0(sp)
111
- .cfi_offset 31, -20
112
- stw r4, 4(sp)
113
- .cfi_offset 4, -16
114
- stw r5, 8(sp)
115
- .cfi_offset 5, -12
116
- stw r6, 12(sp)
117
- .cfi_offset 6, -8
118
- stw r7, 16(sp)
119
- .cfi_offset 7, -4
120
-
121
- /* Call the helper.
122
- r4 = pointer to arguments on stack
123
- r5 = closure pointer (loaded in r10 by the trampoline)
124
- r9 = address of helper function (loaded by trampoline) */
125
- addi r4, sp, 4
126
- mov r5, r10
127
- callr r9
128
-
129
- /* Pop the stack and return. */
130
- ldw ra, 0(sp)
131
- addi sp, sp, 20
132
- .cfi_def_cfa_offset -20
133
- ret
134
- .cfi_endproc
135
- .size ffi_closure_sysv, .-ffi_closure_sysv
136
-