ffi 1.13.1 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +64 -0
  3. data/Gemfile +1 -4
  4. data/README.md +10 -2
  5. data/Rakefile +23 -23
  6. data/ext/ffi_c/AbstractMemory.c +24 -25
  7. data/ext/ffi_c/Buffer.c +2 -7
  8. data/ext/ffi_c/Call.c +2 -8
  9. data/ext/ffi_c/ClosurePool.c +64 -11
  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 +31 -16
  13. data/ext/ffi_c/Function.h +0 -4
  14. data/ext/ffi_c/FunctionInfo.c +2 -6
  15. data/ext/ffi_c/LastError.c +2 -6
  16. data/ext/ffi_c/MemoryPointer.c +2 -7
  17. data/ext/ffi_c/MemoryPointer.h +0 -4
  18. data/ext/ffi_c/MethodHandle.c +4 -8
  19. data/ext/ffi_c/Platform.c +2 -7
  20. data/ext/ffi_c/Pointer.c +24 -25
  21. data/ext/ffi_c/Pointer.h +0 -4
  22. data/ext/ffi_c/Struct.c +3 -6
  23. data/ext/ffi_c/StructByValue.c +2 -7
  24. data/ext/ffi_c/StructLayout.c +2 -6
  25. data/ext/ffi_c/Thread.c +0 -5
  26. data/ext/ffi_c/Thread.h +1 -6
  27. data/ext/ffi_c/Type.c +1 -1
  28. data/ext/ffi_c/Types.c +6 -7
  29. data/ext/ffi_c/Types.h +3 -4
  30. data/ext/ffi_c/Variadic.c +14 -9
  31. data/ext/ffi_c/extconf.rb +17 -4
  32. data/ext/ffi_c/libffi/.travis/bfin-sim.exp +1 -1
  33. data/ext/ffi_c/libffi/.travis/m32r-sim.exp +1 -1
  34. data/ext/ffi_c/libffi/.travis/moxie-sim.exp +1 -1
  35. data/ext/ffi_c/libffi/.travis/or1k-sim.exp +1 -1
  36. data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +1 -1
  37. data/ext/ffi_c/libffi/.travis/wine-sim.exp +1 -1
  38. data/ext/ffi_c/libffi/Makefile.am +48 -58
  39. data/ext/ffi_c/libffi/README.md +4 -0
  40. data/ext/ffi_c/libffi/config.guess +552 -331
  41. data/ext/ffi_c/libffi/config.sub +1321 -1306
  42. data/ext/ffi_c/libffi/configure.ac +6 -1
  43. data/ext/ffi_c/libffi/configure.host +32 -20
  44. data/ext/ffi_c/libffi/doc/Makefile.am +3 -0
  45. data/ext/ffi_c/libffi/doc/libffi.texi +997 -0
  46. data/ext/ffi_c/libffi/doc/version.texi +4 -0
  47. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +1 -1
  48. data/ext/ffi_c/libffi/msvcc.sh +11 -11
  49. data/ext/ffi_c/libffi/src/aarch64/ffi.c +45 -35
  50. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +10 -5
  51. data/ext/ffi_c/libffi/src/aarch64/internal.h +1 -0
  52. data/ext/ffi_c/libffi/src/aarch64/sysv.S +1 -1
  53. data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +1 -1
  54. data/ext/ffi_c/libffi/src/arm/ffi.c +22 -0
  55. data/ext/ffi_c/libffi/src/arm/sysv.S +4 -4
  56. data/ext/ffi_c/libffi/src/closures.c +23 -6
  57. data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
  58. data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
  59. data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
  60. data/ext/ffi_c/libffi/src/dlmalloc.c +1 -1
  61. data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
  62. data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
  63. data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
  64. data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
  65. data/ext/ffi_c/libffi/src/mips/ffi.c +5 -1
  66. data/ext/ffi_c/libffi/src/mips/ffitarget.h +1 -1
  67. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +13 -1
  68. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +1 -1
  69. data/ext/ffi_c/libffi/src/powerpc/linux64.S +8 -0
  70. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +13 -1
  71. data/ext/ffi_c/libffi/src/prep_cif.c +1 -1
  72. data/ext/ffi_c/libffi/src/x86/ffi.c +8 -2
  73. data/ext/ffi_c/libffi/src/x86/ffi64.c +7 -0
  74. data/ext/ffi_c/libffi/src/x86/ffiw64.c +5 -0
  75. data/ext/ffi_c/libffi/src/x86/sysv.S +2 -2
  76. data/ext/ffi_c/libffi/src/x86/unix64.S +1 -2
  77. data/ext/ffi_c/libffi/src/x86/win64.S +3 -2
  78. data/ext/ffi_c/libffi/src/x86/win64_intel.S +3 -2
  79. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +22 -2
  80. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +4 -4
  81. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2 -2
  82. data/ext/ffi_c/libffi/testsuite/libffi.closures/huge_struct.c +2 -0
  83. data/ffi.gemspec +1 -1
  84. data/lib/ffi.rb +2 -2
  85. data/lib/ffi/abstract_memory.rb +44 -0
  86. data/lib/ffi/autopointer.rb +1 -1
  87. data/lib/ffi/ffi.rb +1 -0
  88. data/lib/ffi/io.rb +3 -3
  89. data/lib/ffi/library.rb +1 -1
  90. data/lib/ffi/managedstruct.rb +2 -2
  91. data/lib/ffi/platform.rb +15 -6
  92. data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
  93. data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
  94. data/lib/ffi/platform/powerpc64le-linux/types.conf +100 -0
  95. data/lib/ffi/platform/riscv64-linux/types.conf +104 -0
  96. data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
  97. data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
  98. data/lib/ffi/pointer.rb +2 -2
  99. data/lib/ffi/variadic.rb +1 -10
  100. data/lib/ffi/version.rb +1 -1
  101. data/rakelib/ffi_gem_helper.rb +65 -0
  102. metadata +18 -11
  103. data/.appveyor.yml +0 -30
  104. data/.github/workflows/ci.yml +0 -64
  105. data/.gitignore +0 -25
  106. data/.gitmodules +0 -4
  107. data/.travis.yml +0 -58
  108. data/.yardopts +0 -5
  109. data/ext/ffi_c/win32/stdbool.h +0 -8
  110. data/ext/ffi_c/win32/stdint.h +0 -201
