ffi 1.12.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +79 -0
- data/Gemfile +4 -2
- data/README.md +10 -2
- data/Rakefile +24 -43
- data/ext/ffi_c/AbstractMemory.c +25 -26
- data/ext/ffi_c/Buffer.c +4 -9
- data/ext/ffi_c/Call.c +3 -14
- data/ext/ffi_c/ClosurePool.c +75 -25
- data/ext/ffi_c/ClosurePool.h +3 -1
- data/ext/ffi_c/DynamicLibrary.c +1 -6
- data/ext/ffi_c/Function.c +15 -35
- data/ext/ffi_c/FunctionInfo.c +3 -8
- data/ext/ffi_c/LastError.c +2 -6
- data/ext/ffi_c/LongDouble.c +5 -3
- data/ext/ffi_c/LongDouble.h +0 -4
- data/ext/ffi_c/MemoryPointer.c +3 -8
- data/ext/ffi_c/MethodHandle.c +21 -31
- data/ext/ffi_c/MethodHandle.h +3 -2
- data/ext/ffi_c/Platform.c +3 -7
- data/ext/ffi_c/Pointer.c +25 -26
- data/ext/ffi_c/Struct.c +49 -56
- data/ext/ffi_c/Struct.h +12 -6
- data/ext/ffi_c/StructByValue.c +2 -7
- data/ext/ffi_c/StructLayout.c +22 -19
- data/ext/ffi_c/Thread.c +0 -8
- data/ext/ffi_c/Thread.h +1 -9
- data/ext/ffi_c/Type.c +1 -1
- data/ext/ffi_c/Variadic.c +2 -7
- data/ext/ffi_c/compat.h +4 -0
- data/ext/ffi_c/extconf.rb +33 -24
- data/ext/ffi_c/libffi/.travis.yml +4 -0
- data/ext/ffi_c/libffi/.travis/bfin-sim.exp +1 -1
- data/ext/ffi_c/libffi/.travis/build.sh +4 -0
- data/ext/ffi_c/libffi/.travis/m32r-sim.exp +1 -1
- data/ext/ffi_c/libffi/.travis/moxie-sim.exp +1 -1
- data/ext/ffi_c/libffi/.travis/or1k-sim.exp +1 -1
- data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +1 -1
- data/ext/ffi_c/libffi/.travis/wine-sim.exp +1 -1
- data/ext/ffi_c/libffi/Makefile.am +49 -58
- data/ext/ffi_c/libffi/README.md +11 -1
- data/ext/ffi_c/libffi/config.guess +552 -331
- data/ext/ffi_c/libffi/config.sub +1321 -1306
- data/ext/ffi_c/libffi/configure.ac +31 -10
- data/ext/ffi_c/libffi/configure.host +32 -20
- data/ext/ffi_c/libffi/doc/Makefile.am +3 -0
- data/ext/ffi_c/libffi/doc/libffi.texi +997 -0
- data/ext/ffi_c/libffi/doc/version.texi +4 -0
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +1 -1
- data/ext/ffi_c/libffi/include/ffi.h.in +8 -0
- data/ext/ffi_c/libffi/libffi.map.in +8 -12
- data/ext/ffi_c/libffi/libtool-version +1 -1
- data/ext/ffi_c/libffi/msvcc.sh +11 -11
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +51 -35
- data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +10 -5
- data/ext/ffi_c/libffi/src/aarch64/internal.h +1 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +14 -3
- data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +1 -1
- data/ext/ffi_c/libffi/src/arm/ffi.c +22 -0
- data/ext/ffi_c/libffi/src/arm/sysv.S +4 -4
- data/ext/ffi_c/libffi/src/closures.c +33 -10
- data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
- data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
- data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
- data/ext/ffi_c/libffi/src/dlmalloc.c +1 -1
- data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
- data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
- data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
- data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
- data/ext/ffi_c/libffi/src/mips/ffi.c +5 -1
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +1 -1
- data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
- data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
- data/ext/ffi_c/libffi/src/pa/linux.S +4 -2
- data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +13 -1
- data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +1 -1
- data/ext/ffi_c/libffi/src/powerpc/linux64.S +8 -0
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +13 -1
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
- data/ext/ffi_c/libffi/src/prep_cif.c +1 -1
- data/ext/ffi_c/libffi/src/x86/ffi.c +15 -6
- data/ext/ffi_c/libffi/src/x86/ffi64.c +17 -8
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +15 -8
- data/ext/ffi_c/libffi/src/x86/sysv.S +15 -6
- data/ext/ffi_c/libffi/src/x86/unix64.S +59 -4
- data/ext/ffi_c/libffi/src/x86/win64.S +7 -3
- data/ext/ffi_c/libffi/src/x86/win64_intel.S +3 -2
- data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +22 -2
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.closures/huge_struct.c +2 -0
- data/ffi.gemspec +2 -2
- data/lib/ffi.rb +10 -2
- data/lib/ffi/abstract_memory.rb +44 -0
- data/lib/ffi/ffi.rb +1 -0
- data/lib/ffi/library.rb +6 -2
- data/lib/ffi/platform.rb +21 -8
- data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
- data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
- data/lib/ffi/platform/arm-linux/types.conf +32 -4
- data/lib/ffi/platform/i386-windows/types.conf +26 -79
- data/lib/ffi/platform/powerpc-linux/types.conf +32 -2
- data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
- data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
- data/lib/ffi/platform/x86_64-darwin/types.conf +4 -0
- data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +4 -22
- data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
- data/lib/ffi/platform/x86_64-linux/types.conf +21 -0
- data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
- data/lib/ffi/platform/x86_64-windows/types.conf +10 -78
- data/lib/ffi/pointer.rb +40 -19
- data/lib/ffi/struct.rb +9 -4
- data/lib/ffi/tools/types_generator.rb +2 -0
- data/lib/ffi/version.rb +1 -1
- data/samples/getlogin.rb +1 -1
- data/samples/getpid.rb +1 -1
- data/samples/gettimeofday.rb +8 -8
- data/samples/hello.rb +2 -1
- data/samples/inotify.rb +1 -1
- data/samples/pty.rb +1 -2
- data/samples/qsort.rb +0 -1
- metadata +18 -12
- data/.appveyor.yml +0 -27
- data/.gitignore +0 -25
- data/.gitmodules +0 -4
- data/.travis.yml +0 -44
- data/.yardopts +0 -5
- data/ext/ffi_c/win32/stdbool.h +0 -8
- data/ext/ffi_c/win32/stdint.h +0 -201
- data/samples/sample_helper.rb +0 -6
@@ -39,7 +39,9 @@
|
|
39
39
|
#endif
|
40
40
|
|
41
41
|
#ifndef USE__BUILTIN___CLEAR_CACHE
|
42
|
-
# if defined(
|
42
|
+
# if defined(__FreeBSD__)
|
43
|
+
# include <machine/sysarch.h>
|
44
|
+
# elif defined(__OpenBSD__)
|
43
45
|
# include <mips64/sysarch.h>
|
44
46
|
# else
|
45
47
|
# include <sys/cachectl.h>
|
@@ -777,11 +779,13 @@ ffi_prep_closure_loc (ffi_closure *closure,
|
|
777
779
|
closure->fun = fun;
|
778
780
|
closure->user_data = user_data;
|
779
781
|
|
782
|
+
#if !defined(__FreeBSD__)
|
780
783
|
#ifdef USE__BUILTIN___CLEAR_CACHE
|
781
784
|
__builtin___clear_cache(clear_location, clear_location + FFI_TRAMPOLINE_SIZE);
|
782
785
|
#else
|
783
786
|
cacheflush (clear_location, FFI_TRAMPOLINE_SIZE, ICACHE);
|
784
787
|
#endif
|
788
|
+
#endif /* ! __FreeBSD__ */
|
785
789
|
return FFI_OK;
|
786
790
|
}
|
787
791
|
|
@@ -421,12 +421,15 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack)
|
|
421
421
|
ffi_cif *cif;
|
422
422
|
void **avalue;
|
423
423
|
void *rvalue;
|
424
|
-
|
424
|
+
/* Functions can return up to 64-bits in registers. Return address
|
425
|
+
must be double word aligned. */
|
426
|
+
union { double rd; UINT32 ret[2]; } u;
|
425
427
|
ffi_type **p_arg;
|
426
428
|
char *tmp;
|
427
429
|
int i, avn;
|
428
430
|
unsigned int slot = FIRST_ARG_SLOT;
|
429
431
|
register UINT32 r28 asm("r28");
|
432
|
+
ffi_closure *c = (ffi_closure *)FFI_RESTORE_PTR (closure);
|
430
433
|
|
431
434
|
cif = closure->cif;
|
432
435
|
|
@@ -434,7 +437,7 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack)
|
|
434
437
|
if (cif->flags == FFI_TYPE_STRUCT)
|
435
438
|
rvalue = (void *)r28;
|
436
439
|
else
|
437
|
-
rvalue = &
|
440
|
+
rvalue = &u;
|
438
441
|
|
439
442
|
avalue = (void **)alloca(cif->nargs * FFI_SIZEOF_ARG);
|
440
443
|
avn = cif->nargs;
|
@@ -529,35 +532,35 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack)
|
|
529
532
|
}
|
530
533
|
|
531
534
|
/* Invoke the closure. */
|
532
|
-
(
|
535
|
+
(c->fun) (cif, rvalue, avalue, c->user_data);
|
533
536
|
|
534
|
-
debug(3, "after calling function, ret[0] = %08x, ret[1] = %08x\n", ret[0],
|
535
|
-
ret[1]);
|
537
|
+
debug(3, "after calling function, ret[0] = %08x, ret[1] = %08x\n", u.ret[0],
|
538
|
+
u.ret[1]);
|
536
539
|
|
537
540
|
/* Store the result using the lower 2 bytes of the flags. */
|
538
541
|
switch (cif->flags)
|
539
542
|
{
|
540
543
|
case FFI_TYPE_UINT8:
|
541
|
-
*(stack - FIRST_ARG_SLOT) = (UINT8)(ret[0] >> 24);
|
544
|
+
*(stack - FIRST_ARG_SLOT) = (UINT8)(u.ret[0] >> 24);
|
542
545
|
break;
|
543
546
|
case FFI_TYPE_SINT8:
|
544
|
-
*(stack - FIRST_ARG_SLOT) = (SINT8)(ret[0] >> 24);
|
547
|
+
*(stack - FIRST_ARG_SLOT) = (SINT8)(u.ret[0] >> 24);
|
545
548
|
break;
|
546
549
|
case FFI_TYPE_UINT16:
|
547
|
-
*(stack - FIRST_ARG_SLOT) = (UINT16)(ret[0] >> 16);
|
550
|
+
*(stack - FIRST_ARG_SLOT) = (UINT16)(u.ret[0] >> 16);
|
548
551
|
break;
|
549
552
|
case FFI_TYPE_SINT16:
|
550
|
-
*(stack - FIRST_ARG_SLOT) = (SINT16)(ret[0] >> 16);
|
553
|
+
*(stack - FIRST_ARG_SLOT) = (SINT16)(u.ret[0] >> 16);
|
551
554
|
break;
|
552
555
|
case FFI_TYPE_INT:
|
553
556
|
case FFI_TYPE_SINT32:
|
554
557
|
case FFI_TYPE_UINT32:
|
555
|
-
*(stack - FIRST_ARG_SLOT) = ret[0];
|
558
|
+
*(stack - FIRST_ARG_SLOT) = u.ret[0];
|
556
559
|
break;
|
557
560
|
case FFI_TYPE_SINT64:
|
558
561
|
case FFI_TYPE_UINT64:
|
559
|
-
*(stack - FIRST_ARG_SLOT) = ret[0];
|
560
|
-
*(stack - FIRST_ARG_SLOT - 1) = ret[1];
|
562
|
+
*(stack - FIRST_ARG_SLOT) = u.ret[0];
|
563
|
+
*(stack - FIRST_ARG_SLOT - 1) = u.ret[1];
|
561
564
|
break;
|
562
565
|
|
563
566
|
case FFI_TYPE_DOUBLE:
|
@@ -577,7 +580,7 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack)
|
|
577
580
|
case FFI_TYPE_SMALL_STRUCT4:
|
578
581
|
tmp = (void*)(stack - FIRST_ARG_SLOT);
|
579
582
|
tmp += 4 - cif->rtype->size;
|
580
|
-
memcpy((void*)tmp, &
|
583
|
+
memcpy((void*)tmp, &u, cif->rtype->size);
|
581
584
|
break;
|
582
585
|
|
583
586
|
case FFI_TYPE_SMALL_STRUCT5:
|
@@ -598,7 +601,7 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack)
|
|
598
601
|
}
|
599
602
|
|
600
603
|
memset (ret2, 0, sizeof (ret2));
|
601
|
-
memcpy ((char *)ret2 + off,
|
604
|
+
memcpy ((char *)ret2 + off, &u, 8 - off);
|
602
605
|
|
603
606
|
*(stack - FIRST_ARG_SLOT) = ret2[0];
|
604
607
|
*(stack - FIRST_ARG_SLOT - 1) = ret2[1];
|
@@ -630,89 +633,41 @@ ffi_prep_closure_loc (ffi_closure* closure,
|
|
630
633
|
void *user_data,
|
631
634
|
void *codeloc)
|
632
635
|
{
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
636
|
+
ffi_closure *c = (ffi_closure *)FFI_RESTORE_PTR (closure);
|
637
|
+
|
638
|
+
/* The layout of a function descriptor. A function pointer with the PLABEL
|
639
|
+
bit set points to a function descriptor. */
|
640
|
+
struct pa32_fd
|
641
|
+
{
|
642
|
+
UINT32 code_pointer;
|
643
|
+
UINT32 gp;
|
644
|
+
};
|
645
|
+
|
646
|
+
struct ffi_pa32_trampoline_struct
|
647
|
+
{
|
648
|
+
UINT32 code_pointer; /* Pointer to ffi_closure_unix. */
|
649
|
+
UINT32 fake_gp; /* Pointer to closure, installed as gp. */
|
650
|
+
UINT32 real_gp; /* Real gp value. */
|
651
|
+
};
|
652
|
+
|
653
|
+
struct ffi_pa32_trampoline_struct *tramp;
|
654
|
+
struct pa32_fd *fd;
|
637
655
|
|
638
656
|
if (cif->abi != FFI_PA32)
|
639
657
|
return FFI_BAD_ABI;
|
640
658
|
|
641
|
-
/*
|
642
|
-
|
643
|
-
|
644
|
-
#ifdef PA_LINUX
|
645
|
-
tramp[0] = 0xeaa00000; /* b,l .+8,%r21 ; %r21 <- pc+8 */
|
646
|
-
tramp[1] = 0xd6a01c1e; /* depi 0,31,2,%r21 ; mask priv bits */
|
647
|
-
tramp[2] = 0x4aa10028; /* ldw 20(%r21),%r1 ; load plabel */
|
648
|
-
tramp[3] = 0x36b53ff1; /* ldo -8(%r21),%r21 ; get closure addr */
|
649
|
-
tramp[4] = 0x0c201096; /* ldw 0(%r1),%r22 ; address of handler */
|
650
|
-
tramp[5] = 0xeac0c000; /* bv%r0(%r22) ; branch to handler */
|
651
|
-
tramp[6] = 0x0c281093; /* ldw 4(%r1),%r19 ; GP of handler */
|
652
|
-
tramp[7] = ((UINT32)(ffi_closure_pa32) & ~2);
|
653
|
-
|
654
|
-
/* Flush d/icache -- have to flush up 2 two lines because of
|
655
|
-
alignment. */
|
656
|
-
__asm__ volatile(
|
657
|
-
"fdc 0(%0)\n\t"
|
658
|
-
"fdc %1(%0)\n\t"
|
659
|
-
"fic 0(%%sr4, %0)\n\t"
|
660
|
-
"fic %1(%%sr4, %0)\n\t"
|
661
|
-
"sync\n\t"
|
662
|
-
"nop\n\t"
|
663
|
-
"nop\n\t"
|
664
|
-
"nop\n\t"
|
665
|
-
"nop\n\t"
|
666
|
-
"nop\n\t"
|
667
|
-
"nop\n\t"
|
668
|
-
"nop\n"
|
669
|
-
:
|
670
|
-
: "r"((unsigned long)tramp & ~31),
|
671
|
-
"r"(32 /* stride */)
|
672
|
-
: "memory");
|
673
|
-
#endif
|
659
|
+
/* Get function descriptor address for ffi_closure_pa32. */
|
660
|
+
fd = (struct pa32_fd *)((UINT32)ffi_closure_pa32 & ~3);
|
674
661
|
|
675
|
-
|
676
|
-
tramp
|
677
|
-
tramp
|
678
|
-
tramp
|
679
|
-
tramp
|
680
|
-
tramp[4] = 0x0c201096; /* ldw 0(%r1),%r22 ; address of handler */
|
681
|
-
tramp[5] = 0x02c010b4; /* ldsid (%r22),%r20 ; load space id */
|
682
|
-
tramp[6] = 0x00141820; /* mtsp %r20,%sr0 ; into %sr0 */
|
683
|
-
tramp[7] = 0xe2c00000; /* be 0(%sr0,%r22) ; branch to handler */
|
684
|
-
tramp[8] = 0x0c281093; /* ldw 4(%r1),%r19 ; GP of handler */
|
685
|
-
tramp[9] = ((UINT32)(ffi_closure_pa32) & ~2);
|
686
|
-
|
687
|
-
/* Flush d/icache -- have to flush three lines because of alignment. */
|
688
|
-
__asm__ volatile(
|
689
|
-
"copy %1,%0\n\t"
|
690
|
-
"fdc,m %2(%0)\n\t"
|
691
|
-
"fdc,m %2(%0)\n\t"
|
692
|
-
"fdc,m %2(%0)\n\t"
|
693
|
-
"ldsid (%1),%0\n\t"
|
694
|
-
"mtsp %0,%%sr0\n\t"
|
695
|
-
"copy %1,%0\n\t"
|
696
|
-
"fic,m %2(%%sr0,%0)\n\t"
|
697
|
-
"fic,m %2(%%sr0,%0)\n\t"
|
698
|
-
"fic,m %2(%%sr0,%0)\n\t"
|
699
|
-
"sync\n\t"
|
700
|
-
"nop\n\t"
|
701
|
-
"nop\n\t"
|
702
|
-
"nop\n\t"
|
703
|
-
"nop\n\t"
|
704
|
-
"nop\n\t"
|
705
|
-
"nop\n\t"
|
706
|
-
"nop\n"
|
707
|
-
: "=&r" ((unsigned long)tmp)
|
708
|
-
: "r" ((unsigned long)tramp & ~31),
|
709
|
-
"r" (32/* stride */)
|
710
|
-
: "memory");
|
711
|
-
#endif
|
662
|
+
/* Setup trampoline. */
|
663
|
+
tramp = (struct ffi_pa32_trampoline_struct *)c->tramp;
|
664
|
+
tramp->code_pointer = fd->code_pointer;
|
665
|
+
tramp->fake_gp = (UINT32)codeloc & ~3;
|
666
|
+
tramp->real_gp = fd->gp;
|
712
667
|
|
713
|
-
|
714
|
-
|
715
|
-
|
668
|
+
c->cif = cif;
|
669
|
+
c->user_data = user_data;
|
670
|
+
c->fun = fun;
|
716
671
|
|
717
672
|
return FFI_OK;
|
718
673
|
}
|
@@ -68,12 +68,7 @@ typedef enum ffi_abi {
|
|
68
68
|
|
69
69
|
#define FFI_CLOSURES 1
|
70
70
|
#define FFI_NATIVE_RAW_API 0
|
71
|
-
|
72
|
-
#ifdef PA_LINUX
|
73
|
-
#define FFI_TRAMPOLINE_SIZE 32
|
74
|
-
#else
|
75
|
-
#define FFI_TRAMPOLINE_SIZE 40
|
76
|
-
#endif
|
71
|
+
#define FFI_TRAMPOLINE_SIZE 12
|
77
72
|
|
78
73
|
#define FFI_TYPE_SMALL_STRUCT2 -1
|
79
74
|
#define FFI_TYPE_SMALL_STRUCT3 -2
|
@@ -259,7 +259,7 @@ L$done
|
|
259
259
|
L$FE1
|
260
260
|
|
261
261
|
/* void ffi_closure_pa32(void);
|
262
|
-
Called with closure argument in %
|
262
|
+
Called with closure argument in %r19 */
|
263
263
|
|
264
264
|
.SPACE $TEXT$
|
265
265
|
.SUBSPA $CODE$
|
@@ -285,7 +285,9 @@ L$CFI22
|
|
285
285
|
stw %arg2, -44(%r3)
|
286
286
|
stw %arg3, -48(%r3)
|
287
287
|
|
288
|
-
|
288
|
+
/* Retrieve closure pointer and real gp. */
|
289
|
+
copy %r19, %arg0
|
290
|
+
ldw 8(%r19), %r19
|
289
291
|
bl ffi_closure_inner_pa32, %r2
|
290
292
|
copy %r3, %arg1
|
291
293
|
ldwm -64(%sp), %r3
|
@@ -252,7 +252,7 @@ ffi_call_pa32:
|
|
252
252
|
.LFE1:
|
253
253
|
|
254
254
|
/* void ffi_closure_pa32(void);
|
255
|
-
Called with closure argument in %
|
255
|
+
Called with closure argument in %r19 */
|
256
256
|
.export ffi_closure_pa32,code
|
257
257
|
.import ffi_closure_inner_pa32,code
|
258
258
|
|
@@ -277,7 +277,9 @@ ffi_closure_pa32:
|
|
277
277
|
stw %arg2, -44(%r3)
|
278
278
|
stw %arg3, -48(%r3)
|
279
279
|
|
280
|
-
|
280
|
+
/* Retrieve closure pointer and real gp. */
|
281
|
+
copy %r19, %arg0
|
282
|
+
ldw 8(%r19), %r19
|
281
283
|
bl ffi_closure_inner_pa32, %r2
|
282
284
|
copy %r3, %arg1
|
283
285
|
|
@@ -33,7 +33,10 @@
|
|
33
33
|
#include <stdlib.h>
|
34
34
|
|
35
35
|
extern void ffi_closure_ASM (void);
|
36
|
+
|
37
|
+
#if defined (FFI_GO_CLOSURES)
|
36
38
|
extern void ffi_go_closure_ASM (void);
|
39
|
+
#endif
|
37
40
|
|
38
41
|
enum {
|
39
42
|
/* The assembly depends on these exact flags.
|
@@ -909,8 +912,10 @@ ffi_prep_cif_machdep (ffi_cif *cif)
|
|
909
912
|
extern void ffi_call_AIX(extended_cif *, long, unsigned, unsigned *,
|
910
913
|
void (*fn)(void), void (*fn2)(void));
|
911
914
|
|
915
|
+
#if defined (FFI_GO_CLOSURES)
|
912
916
|
extern void ffi_call_go_AIX(extended_cif *, long, unsigned, unsigned *,
|
913
917
|
void (*fn)(void), void (*fn2)(void), void *closure);
|
918
|
+
#endif
|
914
919
|
|
915
920
|
extern void ffi_call_DARWIN(extended_cif *, long, unsigned, unsigned *,
|
916
921
|
void (*fn)(void), void (*fn2)(void), ffi_type*);
|
@@ -950,6 +955,7 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
|
|
950
955
|
}
|
951
956
|
}
|
952
957
|
|
958
|
+
#if defined (FFI_GO_CLOSURES)
|
953
959
|
void
|
954
960
|
ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue,
|
955
961
|
void *closure)
|
@@ -981,6 +987,7 @@ ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue,
|
|
981
987
|
break;
|
982
988
|
}
|
983
989
|
}
|
990
|
+
#endif
|
984
991
|
|
985
992
|
static void flush_icache(char *);
|
986
993
|
static void flush_range(char *, int);
|
@@ -1110,6 +1117,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
|
|
1110
1117
|
return FFI_OK;
|
1111
1118
|
}
|
1112
1119
|
|
1120
|
+
#if defined (FFI_GO_CLOSURES)
|
1113
1121
|
ffi_status
|
1114
1122
|
ffi_prep_go_closure (ffi_go_closure* closure,
|
1115
1123
|
ffi_cif* cif,
|
@@ -1133,6 +1141,7 @@ ffi_prep_go_closure (ffi_go_closure* closure,
|
|
1133
1141
|
}
|
1134
1142
|
return FFI_OK;
|
1135
1143
|
}
|
1144
|
+
#endif
|
1136
1145
|
|
1137
1146
|
static void
|
1138
1147
|
flush_icache(char *addr)
|
@@ -1168,9 +1177,11 @@ ffi_type *
|
|
1168
1177
|
ffi_closure_helper_DARWIN (ffi_closure *, void *,
|
1169
1178
|
unsigned long *, ffi_dblfl *);
|
1170
1179
|
|
1180
|
+
#if defined (FFI_GO_CLOSURES)
|
1171
1181
|
ffi_type *
|
1172
1182
|
ffi_go_closure_helper_DARWIN (ffi_go_closure*, void *,
|
1173
1183
|
unsigned long *, ffi_dblfl *);
|
1184
|
+
#endif
|
1174
1185
|
|
1175
1186
|
/* Basically the trampoline invokes ffi_closure_ASM, and on
|
1176
1187
|
entry, r11 holds the address of the closure.
|
@@ -1430,6 +1441,7 @@ ffi_closure_helper_DARWIN (ffi_closure *closure, void *rvalue,
|
|
1430
1441
|
closure->user_data, rvalue, pgr, pfr);
|
1431
1442
|
}
|
1432
1443
|
|
1444
|
+
#if defined (FFI_GO_CLOSURES)
|
1433
1445
|
ffi_type *
|
1434
1446
|
ffi_go_closure_helper_DARWIN (ffi_go_closure *closure, void *rvalue,
|
1435
1447
|
unsigned long *pgr, ffi_dblfl *pfr)
|
@@ -1437,4 +1449,4 @@ ffi_go_closure_helper_DARWIN (ffi_go_closure *closure, void *rvalue,
|
|
1437
1449
|
return ffi_closure_helper_common (closure->cif, closure->fun,
|
1438
1450
|
closure, rvalue, pgr, pfr);
|
1439
1451
|
}
|
1440
|
-
|
1452
|
+
#endif
|
@@ -36,8 +36,10 @@
|
|
36
36
|
.cfi_startproc
|
37
37
|
# if _CALL_ELF == 2
|
38
38
|
ffi_call_LINUX64:
|
39
|
+
# ifndef __PCREL__
|
39
40
|
addis %r2, %r12, .TOC.-ffi_call_LINUX64@ha
|
40
41
|
addi %r2, %r2, .TOC.-ffi_call_LINUX64@l
|
42
|
+
# endif
|
41
43
|
.localentry ffi_call_LINUX64, . - ffi_call_LINUX64
|
42
44
|
# else
|
43
45
|
.section ".opd","aw"
|
@@ -89,9 +91,15 @@ ffi_call_LINUX64:
|
|
89
91
|
/* Call ffi_prep_args64. */
|
90
92
|
mr %r4, %r1
|
91
93
|
# if defined _CALL_LINUX || _CALL_ELF == 2
|
94
|
+
# ifdef __PCREL__
|
95
|
+
bl ffi_prep_args64@notoc
|
96
|
+
# else
|
92
97
|
bl ffi_prep_args64
|
98
|
+
nop
|
99
|
+
# endif
|
93
100
|
# else
|
94
101
|
bl .ffi_prep_args64
|
102
|
+
nop
|
95
103
|
# endif
|
96
104
|
|
97
105
|
# if _CALL_ELF == 2
|
@@ -37,8 +37,10 @@
|
|
37
37
|
.cfi_startproc
|
38
38
|
# if _CALL_ELF == 2
|
39
39
|
ffi_closure_LINUX64:
|
40
|
+
# ifndef __PCREL__
|
40
41
|
addis %r2, %r12, .TOC.-ffi_closure_LINUX64@ha
|
41
42
|
addi %r2, %r2, .TOC.-ffi_closure_LINUX64@l
|
43
|
+
# endif
|
42
44
|
.localentry ffi_closure_LINUX64, . - ffi_closure_LINUX64
|
43
45
|
# else
|
44
46
|
.section ".opd","aw"
|
@@ -190,11 +192,19 @@ ffi_closure_LINUX64:
|
|
190
192
|
|
191
193
|
# make the call
|
192
194
|
# if defined _CALL_LINUX || _CALL_ELF == 2
|
195
|
+
# ifdef __PCREL__
|
196
|
+
bl ffi_closure_helper_LINUX64@notoc
|
197
|
+
.Lret:
|
198
|
+
# else
|
193
199
|
bl ffi_closure_helper_LINUX64
|
200
|
+
.Lret:
|
201
|
+
nop
|
202
|
+
# endif
|
194
203
|
# else
|
195
204
|
bl .ffi_closure_helper_LINUX64
|
196
|
-
# endif
|
197
205
|
.Lret:
|
206
|
+
nop
|
207
|
+
# endif
|
198
208
|
|
199
209
|
# now r3 contains the return type
|
200
210
|
# so use it to look up in a table
|
@@ -460,8 +470,10 @@ ffi_closure_LINUX64:
|
|
460
470
|
.cfi_startproc
|
461
471
|
# if _CALL_ELF == 2
|
462
472
|
ffi_go_closure_linux64:
|
473
|
+
# ifndef __PCREL__
|
463
474
|
addis %r2, %r12, .TOC.-ffi_go_closure_linux64@ha
|
464
475
|
addi %r2, %r2, .TOC.-ffi_go_closure_linux64@l
|
476
|
+
# endif
|
465
477
|
.localentry ffi_go_closure_linux64, . - ffi_go_closure_linux64
|
466
478
|
# else
|
467
479
|
.section ".opd","aw"
|