ffi 1.12.0 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +79 -0
  3. data/Gemfile +4 -2
  4. data/README.md +10 -2
  5. data/Rakefile +24 -43
  6. data/ext/ffi_c/AbstractMemory.c +25 -26
  7. data/ext/ffi_c/Buffer.c +4 -9
  8. data/ext/ffi_c/Call.c +3 -14
  9. data/ext/ffi_c/ClosurePool.c +75 -25
  10. data/ext/ffi_c/ClosurePool.h +3 -1
  11. data/ext/ffi_c/DynamicLibrary.c +1 -6
  12. data/ext/ffi_c/Function.c +15 -35
  13. data/ext/ffi_c/FunctionInfo.c +3 -8
  14. data/ext/ffi_c/LastError.c +2 -6
  15. data/ext/ffi_c/LongDouble.c +5 -3
  16. data/ext/ffi_c/LongDouble.h +0 -4
  17. data/ext/ffi_c/MemoryPointer.c +3 -8
  18. data/ext/ffi_c/MethodHandle.c +21 -31
  19. data/ext/ffi_c/MethodHandle.h +3 -2
  20. data/ext/ffi_c/Platform.c +3 -7
  21. data/ext/ffi_c/Pointer.c +25 -26
  22. data/ext/ffi_c/Struct.c +49 -56
  23. data/ext/ffi_c/Struct.h +12 -6
  24. data/ext/ffi_c/StructByValue.c +2 -7
  25. data/ext/ffi_c/StructLayout.c +22 -19
  26. data/ext/ffi_c/Thread.c +0 -8
  27. data/ext/ffi_c/Thread.h +1 -9
  28. data/ext/ffi_c/Type.c +1 -1
  29. data/ext/ffi_c/Variadic.c +2 -7
  30. data/ext/ffi_c/compat.h +4 -0
  31. data/ext/ffi_c/extconf.rb +33 -24
  32. data/ext/ffi_c/libffi/.travis.yml +4 -0
  33. data/ext/ffi_c/libffi/.travis/bfin-sim.exp +1 -1
  34. data/ext/ffi_c/libffi/.travis/build.sh +4 -0
  35. data/ext/ffi_c/libffi/.travis/m32r-sim.exp +1 -1
  36. data/ext/ffi_c/libffi/.travis/moxie-sim.exp +1 -1
  37. data/ext/ffi_c/libffi/.travis/or1k-sim.exp +1 -1
  38. data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +1 -1
  39. data/ext/ffi_c/libffi/.travis/wine-sim.exp +1 -1
  40. data/ext/ffi_c/libffi/Makefile.am +49 -58
  41. data/ext/ffi_c/libffi/README.md +11 -1
  42. data/ext/ffi_c/libffi/config.guess +552 -331
  43. data/ext/ffi_c/libffi/config.sub +1321 -1306
  44. data/ext/ffi_c/libffi/configure.ac +31 -10
  45. data/ext/ffi_c/libffi/configure.host +32 -20
  46. data/ext/ffi_c/libffi/doc/Makefile.am +3 -0
  47. data/ext/ffi_c/libffi/doc/libffi.texi +997 -0
  48. data/ext/ffi_c/libffi/doc/version.texi +4 -0
  49. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +1 -1
  50. data/ext/ffi_c/libffi/include/ffi.h.in +8 -0
  51. data/ext/ffi_c/libffi/libffi.map.in +8 -12
  52. data/ext/ffi_c/libffi/libtool-version +1 -1
  53. data/ext/ffi_c/libffi/msvcc.sh +11 -11
  54. data/ext/ffi_c/libffi/src/aarch64/ffi.c +51 -35
  55. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +10 -5
  56. data/ext/ffi_c/libffi/src/aarch64/internal.h +1 -0
  57. data/ext/ffi_c/libffi/src/aarch64/sysv.S +14 -3
  58. data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +1 -1
  59. data/ext/ffi_c/libffi/src/arm/ffi.c +22 -0
  60. data/ext/ffi_c/libffi/src/arm/sysv.S +4 -4
  61. data/ext/ffi_c/libffi/src/closures.c +33 -10
  62. data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
  63. data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
  64. data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
  65. data/ext/ffi_c/libffi/src/dlmalloc.c +1 -1
  66. data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
  67. data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
  68. data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
  69. data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
  70. data/ext/ffi_c/libffi/src/mips/ffi.c +5 -1
  71. data/ext/ffi_c/libffi/src/mips/ffitarget.h +1 -1
  72. data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
  73. data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
  74. data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
  75. data/ext/ffi_c/libffi/src/pa/linux.S +4 -2
  76. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +13 -1
  77. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +1 -1
  78. data/ext/ffi_c/libffi/src/powerpc/linux64.S +8 -0
  79. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +13 -1
  80. data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
  81. data/ext/ffi_c/libffi/src/prep_cif.c +1 -1
  82. data/ext/ffi_c/libffi/src/x86/ffi.c +15 -6
  83. data/ext/ffi_c/libffi/src/x86/ffi64.c +17 -8
  84. data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
  85. data/ext/ffi_c/libffi/src/x86/ffiw64.c +15 -8
  86. data/ext/ffi_c/libffi/src/x86/sysv.S +15 -6
  87. data/ext/ffi_c/libffi/src/x86/unix64.S +59 -4
  88. data/ext/ffi_c/libffi/src/x86/win64.S +7 -3
  89. data/ext/ffi_c/libffi/src/x86/win64_intel.S +3 -2
  90. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +22 -2
  91. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +4 -4
  92. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2 -2
  93. data/ext/ffi_c/libffi/testsuite/libffi.closures/huge_struct.c +2 -0
  94. data/ffi.gemspec +2 -2
  95. data/lib/ffi.rb +10 -2
  96. data/lib/ffi/abstract_memory.rb +44 -0
  97. data/lib/ffi/ffi.rb +1 -0
  98. data/lib/ffi/library.rb +6 -2
  99. data/lib/ffi/platform.rb +21 -8
  100. data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
  101. data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
  102. data/lib/ffi/platform/arm-linux/types.conf +32 -4
  103. data/lib/ffi/platform/i386-windows/types.conf +26 -79
  104. data/lib/ffi/platform/powerpc-linux/types.conf +32 -2
  105. data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
  106. data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
  107. data/lib/ffi/platform/x86_64-darwin/types.conf +4 -0
  108. data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +4 -22
  109. data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
  110. data/lib/ffi/platform/x86_64-linux/types.conf +21 -0
  111. data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
  112. data/lib/ffi/platform/x86_64-windows/types.conf +10 -78
  113. data/lib/ffi/pointer.rb +40 -19
  114. data/lib/ffi/struct.rb +9 -4
  115. data/lib/ffi/tools/types_generator.rb +2 -0
  116. data/lib/ffi/version.rb +1 -1
  117. data/samples/getlogin.rb +1 -1
  118. data/samples/getpid.rb +1 -1
  119. data/samples/gettimeofday.rb +8 -8
  120. data/samples/hello.rb +2 -1
  121. data/samples/inotify.rb +1 -1
  122. data/samples/pty.rb +1 -2
  123. data/samples/qsort.rb +0 -1
  124. metadata +18 -12
  125. data/.appveyor.yml +0 -27
  126. data/.gitignore +0 -25
  127. data/.gitmodules +0 -4
  128. data/.travis.yml +0 -44
  129. data/.yardopts +0 -5
  130. data/ext/ffi_c/win32/stdbool.h +0 -8
  131. data/ext/ffi_c/win32/stdint.h +0 -201
  132. 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(__OpenBSD__)
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
 