@@ -0,0 +1,75 @@
1
+ /* -----------------------------------------------------------------------
2
+ ffitarget.h - Copyright (c) 2020 Kalray
3
+
4
+ KVX Target configuration macros
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ ``Software''), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included
15
+ in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24
+ DEALINGS IN THE SOFTWARE.
25
+ ----------------------------------------------------------------------- */
26
+
27
+ #ifndef LIBFFI_TARGET_H
28
+ #define LIBFFI_TARGET_H
29
+
30
+ #ifndef LIBFFI_H
31
+ #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
32
+ #endif
33
+
34
+ /* ---- System specific configurations ----------------------------------- */
35
+
36
+ #ifndef LIBFFI_ASM
37
+ typedef unsigned long ffi_arg;
38
+ typedef signed long ffi_sarg;
39
+
40
+ typedef enum ffi_abi {
41
+ FFI_FIRST_ABI = 0,
42
+ FFI_SYSV,
43
+ FFI_LAST_ABI,
44
+ FFI_DEFAULT_ABI = FFI_SYSV
45
+ } ffi_abi;
46
+
47
+ /* Those values are set depending on return type
48
+ * they are used in the assembly code in sysv.S
49
+ */
50
+ typedef enum kvx_intext_method {
51
+ KVX_RET_NONE = 0,
52
+ KVX_RET_SXBD = 1,
53
+ KVX_RET_SXHD = 2,
54
+ KVX_RET_SXWD = 3,
55
+ KVX_RET_ZXBD = 4,
56
+ KVX_RET_ZXHD = 5,
57
+ KVX_RET_ZXWD = 6
58
+ } kvx_intext_method;
59
+
60
+ #endif
61
+
62
+ /* ---- Definitions for closures ----------------------------------------- */
63
+
64
+ /* This is only to allow Python to compile
65
+ * but closures are not supported yet
66
+ */
67
+ #define FFI_CLOSURES 1
68
+ #define FFI_TRAMPOLINE_SIZE 0
69
+
70
+ #define FFI_NATIVE_RAW_API 0
71
+ #define FFI_TARGET_SPECIFIC_VARIADIC 1
72
+ #define FFI_TARGET_HAS_COMPLEX_TYPE
73
+
74
+ #endif
75
+
@@ -0,0 +1,127 @@
1
+ /* Copyright (c) 2020 Kalray
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ ``Software''), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
21
+
22
+ #if defined(__kvx__)
23
+ #define LIBFFI_ASM
24
+ #include <fficonfig.h>
25
+ #include <ffi.h>
26
+ #include <ffi_cfi.h>
27
+ #include <kvx/asm.h>
28
+
29
+ .text
30
+ .global ffi_call_SYSV
31
+ .type ffi_call_SYSV, @function
32
+ .type ffi_prep_args, @function
33
+ .align 8
34
+
35
+ /* ffi_call_SYSV
36
+
37
+ r0: total size to allocate on stack
38
+ r1: size of arg slots
39
+ r2: extended cif structure, DO NOT REMOVE: it is used by ffi_prep_args()
40
+ r3: return value address
41
+ r4: function to call
42
+ r5: integer sign extension method to be used
43
+ */
44
+ ffi_call_SYSV:
45
+ addd $r12 = $r12, -64
46
+ so (-32)[$r12] = $r20r21r22r23
47
+ ;;
48
+ sd (0)[$r12] = $r24
49
+ ;;
50
+ get $r23 = $ra
51
+ copyd $r20 = $r12
52
+ sbfd $r12 = $r0, $r12
53
+ ;;
54
+ copyd $r0 = $r12
55
+ copyd $r21 = $r3
56
+ copyd $r22 = $r4
57
+ copyd $r24 = $r5
58
+ call ffi_prep_args
59
+ ;;
60
+ lo $r8r9r10r11 = (64)[$r12]
61
+ ;;
62
+ lo $r4r5r6r7 = (32)[$r12]
63
+ ;;
64
+ lo $r0r1r2r3 = (0)[$r12]
65
+ copyd $r12 = $r0
66
+ /* $r15 is the register used by the ABI to return big (>32 bytes)
67
+ * structs by value.
68
+ * It is also referred to as the "struct register" in the ABI.
69
+ */
70
+ copyd $r15 = $r21
71
+ icall $r22
72
+ ;;
73
+ pcrel $r4 = @pcrel(.Ltable)
74
+ cb.deqz $r24 ? .Lend
75
+ ;;
76
+ addx8d $r24 = $r24, $r4
77
+ ;;
78
+ igoto $r24
79
+ ;;
80
+ .Ltable:
81
+ 0: /* we should never arrive here */
82
+ goto .Lerror
83
+ nop
84
+ ;;
85
+ 1: /* Sign extend byte to double */
86
+ sxbd $r0 = $r0
87
+ goto .Lend
88
+ ;;
89
+ 2: /* Sign extend half to double */
90
+ sxhd $r0 = $r0
91
+ goto .Lend
92
+ ;;
93
+ 3: /* Sign extend word to double */
94
+ sxwd $r0 = $r0
95
+ goto .Lend
96
+ ;;
97
+ 4: /* Zero extend byte to double */
98
+ zxbd $r0 = $r0
99
+ goto .Lend
100
+ ;;
101
+ 5: /* Zero extend half to double */
102
+ zxhd $r0 = $r0
103
+ goto .Lend
104
+ ;;
105
+ 6: /* Zero extend word to double */
106
+ zxwd $r0 = $r0
107
+ /* Fallthrough to .Lend */
108
+ ;;
109
+ .Lend:
110
+ ld $r24 = (0)[$r12]
111
+ ;;
112
+ set $ra = $r23
113
+ lo $r20r21r22r23 = (32)[$r20]
114
+ addd $r12 = $r20, 64
115
+ ;;
116
+ ret
117
+ ;;
118
+ .Lerror:
119
+ errop
120
+ ;;
121
+
122
+ #endif /* __kvx__ */
123
+
124
+ #if defined __ELF__ && defined __linux__
125
+ .section .note.GNU-stack,"",%progbits
126
+ #endif
127
+
@@ -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
 
