Imported File#ftype spec from rubyspecs.
[rbx.git] / shotgun / external_libs / libffi / src / powerpc / ffi.c
blobe6b869f8737c9c287cee20ca5f5a366c0c0156ba
1 /* -----------------------------------------------------------------------
2 ffi.c - Copyright (c) 1998 Geoffrey Keating
3 Copyright (C) 2007 Free Software Foundation, Inc
5 PowerPC Foreign Function Interface
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the
9 ``Software''), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
15 The above copyright notice and this permission notice shall be included
16 in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 OTHER DEALINGS IN THE SOFTWARE.
25 ----------------------------------------------------------------------- */
27 #include <ffi.h>
28 #include <ffi_common.h>
30 #include <stdlib.h>
31 #include <stdio.h>
34 extern void ffi_closure_SYSV (void);
35 extern void FFI_HIDDEN ffi_closure_LINUX64 (void);
37 enum {
38 /* The assembly depends on these exact flags. */
39 FLAG_RETURNS_SMST = 1 << (31-31), /* Used for FFI_SYSV small structs. */
40 FLAG_RETURNS_NOTHING = 1 << (31-30), /* These go in cr7 */
41 FLAG_RETURNS_FP = 1 << (31-29),
42 FLAG_RETURNS_64BITS = 1 << (31-28),
44 FLAG_RETURNS_128BITS = 1 << (31-27), /* cr6 */
46 FLAG_ARG_NEEDS_COPY = 1 << (31- 7),
47 FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */
48 FLAG_4_GPR_ARGUMENTS = 1 << (31- 5),
49 FLAG_RETVAL_REFERENCE = 1 << (31- 4)
52 /* About the SYSV ABI. */
53 unsigned int NUM_GPR_ARG_REGISTERS = 8;
54 #ifndef __NO_FPRS__
55 unsigned int NUM_FPR_ARG_REGISTERS = 8;
56 #else
57 unsigned int NUM_FPR_ARG_REGISTERS = 0;
58 #endif
60 enum { ASM_NEEDS_REGISTERS = 4 };
62 /* ffi_prep_args_SYSV is called by the assembly routine once stack space
63 has been allocated for the function's arguments.
65 The stack layout we want looks like this:
67 | Return address from ffi_call_SYSV 4bytes | higher addresses
68 |--------------------------------------------|
69 | Previous backchain pointer 4 | stack pointer here
70 |--------------------------------------------|<+ <<< on entry to
71 | Saved r28-r31 4*4 | | ffi_call_SYSV
72 |--------------------------------------------| |
73 | GPR registers r3-r10 8*4 | | ffi_call_SYSV
74 |--------------------------------------------| |
75 | FPR registers f1-f8 (optional) 8*8 | |
76 |--------------------------------------------| | stack |
77 | Space for copied structures | | grows |
78 |--------------------------------------------| | down V
79 | Parameters that didn't fit in registers | |
80 |--------------------------------------------| | lower addresses
81 | Space for callee's LR 4 | |
82 |--------------------------------------------| | stack pointer here
83 | Current backchain pointer 4 |-/ during
84 |--------------------------------------------| <<< ffi_call_SYSV
88 void
89 ffi_prep_args_SYSV (extended_cif *ecif, unsigned *const stack)
91 const unsigned bytes = ecif->cif->bytes;
92 const unsigned flags = ecif->cif->flags;
94 typedef union {
95 char *c;
96 unsigned *u;
97 long long *ll;
98 float *f;
99 double *d;
100 } valp;
102 /* 'stacktop' points at the previous backchain pointer. */
103 valp stacktop;
105 /* 'gpr_base' points at the space for gpr3, and grows upwards as
106 we use GPR registers. */
107 valp gpr_base;
108 int intarg_count;
110 /* 'fpr_base' points at the space for fpr1, and grows upwards as
111 we use FPR registers. */
112 valp fpr_base;
113 int fparg_count;
115 /* 'copy_space' grows down as we put structures in it. It should
116 stay 16-byte aligned. */
117 valp copy_space;
119 /* 'next_arg' grows up as we put parameters in it. */
120 valp next_arg;
122 int i, ii MAYBE_UNUSED;
123 ffi_type **ptr;
124 double double_tmp;
125 union {
126 void **v;
127 char **c;
128 signed char **sc;
129 unsigned char **uc;
130 signed short **ss;
131 unsigned short **us;
132 unsigned int **ui;
133 long long **ll;
134 float **f;
135 double **d;
136 } p_argv;
137 size_t struct_copy_size;
138 unsigned gprvalue;
140 if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT)
141 NUM_FPR_ARG_REGISTERS = 0;
143 stacktop.c = (char *) stack + bytes;
144 gpr_base.u = stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS;
145 intarg_count = 0;
146 fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS;
147 fparg_count = 0;
148 copy_space.c = ((flags & FLAG_FP_ARGUMENTS) ? fpr_base.c : gpr_base.c);
149 next_arg.u = stack + 2;
151 /* Check that everything starts aligned properly. */
152 FFI_ASSERT (((unsigned) (char *) stack & 0xF) == 0);
153 FFI_ASSERT (((unsigned) copy_space.c & 0xF) == 0);
154 FFI_ASSERT (((unsigned) stacktop.c & 0xF) == 0);
155 FFI_ASSERT ((bytes & 0xF) == 0);
156 FFI_ASSERT (copy_space.c >= next_arg.c);
158 /* Deal with return values that are actually pass-by-reference. */
159 if (flags & FLAG_RETVAL_REFERENCE)
161 *gpr_base.u++ = (unsigned long) (char *) ecif->rvalue;
162 intarg_count++;
165 /* Now for the arguments. */
166 p_argv.v = ecif->avalue;
167 for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
168 i > 0;
169 i--, ptr++, p_argv.v++)
171 switch ((*ptr)->type)
173 case FFI_TYPE_FLOAT:
174 /* With FFI_LINUX_SOFT_FLOAT floats are handled like UINT32. */
175 if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT)
176 goto soft_float_prep;
177 double_tmp = **p_argv.f;
178 if (fparg_count >= NUM_FPR_ARG_REGISTERS)
180 *next_arg.f = (float) double_tmp;
181 next_arg.u += 1;
183 else
184 *fpr_base.d++ = double_tmp;
185 fparg_count++;
186 FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
187 break;
189 case FFI_TYPE_DOUBLE:
190 /* With FFI_LINUX_SOFT_FLOAT doubles are handled like UINT64. */
191 if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT)
192 goto soft_double_prep;
193 double_tmp = **p_argv.d;
195 if (fparg_count >= NUM_FPR_ARG_REGISTERS)
197 if (intarg_count >= NUM_GPR_ARG_REGISTERS
198 && intarg_count % 2 != 0)
200 intarg_count++;
201 next_arg.u++;
203 *next_arg.d = double_tmp;
204 next_arg.u += 2;
206 else
207 *fpr_base.d++ = double_tmp;
208 fparg_count++;
209 FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
210 break;
212 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
213 case FFI_TYPE_LONGDOUBLE:
214 if ((ecif->cif->abi != FFI_LINUX)
215 && (ecif->cif->abi != FFI_LINUX_SOFT_FLOAT))
216 goto do_struct;
217 /* The soft float ABI for long doubles works like this,
218 a long double is passed in four consecutive gprs if available.
219 A maximum of 2 long doubles can be passed in gprs.
220 If we do not have 4 gprs left, the long double is passed on the
221 stack, 4-byte aligned. */
222 if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT)
224 unsigned int int_tmp = (*p_argv.ui)[0];
225 if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3)
227 if (intarg_count < NUM_GPR_ARG_REGISTERS)
228 intarg_count += NUM_GPR_ARG_REGISTERS - intarg_count;
229 *next_arg.u = int_tmp;
230 next_arg.u++;
231 for (ii = 1; ii < 4; ii++)
233 int_tmp = (*p_argv.ui)[ii];
234 *next_arg.u = int_tmp;
235 next_arg.u++;
238 else
240 *gpr_base.u++ = int_tmp;
241 for (ii = 1; ii < 4; ii++)
243 int_tmp = (*p_argv.ui)[ii];
244 *gpr_base.u++ = int_tmp;
247 intarg_count +=4;
249 else
251 double_tmp = (*p_argv.d)[0];
253 if (fparg_count >= NUM_FPR_ARG_REGISTERS - 1)
255 if (intarg_count >= NUM_GPR_ARG_REGISTERS
256 && intarg_count % 2 != 0)
258 intarg_count++;
259 next_arg.u++;
261 *next_arg.d = double_tmp;
262 next_arg.u += 2;
263 double_tmp = (*p_argv.d)[1];
264 *next_arg.d = double_tmp;
265 next_arg.u += 2;
267 else
269 *fpr_base.d++ = double_tmp;
270 double_tmp = (*p_argv.d)[1];
271 *fpr_base.d++ = double_tmp;
274 fparg_count += 2;
275 FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
277 break;
278 #endif
280 case FFI_TYPE_UINT64:
281 case FFI_TYPE_SINT64:
282 soft_double_prep:
283 if (intarg_count == NUM_GPR_ARG_REGISTERS-1)
284 intarg_count++;
285 if (intarg_count >= NUM_GPR_ARG_REGISTERS)
287 if (intarg_count % 2 != 0)
289 intarg_count++;
290 next_arg.u++;
292 *next_arg.ll = **p_argv.ll;
293 next_arg.u += 2;
295 else
297 /* whoops: abi states only certain register pairs
298 * can be used for passing long long int
299 * specifically (r3,r4), (r5,r6), (r7,r8),
300 * (r9,r10) and if next arg is long long but
301 * not correct starting register of pair then skip
302 * until the proper starting register
304 if (intarg_count % 2 != 0)
306 intarg_count ++;
307 gpr_base.u++;
309 *gpr_base.ll++ = **p_argv.ll;
311 intarg_count += 2;
312 break;
314 case FFI_TYPE_STRUCT:
315 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
316 do_struct:
317 #endif
318 struct_copy_size = ((*ptr)->size + 15) & ~0xF;
319 copy_space.c -= struct_copy_size;
320 memcpy (copy_space.c, *p_argv.c, (*ptr)->size);
322 gprvalue = (unsigned long) copy_space.c;
324 FFI_ASSERT (copy_space.c > next_arg.c);
325 FFI_ASSERT (flags & FLAG_ARG_NEEDS_COPY);
326 goto putgpr;
328 case FFI_TYPE_UINT8:
329 gprvalue = **p_argv.uc;
330 goto putgpr;
331 case FFI_TYPE_SINT8:
332 gprvalue = **p_argv.sc;
333 goto putgpr;
334 case FFI_TYPE_UINT16:
335 gprvalue = **p_argv.us;
336 goto putgpr;
337 case FFI_TYPE_SINT16:
338 gprvalue = **p_argv.ss;
339 goto putgpr;
341 case FFI_TYPE_INT:
342 case FFI_TYPE_UINT32:
343 case FFI_TYPE_SINT32:
344 case FFI_TYPE_POINTER:
345 soft_float_prep:
347 gprvalue = **p_argv.ui;
349 putgpr:
350 if (intarg_count >= NUM_GPR_ARG_REGISTERS)
351 *next_arg.u++ = gprvalue;
352 else
353 *gpr_base.u++ = gprvalue;
354 intarg_count++;
355 break;
359 /* Check that we didn't overrun the stack... */
360 FFI_ASSERT (copy_space.c >= next_arg.c);
361 FFI_ASSERT (gpr_base.u <= stacktop.u - ASM_NEEDS_REGISTERS);
362 FFI_ASSERT (fpr_base.u
363 <= stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS);
364 FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4);
367 /* About the LINUX64 ABI. */
368 enum {
369 NUM_GPR_ARG_REGISTERS64 = 8,
370 NUM_FPR_ARG_REGISTERS64 = 13
372 enum { ASM_NEEDS_REGISTERS64 = 4 };
374 /* ffi_prep_args64 is called by the assembly routine once stack space
375 has been allocated for the function's arguments.
377 The stack layout we want looks like this:
379 | Ret addr from ffi_call_LINUX64 8bytes | higher addresses
380 |--------------------------------------------|
381 | CR save area 8bytes |
382 |--------------------------------------------|
383 | Previous backchain pointer 8 | stack pointer here
384 |--------------------------------------------|<+ <<< on entry to
385 | Saved r28-r31 4*8 | | ffi_call_LINUX64
386 |--------------------------------------------| |
387 | GPR registers r3-r10 8*8 | |
388 |--------------------------------------------| |
389 | FPR registers f1-f13 (optional) 13*8 | |
390 |--------------------------------------------| |
391 | Parameter save area | |
392 |--------------------------------------------| |
393 | TOC save area 8 | |
394 |--------------------------------------------| | stack |
395 | Linker doubleword 8 | | grows |
396 |--------------------------------------------| | down V
397 | Compiler doubleword 8 | |
398 |--------------------------------------------| | lower addresses
399 | Space for callee's LR 8 | |
400 |--------------------------------------------| |
401 | CR save area 8 | |
402 |--------------------------------------------| | stack pointer here
403 | Current backchain pointer 8 |-/ during
404 |--------------------------------------------| <<< ffi_call_LINUX64
408 void FFI_HIDDEN
409 ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
411 const unsigned long bytes = ecif->cif->bytes;
412 const unsigned long flags = ecif->cif->flags;
414 typedef union {
415 char *c;
416 unsigned long *ul;
417 float *f;
418 double *d;
419 } valp;
421 /* 'stacktop' points at the previous backchain pointer. */
422 valp stacktop;
424 /* 'next_arg' points at the space for gpr3, and grows upwards as
425 we use GPR registers, then continues at rest. */
426 valp gpr_base;
427 valp gpr_end;
428 valp rest;
429 valp next_arg;
431 /* 'fpr_base' points at the space for fpr3, and grows upwards as
432 we use FPR registers. */
433 valp fpr_base;
434 int fparg_count;
436 int i, words;
437 ffi_type **ptr;
438 double double_tmp;
439 union {
440 void **v;
441 char **c;
442 signed char **sc;
443 unsigned char **uc;
444 signed short **ss;
445 unsigned short **us;
446 signed int **si;
447 unsigned int **ui;
448 unsigned long **ul;
449 float **f;
450 double **d;
451 } p_argv;
452 unsigned long gprvalue;
454 stacktop.c = (char *) stack + bytes;
455 gpr_base.ul = stacktop.ul - ASM_NEEDS_REGISTERS64 - NUM_GPR_ARG_REGISTERS64;
456 gpr_end.ul = gpr_base.ul + NUM_GPR_ARG_REGISTERS64;
457 rest.ul = stack + 6 + NUM_GPR_ARG_REGISTERS64;
458 fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS64;
459 fparg_count = 0;
460 next_arg.ul = gpr_base.ul;
462 /* Check that everything starts aligned properly. */
463 FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0);
464 FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0);
465 FFI_ASSERT ((bytes & 0xF) == 0);
467 /* Deal with return values that are actually pass-by-reference. */
468 if (flags & FLAG_RETVAL_REFERENCE)
469 *next_arg.ul++ = (unsigned long) (char *) ecif->rvalue;
471 /* Now for the arguments. */
472 p_argv.v = ecif->avalue;
473 for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
474 i > 0;
475 i--, ptr++, p_argv.v++)
477 switch ((*ptr)->type)
479 case FFI_TYPE_FLOAT:
480 double_tmp = **p_argv.f;
481 *next_arg.f = (float) double_tmp;
482 if (++next_arg.ul == gpr_end.ul)
483 next_arg.ul = rest.ul;
484 if (fparg_count < NUM_FPR_ARG_REGISTERS64)
485 *fpr_base.d++ = double_tmp;
486 fparg_count++;
487 FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
488 break;
490 case FFI_TYPE_DOUBLE:
491 double_tmp = **p_argv.d;
492 *next_arg.d = double_tmp;
493 if (++next_arg.ul == gpr_end.ul)
494 next_arg.ul = rest.ul;
495 if (fparg_count < NUM_FPR_ARG_REGISTERS64)
496 *fpr_base.d++ = double_tmp;
497 fparg_count++;
498 FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
499 break;
501 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
502 case FFI_TYPE_LONGDOUBLE:
503 double_tmp = (*p_argv.d)[0];
504 *next_arg.d = double_tmp;
505 if (++next_arg.ul == gpr_end.ul)
506 next_arg.ul = rest.ul;
507 if (fparg_count < NUM_FPR_ARG_REGISTERS64)
508 *fpr_base.d++ = double_tmp;
509 fparg_count++;
510 double_tmp = (*p_argv.d)[1];
511 *next_arg.d = double_tmp;
512 if (++next_arg.ul == gpr_end.ul)
513 next_arg.ul = rest.ul;
514 if (fparg_count < NUM_FPR_ARG_REGISTERS64)
515 *fpr_base.d++ = double_tmp;
516 fparg_count++;
517 FFI_ASSERT (__LDBL_MANT_DIG__ == 106);
518 FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
519 break;
520 #endif
522 case FFI_TYPE_STRUCT:
523 words = ((*ptr)->size + 7) / 8;
524 if (next_arg.ul >= gpr_base.ul && next_arg.ul + words > gpr_end.ul)
526 size_t first = gpr_end.c - next_arg.c;
527 memcpy (next_arg.c, *p_argv.c, first);
528 memcpy (rest.c, *p_argv.c + first, (*ptr)->size - first);
529 next_arg.c = rest.c + words * 8 - first;
531 else
533 char *where = next_arg.c;
535 /* Structures with size less than eight bytes are passed
536 left-padded. */
537 if ((*ptr)->size < 8)
538 where += 8 - (*ptr)->size;
540 memcpy (where, *p_argv.c, (*ptr)->size);
541 next_arg.ul += words;
542 if (next_arg.ul == gpr_end.ul)
543 next_arg.ul = rest.ul;
545 break;
547 case FFI_TYPE_UINT8:
548 gprvalue = **p_argv.uc;
549 goto putgpr;
550 case FFI_TYPE_SINT8:
551 gprvalue = **p_argv.sc;
552 goto putgpr;
553 case FFI_TYPE_UINT16:
554 gprvalue = **p_argv.us;
555 goto putgpr;
556 case FFI_TYPE_SINT16:
557 gprvalue = **p_argv.ss;
558 goto putgpr;
559 case FFI_TYPE_UINT32:
560 gprvalue = **p_argv.ui;
561 goto putgpr;
562 case FFI_TYPE_INT:
563 case FFI_TYPE_SINT32:
564 gprvalue = **p_argv.si;
565 goto putgpr;
567 case FFI_TYPE_UINT64:
568 case FFI_TYPE_SINT64:
569 case FFI_TYPE_POINTER:
570 gprvalue = **p_argv.ul;
571 putgpr:
572 *next_arg.ul++ = gprvalue;
573 if (next_arg.ul == gpr_end.ul)
574 next_arg.ul = rest.ul;
575 break;
579 FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS
580 || (next_arg.ul >= gpr_base.ul
581 && next_arg.ul <= gpr_base.ul + 4));
586 /* Perform machine dependent cif processing */
587 ffi_status
588 ffi_prep_cif_machdep (ffi_cif *cif)
590 /* All this is for the SYSV and LINUX64 ABI. */
591 int i;
592 ffi_type **ptr;
593 unsigned bytes;
594 int fparg_count = 0, intarg_count = 0;
595 unsigned flags = 0;
596 unsigned struct_copy_size = 0;
597 unsigned type = cif->rtype->type;
598 unsigned size = cif->rtype->size;
600 if (cif->abi == FFI_LINUX_SOFT_FLOAT)
601 NUM_FPR_ARG_REGISTERS = 0;
603 if (cif->abi != FFI_LINUX64)
605 /* All the machine-independent calculation of cif->bytes will be wrong.
606 Redo the calculation for SYSV. */
608 /* Space for the frame pointer, callee's LR, and the asm's temp regs. */
609 bytes = (2 + ASM_NEEDS_REGISTERS) * sizeof (int);
611 /* Space for the GPR registers. */
612 bytes += NUM_GPR_ARG_REGISTERS * sizeof (int);
614 else
616 /* 64-bit ABI. */
618 /* Space for backchain, CR, LR, cc/ld doubleword, TOC and the asm's temp
619 regs. */
620 bytes = (6 + ASM_NEEDS_REGISTERS64) * sizeof (long);
622 /* Space for the mandatory parm save area and general registers. */
623 bytes += 2 * NUM_GPR_ARG_REGISTERS64 * sizeof (long);
626 /* Return value handling. The rules for SYSV are as follows:
627 - 32-bit (or less) integer values are returned in gpr3;
628 - Structures of size <= 4 bytes also returned in gpr3;
629 - 64-bit integer values and structures between 5 and 8 bytes are returned
630 in gpr3 and gpr4;
631 - Single/double FP values are returned in fpr1;
632 - Larger structures are allocated space and a pointer is passed as
633 the first argument.
634 - long doubles (if not equivalent to double) are returned in
635 fpr1,fpr2 for Linux and as for large structs for SysV.
636 For LINUX64:
637 - integer values in gpr3;
638 - Structures/Unions by reference;
639 - Single/double FP values in fpr1, long double in fpr1,fpr2.
640 - soft-float float/doubles are treated as UINT32/UINT64 respectivley.
641 - soft-float long doubles are returned in gpr3-gpr6. */
642 switch (type)
644 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
645 case FFI_TYPE_LONGDOUBLE:
646 if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX64
647 && cif->abi != FFI_LINUX_SOFT_FLOAT)
648 goto byref;
649 flags |= FLAG_RETURNS_128BITS;
650 /* Fall through. */
651 #endif
652 case FFI_TYPE_DOUBLE:
653 flags |= FLAG_RETURNS_64BITS;
654 /* Fall through. */
655 case FFI_TYPE_FLOAT:
656 /* With FFI_LINUX_SOFT_FLOAT no fp registers are used. */
657 if (cif->abi != FFI_LINUX_SOFT_FLOAT)
658 flags |= FLAG_RETURNS_FP;
659 break;
661 case FFI_TYPE_UINT64:
662 case FFI_TYPE_SINT64:
663 flags |= FLAG_RETURNS_64BITS;
664 break;
666 case FFI_TYPE_STRUCT:
667 if (cif->abi == FFI_SYSV)
669 /* The final SYSV ABI says that structures smaller or equal 8 bytes
670 are returned in r3/r4. The FFI_GCC_SYSV ABI instead returns them
671 in memory. */
673 /* Treat structs with size <= 8 bytes. */
674 if (size <= 8)
676 flags |= FLAG_RETURNS_SMST;
677 /* These structs are returned in r3. We pack the type and the
678 precalculated shift value (needed in the sysv.S) into flags.
679 The same applies for the structs returned in r3/r4. */
680 if (size <= 4)
682 flags |= 1 << (31 - FFI_SYSV_TYPE_SMALL_STRUCT - 1);
683 flags |= 8 * (4 - size) << 4;
684 break;
686 /* These structs are returned in r3 and r4. See above. */
687 if (size <= 8)
689 flags |= 1 << (31 - FFI_SYSV_TYPE_SMALL_STRUCT - 2);
690 flags |= 8 * (8 - size) << 4;
691 break;
695 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
696 byref:
697 #endif
698 intarg_count++;
699 flags |= FLAG_RETVAL_REFERENCE;
700 /* Fall through. */
701 case FFI_TYPE_VOID:
702 flags |= FLAG_RETURNS_NOTHING;
703 break;
705 default:
706 /* Returns 32-bit integer, or similar. Nothing to do here. */
707 break;
710 if (cif->abi != FFI_LINUX64)
711 /* The first NUM_GPR_ARG_REGISTERS words of integer arguments, and the
712 first NUM_FPR_ARG_REGISTERS fp arguments, go in registers; the rest
713 goes on the stack. Structures and long doubles (if not equivalent
714 to double) are passed as a pointer to a copy of the structure.
715 Stuff on the stack needs to keep proper alignment. */
716 for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
718 switch ((*ptr)->type)
720 case FFI_TYPE_FLOAT:
721 /* With FFI_LINUX_SOFT_FLOAT floats are handled like UINT32. */
722 if (cif->abi == FFI_LINUX_SOFT_FLOAT)
723 goto soft_float_cif;
724 fparg_count++;
725 /* floating singles are not 8-aligned on stack */
726 break;
728 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
729 case FFI_TYPE_LONGDOUBLE:
730 if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX_SOFT_FLOAT)
731 goto do_struct;
732 if (cif->abi == FFI_LINUX_SOFT_FLOAT)
734 if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3
735 || intarg_count < NUM_GPR_ARG_REGISTERS)
736 /* A long double in FFI_LINUX_SOFT_FLOAT can use only
737 a set of four consecutive gprs. If we have not enough,
738 we have to adjust the intarg_count value. */
739 intarg_count += NUM_GPR_ARG_REGISTERS - intarg_count;
740 intarg_count += 4;
741 break;
743 else
744 fparg_count++;
745 /* Fall thru */
746 #endif
747 case FFI_TYPE_DOUBLE:
748 /* With FFI_LINUX_SOFT_FLOAT doubles are handled like UINT64. */
749 if (cif->abi == FFI_LINUX_SOFT_FLOAT)
750 goto soft_double_cif;
751 fparg_count++;
752 /* If this FP arg is going on the stack, it must be
753 8-byte-aligned. */
754 if (fparg_count > NUM_FPR_ARG_REGISTERS
755 && intarg_count >= NUM_GPR_ARG_REGISTERS
756 && intarg_count % 2 != 0)
757 intarg_count++;
758 break;
760 case FFI_TYPE_UINT64:
761 case FFI_TYPE_SINT64:
762 soft_double_cif:
763 /* 'long long' arguments are passed as two words, but
764 either both words must fit in registers or both go
765 on the stack. If they go on the stack, they must
766 be 8-byte-aligned.
768 Also, only certain register pairs can be used for
769 passing long long int -- specifically (r3,r4), (r5,r6),
770 (r7,r8), (r9,r10).
772 if (intarg_count == NUM_GPR_ARG_REGISTERS-1
773 || intarg_count % 2 != 0)
774 intarg_count++;
775 intarg_count += 2;
776 break;
778 case FFI_TYPE_STRUCT:
779 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
780 do_struct:
781 #endif
782 /* We must allocate space for a copy of these to enforce
783 pass-by-value. Pad the space up to a multiple of 16
784 bytes (the maximum alignment required for anything under
785 the SYSV ABI). */
786 struct_copy_size += ((*ptr)->size + 15) & ~0xF;
787 /* Fall through (allocate space for the pointer). */
789 default:
790 soft_float_cif:
791 /* Everything else is passed as a 4-byte word in a GPR, either
792 the object itself or a pointer to it. */
793 intarg_count++;
794 break;
797 else
798 for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
800 switch ((*ptr)->type)
802 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
803 case FFI_TYPE_LONGDOUBLE:
804 if (cif->abi == FFI_LINUX_SOFT_FLOAT)
805 intarg_count += 4;
806 else
808 fparg_count += 2;
809 intarg_count += 2;
811 break;
812 #endif
813 case FFI_TYPE_FLOAT:
814 case FFI_TYPE_DOUBLE:
815 fparg_count++;
816 intarg_count++;
817 break;
819 case FFI_TYPE_STRUCT:
820 intarg_count += ((*ptr)->size + 7) / 8;
821 break;
823 default:
824 /* Everything else is passed as a 8-byte word in a GPR, either
825 the object itself or a pointer to it. */
826 intarg_count++;
827 break;
831 if (fparg_count != 0)
832 flags |= FLAG_FP_ARGUMENTS;
833 if (intarg_count > 4)
834 flags |= FLAG_4_GPR_ARGUMENTS;
835 if (struct_copy_size != 0)
836 flags |= FLAG_ARG_NEEDS_COPY;
838 if (cif->abi != FFI_LINUX64)
840 /* Space for the FPR registers, if needed. */
841 if (fparg_count != 0)
842 bytes += NUM_FPR_ARG_REGISTERS * sizeof (double);
844 /* Stack space. */
845 if (intarg_count > NUM_GPR_ARG_REGISTERS)
846 bytes += (intarg_count - NUM_GPR_ARG_REGISTERS) * sizeof (int);
847 if (fparg_count > NUM_FPR_ARG_REGISTERS)
848 bytes += (fparg_count - NUM_FPR_ARG_REGISTERS) * sizeof (double);
850 else
852 /* Space for the FPR registers, if needed. */
853 if (fparg_count != 0)
854 bytes += NUM_FPR_ARG_REGISTERS64 * sizeof (double);
856 /* Stack space. */
857 if (intarg_count > NUM_GPR_ARG_REGISTERS64)
858 bytes += (intarg_count - NUM_GPR_ARG_REGISTERS64) * sizeof (long);
861 /* The stack space allocated needs to be a multiple of 16 bytes. */
862 bytes = (bytes + 15) & ~0xF;
864 /* Add in the space for the copied structures. */
865 bytes += struct_copy_size;
867 cif->flags = flags;
868 cif->bytes = bytes;
870 return FFI_OK;
873 extern void ffi_call_SYSV(extended_cif *, unsigned, unsigned, unsigned *,
874 void (*fn)());
875 extern void FFI_HIDDEN ffi_call_LINUX64(extended_cif *, unsigned long,
876 unsigned long, unsigned long *,
877 void (*fn)());
879 void
880 ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue)
882 extended_cif ecif;
884 ecif.cif = cif;
885 ecif.avalue = avalue;
887 /* If the return value is a struct and we don't have a return */
888 /* value address then we need to make one */
890 if ((rvalue == NULL) && (cif->rtype->type == FFI_TYPE_STRUCT))
892 ecif.rvalue = alloca(cif->rtype->size);
894 else
895 ecif.rvalue = rvalue;
898 switch (cif->abi)
900 #ifndef POWERPC64
901 case FFI_SYSV:
902 case FFI_GCC_SYSV:
903 case FFI_LINUX:
904 case FFI_LINUX_SOFT_FLOAT:
905 ffi_call_SYSV (&ecif, -cif->bytes, cif->flags, ecif.rvalue, fn);
906 break;
907 #else
908 case FFI_LINUX64:
909 ffi_call_LINUX64 (&ecif, -(long) cif->bytes, cif->flags, ecif.rvalue, fn);
910 break;
911 #endif
912 default:
913 FFI_ASSERT (0);
914 break;
919 #ifndef POWERPC64
920 #define MIN_CACHE_LINE_SIZE 8
922 static void
923 flush_icache (char *wraddr, char *xaddr, int size)
925 int i;
926 for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE)
927 __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;"
928 : : "r" (xaddr + i), "r" (wraddr + i) : "memory");
929 __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" "sync;" "isync;"
930 : : "r"(xaddr + size - 1), "r"(wraddr + size - 1)
931 : "memory");
933 #endif
935 ffi_status
936 ffi_prep_closure_loc (ffi_closure *closure,
937 ffi_cif *cif,
938 void (*fun) (ffi_cif *, void *, void **, void *),
939 void *user_data,
940 void *codeloc)
942 #ifdef POWERPC64
943 void **tramp = (void **) &closure->tramp[0];
945 FFI_ASSERT (cif->abi == FFI_LINUX64);
946 /* Copy function address and TOC from ffi_closure_LINUX64. */
947 memcpy (tramp, (char *) ffi_closure_LINUX64, 16);
948 tramp[2] = codeloc;
949 #else
950 unsigned int *tramp;
952 FFI_ASSERT (cif->abi == FFI_GCC_SYSV || cif->abi == FFI_SYSV);
954 tramp = (unsigned int *) &closure->tramp[0];
955 tramp[0] = 0x7c0802a6; /* mflr r0 */
956 tramp[1] = 0x4800000d; /* bl 10 <trampoline_initial+0x10> */
957 tramp[4] = 0x7d6802a6; /* mflr r11 */
958 tramp[5] = 0x7c0803a6; /* mtlr r0 */
959 tramp[6] = 0x800b0000; /* lwz r0,0(r11) */
960 tramp[7] = 0x816b0004; /* lwz r11,4(r11) */
961 tramp[8] = 0x7c0903a6; /* mtctr r0 */
962 tramp[9] = 0x4e800420; /* bctr */
963 *(void **) &tramp[2] = (void *) ffi_closure_SYSV; /* function */
964 *(void **) &tramp[3] = codeloc; /* context */
966 /* Flush the icache. */
967 flush_icache ((char *)tramp, (char *)codeloc, FFI_TRAMPOLINE_SIZE);
968 #endif
970 closure->cif = cif;
971 closure->fun = fun;
972 closure->user_data = user_data;
974 return FFI_OK;
977 typedef union
979 float f;
980 double d;
981 } ffi_dblfl;
983 int ffi_closure_helper_SYSV (ffi_closure *, void *, unsigned long *,
984 ffi_dblfl *, unsigned long *);
986 /* Basically the trampoline invokes ffi_closure_SYSV, and on
987 * entry, r11 holds the address of the closure.
988 * After storing the registers that could possibly contain
989 * parameters to be passed into the stack frame and setting
990 * up space for a return value, ffi_closure_SYSV invokes the
991 * following helper function to do most of the work
995 ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
996 unsigned long *pgr, ffi_dblfl *pfr,
997 unsigned long *pst)
999 /* rvalue is the pointer to space for return value in closure assembly */
1000 /* pgr is the pointer to where r3-r10 are stored in ffi_closure_SYSV */
1001 /* pfr is the pointer to where f1-f8 are stored in ffi_closure_SYSV */
1002 /* pst is the pointer to outgoing parameter stack in original caller */
1004 void ** avalue;
1005 ffi_type ** arg_types;
1006 long i, avn;
1007 long nf; /* number of floating registers already used */
1008 long ng; /* number of general registers already used */
1009 ffi_cif * cif;
1010 double temp;
1011 unsigned size;
1013 cif = closure->cif;
1014 avalue = alloca (cif->nargs * sizeof (void *));
1015 size = cif->rtype->size;
1017 nf = 0;
1018 ng = 0;
1020 /* Copy the caller's structure return value address so that the closure
1021 returns the data directly to the caller.
1022 For FFI_SYSV the result is passed in r3/r4 if the struct size is less
1023 or equal 8 bytes. */
1025 if ((cif->rtype->type == FFI_TYPE_STRUCT
1026 && !((cif->abi == FFI_SYSV) && (size <= 8)))
1027 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
1028 || (cif->rtype->type == FFI_TYPE_LONGDOUBLE
1029 && cif->abi != FFI_LINUX && cif->abi != FFI_LINUX_SOFT_FLOAT)
1030 #endif
1033 rvalue = (void *) *pgr;
1034 ng++;
1035 pgr++;
1038 i = 0;
1039 avn = cif->nargs;
1040 arg_types = cif->arg_types;
1042 /* Grab the addresses of the arguments from the stack frame. */
1043 while (i < avn)
1045 switch (arg_types[i]->type)
1047 case FFI_TYPE_SINT8:
1048 case FFI_TYPE_UINT8:
1049 /* there are 8 gpr registers used to pass values */
1050 if (ng < 8)
1052 avalue[i] = (char *) pgr + 3;
1053 ng++;
1054 pgr++;
1056 else
1058 avalue[i] = (char *) pst + 3;
1059 pst++;
1061 break;
1063 case FFI_TYPE_SINT16:
1064 case FFI_TYPE_UINT16:
1065 /* there are 8 gpr registers used to pass values */
1066 if (ng < 8)
1068 avalue[i] = (char *) pgr + 2;
1069 ng++;
1070 pgr++;
1072 else
1074 avalue[i] = (char *) pst + 2;
1075 pst++;
1077 break;
1079 case FFI_TYPE_SINT32:
1080 case FFI_TYPE_UINT32:
1081 case FFI_TYPE_POINTER:
1082 soft_float_closure:
1083 /* there are 8 gpr registers used to pass values */
1084 if (ng < 8)
1086 avalue[i] = pgr;
1087 ng++;
1088 pgr++;
1090 else
1092 avalue[i] = pst;
1093 pst++;
1095 break;
1097 case FFI_TYPE_STRUCT:
1098 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
1099 do_struct:
1100 #endif
1101 /* Structs are passed by reference. The address will appear in a
1102 gpr if it is one of the first 8 arguments. */
1103 if (ng < 8)
1105 avalue[i] = (void *) *pgr;
1106 ng++;
1107 pgr++;
1109 else
1111 avalue[i] = (void *) *pst;
1112 pst++;
1114 break;
1116 case FFI_TYPE_SINT64:
1117 case FFI_TYPE_UINT64:
1118 soft_double_closure:
1119 /* passing long long ints are complex, they must
1120 * be passed in suitable register pairs such as
1121 * (r3,r4) or (r5,r6) or (r6,r7), or (r7,r8) or (r9,r10)
1122 * and if the entire pair aren't available then the outgoing
1123 * parameter stack is used for both but an alignment of 8
1124 * must will be kept. So we must either look in pgr
1125 * or pst to find the correct address for this type
1126 * of parameter.
1128 if (ng < 7)
1130 if (ng & 0x01)
1132 /* skip r4, r6, r8 as starting points */
1133 ng++;
1134 pgr++;
1136 avalue[i] = pgr;
1137 ng += 2;
1138 pgr += 2;
1140 else
1142 if (((long) pst) & 4)
1143 pst++;
1144 avalue[i] = pst;
1145 pst += 2;
1147 break;
1149 case FFI_TYPE_FLOAT:
1150 /* With FFI_LINUX_SOFT_FLOAT floats are handled like UINT32. */
1151 if (cif->abi == FFI_LINUX_SOFT_FLOAT)
1152 goto soft_float_closure;
1153 /* unfortunately float values are stored as doubles
1154 * in the ffi_closure_SYSV code (since we don't check
1155 * the type in that routine).
1158 /* there are 8 64bit floating point registers */
1160 if (nf < 8)
1162 temp = pfr->d;
1163 pfr->f = (float) temp;
1164 avalue[i] = pfr;
1165 nf++;
1166 pfr++;
1168 else
1170 /* FIXME? here we are really changing the values
1171 * stored in the original calling routines outgoing
1172 * parameter stack. This is probably a really
1173 * naughty thing to do but...
1175 avalue[i] = pst;
1176 pst += 1;
1178 break;
1180 case FFI_TYPE_DOUBLE:
1181 /* With FFI_LINUX_SOFT_FLOAT doubles are handled like UINT64. */
1182 if (cif->abi == FFI_LINUX_SOFT_FLOAT)
1183 goto soft_double_closure;
1184 /* On the outgoing stack all values are aligned to 8 */
1185 /* there are 8 64bit floating point registers */
1187 if (nf < 8)
1189 avalue[i] = pfr;
1190 nf++;
1191 pfr++;
1193 else
1195 if (((long) pst) & 4)
1196 pst++;
1197 avalue[i] = pst;
1198 pst += 2;
1200 break;
1202 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
1203 case FFI_TYPE_LONGDOUBLE:
1204 if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX_SOFT_FLOAT)
1205 goto do_struct;
1206 if (cif->abi == FFI_LINUX_SOFT_FLOAT)
1207 { /* Test if for the whole long double, 4 gprs are available.
1208 otherwise the stuff ends up on the stack. */
1209 if (ng < 5)
1211 avalue[i] = pgr;
1212 pgr += 4;
1213 ng += 4;
1215 else
1217 avalue[i] = pst;
1218 pst += 4;
1220 break;
1222 if (nf < 7)
1224 avalue[i] = pfr;
1225 pfr += 2;
1226 nf += 2;
1228 else
1230 if (((long) pst) & 4)
1231 pst++;
1232 avalue[i] = pst;
1233 pst += 4;
1234 nf = 8;
1236 break;
1237 #endif
1239 default:
1240 FFI_ASSERT (0);
1243 i++;
1247 (closure->fun) (cif, rvalue, avalue, closure->user_data);
1249 /* Tell ffi_closure_SYSV how to perform return type promotions.
1250 Because the FFI_SYSV ABI returns the structures <= 8 bytes in r3/r4
1251 we have to tell ffi_closure_SYSV how to treat them. */
1252 if (cif->abi == FFI_SYSV && cif->rtype->type == FFI_TYPE_STRUCT
1253 && size <= 8)
1254 return FFI_SYSV_TYPE_SMALL_STRUCT + size;
1255 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
1256 else if (cif->rtype->type == FFI_TYPE_LONGDOUBLE
1257 && cif->abi != FFI_LINUX && cif->abi != FFI_LINUX_SOFT_FLOAT)
1258 return FFI_TYPE_STRUCT;
1259 #endif
1260 /* With FFI_LINUX_SOFT_FLOAT floats and doubles are handled like UINT32
1261 respectivley UINT64. */
1262 if (cif->abi == FFI_LINUX_SOFT_FLOAT)
1264 switch (cif->rtype->type)
1266 case FFI_TYPE_FLOAT:
1267 return FFI_TYPE_UINT32;
1268 break;
1269 case FFI_TYPE_DOUBLE:
1270 return FFI_TYPE_UINT64;
1271 break;
1272 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
1273 case FFI_TYPE_LONGDOUBLE:
1274 return FFI_TYPE_UINT128;
1275 break;
1276 #endif
1277 default:
1278 return cif->rtype->type;
1281 else
1283 return cif->rtype->type;
1287 int FFI_HIDDEN ffi_closure_helper_LINUX64 (ffi_closure *, void *,
1288 unsigned long *, ffi_dblfl *);
1290 int FFI_HIDDEN
1291 ffi_closure_helper_LINUX64 (ffi_closure *closure, void *rvalue,
1292 unsigned long *pst, ffi_dblfl *pfr)
1294 /* rvalue is the pointer to space for return value in closure assembly */
1295 /* pst is the pointer to parameter save area
1296 (r3-r10 are stored into its first 8 slots by ffi_closure_LINUX64) */
1297 /* pfr is the pointer to where f1-f13 are stored in ffi_closure_LINUX64 */
1299 void **avalue;
1300 ffi_type **arg_types;
1301 long i, avn;
1302 ffi_cif *cif;
1303 ffi_dblfl *end_pfr = pfr + NUM_FPR_ARG_REGISTERS64;
1305 cif = closure->cif;
1306 avalue = alloca (cif->nargs * sizeof (void *));
1308 /* Copy the caller's structure return value address so that the closure
1309 returns the data directly to the caller. */
1310 if (cif->rtype->type == FFI_TYPE_STRUCT)
1312 rvalue = (void *) *pst;
1313 pst++;
1316 i = 0;
1317 avn = cif->nargs;
1318 arg_types = cif->arg_types;
1320 /* Grab the addresses of the arguments from the stack frame. */
1321 while (i < avn)
1323 switch (arg_types[i]->type)
1325 case FFI_TYPE_SINT8:
1326 case FFI_TYPE_UINT8:
1327 avalue[i] = (char *) pst + 7;
1328 pst++;
1329 break;
1331 case FFI_TYPE_SINT16:
1332 case FFI_TYPE_UINT16:
1333 avalue[i] = (char *) pst + 6;
1334 pst++;
1335 break;
1337 case FFI_TYPE_SINT32:
1338 case FFI_TYPE_UINT32:
1339 avalue[i] = (char *) pst + 4;
1340 pst++;
1341 break;
1343 case FFI_TYPE_SINT64:
1344 case FFI_TYPE_UINT64:
1345 case FFI_TYPE_POINTER:
1346 avalue[i] = pst;
1347 pst++;
1348 break;
1350 case FFI_TYPE_STRUCT:
1351 /* Structures with size less than eight bytes are passed
1352 left-padded. */
1353 if (arg_types[i]->size < 8)
1354 avalue[i] = (char *) pst + 8 - arg_types[i]->size;
1355 else
1356 avalue[i] = pst;
1357 pst += (arg_types[i]->size + 7) / 8;
1358 break;
1360 case FFI_TYPE_FLOAT:
1361 /* unfortunately float values are stored as doubles
1362 * in the ffi_closure_LINUX64 code (since we don't check
1363 * the type in that routine).
1366 /* there are 13 64bit floating point registers */
1368 if (pfr < end_pfr)
1370 double temp = pfr->d;
1371 pfr->f = (float) temp;
1372 avalue[i] = pfr;
1373 pfr++;
1375 else
1376 avalue[i] = pst;
1377 pst++;
1378 break;
1380 case FFI_TYPE_DOUBLE:
1381 /* On the outgoing stack all values are aligned to 8 */
1382 /* there are 13 64bit floating point registers */
1384 if (pfr < end_pfr)
1386 avalue[i] = pfr;
1387 pfr++;
1389 else
1390 avalue[i] = pst;
1391 pst++;
1392 break;
1394 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
1395 case FFI_TYPE_LONGDOUBLE:
1396 if (pfr + 1 < end_pfr)
1398 avalue[i] = pfr;
1399 pfr += 2;
1401 else
1403 if (pfr < end_pfr)
1405 /* Passed partly in f13 and partly on the stack.
1406 Move it all to the stack. */
1407 *pst = *(unsigned long *) pfr;
1408 pfr++;
1410 avalue[i] = pst;
1412 pst += 2;
1413 break;
1414 #endif
1416 default:
1417 FFI_ASSERT (0);
1420 i++;
1424 (closure->fun) (cif, rvalue, avalue, closure->user_data);
1426 /* Tell ffi_closure_LINUX64 how to perform return type promotions. */
1427 return cif->rtype->type;