@@ -41,7 +41,7 @@
41
41
  #define _MIPS_SIM_ABI32 1
42
42
  #define _MIPS_SIM_NABI32 2
43
43
  #define _MIPS_SIM_ABI64 3
44
- #elif !defined(__OpenBSD__)
44
+ #elif !defined(__OpenBSD__) && !defined(__FreeBSD__)
45
45
  # include <sgidefs.h>
46
46
  #endif
47
47
 
@@ -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
- UINT32 ret[2]; /* function can return up to 64-bits in registers */
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 = &ret[0];
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
- (closure->fun) (cif, rvalue, avalue, closure->user_data);
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, &ret[0], cif->rtype->size);
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, ret, 8 - 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
- UINT32 *tramp = (UINT32 *)(closure->tramp);
634
- #ifdef PA_HPUX
635
- UINT32 *tmp;
636
- #endif
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
- /* Make a small trampoline that will branch to our
642
- handler function. Use PC-relative addressing. */
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
- #ifdef PA_HPUX
676
- tramp[0] = 0xeaa00000; /* b,l .+8,%r21 ; %r21 <- pc+8 */
677
- tramp[1] = 0xd6a01c1e; /* depi 0,31,2,%r21 ; mask priv bits */
678
- tramp[2] = 0x4aa10038; /* ldw 28(%r21),%r1 ; load plabel */
679
- tramp[3] = 0x36b53ff1; /* ldo -8(%r21),%r21 ; get closure addr */
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
- closure->cif = cif;
714
- closure->user_data = user_data;
715
- closure->fun = fun;
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 %r21 */
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
- copy %r21, %arg0
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 %r21 */
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
- copy %r21, %arg0
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
@@ -57,7 +57,7 @@ typedef union
57
57
  double d;
58
58
  } ffi_dblfl;
59
59
 
60
- #if defined(__FLOAT128_TYPE__)
60
+ #if defined(__FLOAT128_TYPE__) && defined(__HAVE_FLOAT128)
61
61
  typedef _Float128 float128;
62
62
  #elif defined(__FLOAT128__)
63
63
  typedef __float128 float128;
@@ -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"