@@ -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"
@@ -129,7 +129,7 @@ ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi,
129
129
  cif->rtype = rtype;
130
130
 
131
131
  cif->flags = 0;
132
- #ifdef _M_ARM64
132
+ #if (defined(_M_ARM64) || defined(__aarch64__)) && defined(_WIN32)
133
133
  cif->is_variadic = isvariadic;
134
134
  #endif
135
135
  #if HAVE_LONG_DOUBLE_VARIANT
@@ -353,7 +353,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
353
353
  size_t align = FFI_SIZEOF_ARG;
354
354
 
355
355
  /* Issue 434: For thiscall and fastcall, if the paramter passed
356
- as 64-bit integer or struct, all following integer paramters
356
+ as 64-bit integer or struct, all following integer parameters
357
357
  will be passed on stack. */
358
358
  if ((cabi == FFI_THISCALL || cabi == FFI_FASTCALL)
359
359
  && (t == FFI_TYPE_SINT64
@@ -397,12 +397,14 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
397
397
  ffi_call_int (cif, fn, rvalue, avalue, NULL);
398
398
  }
399
399
 
400
+ #ifdef FFI_GO_CLOSURES
400
401
  void
401
402
  ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue,
402
403
  void **avalue, void *closure)
403
404
  {
404
405
  ffi_call_int (cif, fn, rvalue, avalue, closure);
405
406
  }
407
+ #endif
406
408
 
407
409
  /** private members **/
408
410
 
@@ -492,7 +494,7 @@ ffi_closure_inner (struct closure_frame *frame, char *stack)
492
494
  align = 16;
493
495
 
494
496
  /* Issue 434: For thiscall and fastcall, if the paramter passed
495
- as 64-bit integer or struct, all following integer paramters
497
+ as 64-bit integer or struct, all following integer parameters
496
498
  will be passed on stack. */
497
499
  if ((cabi == FFI_THISCALL || cabi == FFI_FASTCALL)
498
500
  && (t == FFI_TYPE_SINT64
@@ -575,6 +577,8 @@ ffi_prep_closure_loc (ffi_closure* closure,
575
577
  return FFI_OK;
576
578
  }
577
579
 
580
+ #ifdef FFI_GO_CLOSURES
581
+
578
582
  void FFI_HIDDEN ffi_go_closure_EAX(void);
579
583
  void FFI_HIDDEN ffi_go_closure_ECX(void);
580
584
  void FFI_HIDDEN ffi_go_closure_STDCALL(void);
@@ -611,6 +615,8 @@ ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif,
611
615
  return FFI_OK;
612
616
  }
613
617
 
618
+ #endif /* FFI_GO_CLOSURES */
619
+
614
620
  /* ------- Native raw API support -------------------------------- */
615
621
 
616
622
  #if !FFI_NO_RAW_API