ffi 1.13.0 → 1.15.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +127 -0
  3. data/Gemfile +1 -4
  4. data/README.md +14 -2
  5. data/Rakefile +43 -29
  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 +3 -9
  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 +4 -9
  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 +25 -10
  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/Makefile.in +420 -156
  40. data/ext/ffi_c/libffi/README.md +4 -0
  41. data/ext/ffi_c/libffi/config.guess +552 -331
  42. data/ext/ffi_c/libffi/config.sub +1321 -1306
  43. data/ext/ffi_c/libffi/configure +158 -96
  44. data/ext/ffi_c/libffi/configure.ac +6 -1
  45. data/ext/ffi_c/libffi/configure.host +32 -20
  46. data/ext/ffi_c/libffi/doc/Makefile.in +8 -5
  47. data/ext/ffi_c/libffi/fficonfig.h.in +6 -0
  48. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +1 -1
  49. data/ext/ffi_c/libffi/include/Makefile.in +8 -5
  50. data/ext/ffi_c/libffi/install-sh +23 -13
  51. data/ext/ffi_c/libffi/ltmain.sh +156 -61
  52. data/ext/ffi_c/libffi/man/Makefile.in +8 -5
  53. data/ext/ffi_c/libffi/missing +8 -8
  54. data/ext/ffi_c/libffi/msvcc.sh +11 -11
  55. data/ext/ffi_c/libffi/src/aarch64/ffi.c +45 -35
  56. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +10 -5
  57. data/ext/ffi_c/libffi/src/aarch64/internal.h +1 -0
  58. data/ext/ffi_c/libffi/src/aarch64/sysv.S +1 -1
  59. data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +1 -1
  60. data/ext/ffi_c/libffi/src/arm/ffi.c +22 -0
  61. data/ext/ffi_c/libffi/src/arm/sysv.S +4 -4
  62. data/ext/ffi_c/libffi/src/closures.c +23 -6
  63. data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
  64. data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
  65. data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
  66. data/ext/ffi_c/libffi/src/dlmalloc.c +1 -1
  67. data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
  68. data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
  69. data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
  70. data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
  71. data/ext/ffi_c/libffi/src/mips/ffi.c +5 -1
  72. data/ext/ffi_c/libffi/src/mips/ffitarget.h +1 -1
  73. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +13 -1
  74. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +1 -1
  75. data/ext/ffi_c/libffi/src/powerpc/linux64.S +8 -0
  76. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +13 -1
  77. data/ext/ffi_c/libffi/src/prep_cif.c +1 -1
  78. data/ext/ffi_c/libffi/src/x86/ffi.c +8 -2
  79. data/ext/ffi_c/libffi/src/x86/ffi64.c +7 -0
  80. data/ext/ffi_c/libffi/src/x86/ffiw64.c +5 -0
  81. data/ext/ffi_c/libffi/src/x86/sysv.S +2 -2
  82. data/ext/ffi_c/libffi/src/x86/unix64.S +1 -2
  83. data/ext/ffi_c/libffi/src/x86/win64.S +3 -2
  84. data/ext/ffi_c/libffi/src/x86/win64_intel.S +3 -2
  85. data/ext/ffi_c/libffi/testsuite/Makefile.in +9 -6
  86. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +22 -2
  87. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +4 -4
  88. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2 -2
  89. data/ext/ffi_c/libffi/testsuite/libffi.closures/huge_struct.c +2 -0
  90. data/ffi.gemspec +1 -2
  91. data/lib/ffi/abstract_memory.rb +44 -0
  92. data/lib/ffi/autopointer.rb +1 -1
  93. data/lib/ffi/ffi.rb +1 -0
  94. data/lib/ffi/io.rb +3 -3
  95. data/lib/ffi/library.rb +3 -3
  96. data/lib/ffi/managedstruct.rb +2 -2
  97. data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
  98. data/lib/ffi/platform/aarch64-freebsd/types.conf +2 -2
  99. data/lib/ffi/platform/aarch64-freebsd12/types.conf +113 -60
  100. data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
  101. data/lib/ffi/platform/powerpc64le-linux/types.conf +100 -0
  102. data/lib/ffi/platform/riscv64-linux/types.conf +104 -0
  103. data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +4 -22
  104. data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
  105. data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
  106. data/lib/ffi/platform.rb +17 -7
  107. data/lib/ffi/pointer.rb +2 -2
  108. data/lib/ffi/tools/const_generator.rb +6 -4
  109. data/lib/ffi/tools/struct_generator.rb +2 -1
  110. data/lib/ffi/variadic.rb +1 -10
  111. data/lib/ffi/version.rb +1 -1
  112. data/lib/ffi.rb +3 -4
  113. data/rakelib/ffi_gem_helper.rb +65 -0
  114. metadata +21 -28
  115. data/.appveyor.yml +0 -30
  116. data/.github/workflows/ci.yml +0 -64
  117. data/.gitignore +0 -25
  118. data/.gitmodules +0 -4
  119. data/.travis.yml +0 -58
  120. data/.yardopts +0 -5
  121. data/ext/ffi_c/win32/stdbool.h +0 -8
  122. 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
@@ -688,6 +688,8 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
688
688
  ffi_call_int (cif, fn, rvalue, avalue, NULL);
689
689
  }
690
690
 
691
+ #ifdef FFI_GO_CLOSURES
692
+
691
693
  #ifndef __ILP32__
692
694
  extern void
693
695
  ffi_call_go_efi64(ffi_cif *cif, void (*fn)(void), void *rvalue,
@@ -708,6 +710,7 @@ ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue,
708
710
  ffi_call_int (cif, fn, rvalue, avalue, closure);
709
711
  }
710
712
 
713
+ #endif /* FFI_GO_CLOSURES */
711
714
 
712
715
  extern void ffi_closure_unix64(void) FFI_HIDDEN;
713
716
  extern void ffi_closure_unix64_sse(void) FFI_HIDDEN;
@@ -856,6 +859,8 @@ ffi_closure_unix64_inner(ffi_cif *cif,
856
859
  return flags;
857
860
  }
858
861
 
862
+ #ifdef FFI_GO_CLOSURES
863
+
859
864
  extern void ffi_go_closure_unix64(void) FFI_HIDDEN;
860
865
  extern void ffi_go_closure_unix64_sse(void) FFI_HIDDEN;
861
866
 
@@ -885,4 +890,6 @@ ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif,
885
890
  return FFI_OK;
886
891
  }
887
892
 
893
+ #endif /* FFI_GO_CLOSURES */
894
+
888
895
  #endif /* __x86_64__ */
@@ -187,7 +187,10 @@ EFI64(ffi_call_go)(ffi_cif *cif, void (*fn)(void), void *rvalue,
187
187
 
188
188
 
189
189
  extern void ffi_closure_win64(void) FFI_HIDDEN;
190
+
191
+ #ifdef FFI_GO_CLOSURES
190
192
  extern void ffi_go_closure_win64(void) FFI_HIDDEN;
193
+ #endif
191
194
 
192
195
  ffi_status
193
196
  EFI64(ffi_prep_closure_loc)(ffi_closure* closure,
@@ -227,6 +230,7 @@ EFI64(ffi_prep_closure_loc)(ffi_closure* closure,
227
230
  return FFI_OK;
228
231
  }
229
232
 
233
+ #ifdef FFI_GO_CLOSURES
230
234
  ffi_status
231
235
  EFI64(ffi_prep_go_closure)(ffi_go_closure* closure, ffi_cif* cif,
232
236
  void (*fun)(ffi_cif*, void*, void**, void*))
@@ -246,6 +250,7 @@ EFI64(ffi_prep_go_closure)(ffi_go_closure* closure, ffi_cif* cif,
246
250
 
247
251
  return FFI_OK;
248
252
  }
253
+ #endif
249
254
 
250
255
  struct win64_closure_frame
251
256
  {
@@ -56,8 +56,8 @@
56
56
 
57
57
  /* Handle win32 fastcall name mangling. */
58
58
  #ifdef X86_WIN32
59
- # define ffi_call_i386 @ffi_call_i386@8
60
- # define ffi_closure_inner @ffi_closure_inner@8
59
+ # define ffi_call_i386 "@ffi_call_i386@8"
60
+ # define ffi_closure_inner "@ffi_closure_inner@8"
61
61
  #else
62
62
  # define ffi_call_i386 C(ffi_call_i386)
63
63
  # define ffi_closure_inner C(ffi_closure_inner)
@@ -84,7 +84,6 @@ L(UW1):
84
84
 
85
85
  movq %rdi, %r10 /* Save a copy of the register area. */
86
86
  movq %r8, %r11 /* Save a copy of the target fn. */
87
- movl %r9d, %eax /* Set number of SSE registers. */
88
87
 
89
88
  /* Load up all argument registers. */
90
89
  movq (%r10), %rdi
@@ -93,7 +92,7 @@ L(UW1):
93
92
  movq 0x18(%r10), %rcx
94
93
  movq 0x20(%r10), %r8
95
94
  movq 0x28(%r10), %r9
96
- movl 0xb0(%r10), %eax
95
+ movl 0xb0(%r10), %eax /* Set number of SSE registers. */
97
96
  testl %eax, %eax
98
97
  jnz L(load_sse)
99
98
  L(ret_from_load_sse):
@@ -30,7 +30,7 @@
30
30
  #if defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__))
31
31
  # define E(BASE, X) .balign 8
32
32
  #else
33
- # define E(BASE, X) .balign 8; .org BASE + X * 8
33
+ # define E(BASE, X) .balign 8; .org BASE + (X) * 8
34
34
  #endif
35
35
 
36
36
  .text
@@ -108,7 +108,8 @@ E(0b, FFI_TYPE_FLOAT)
108
108
  E(0b, FFI_TYPE_DOUBLE)
109
109
  movsd %xmm0, (%r8)
110
110
  epilogue
111
- E(0b, FFI_TYPE_LONGDOUBLE)
111
+ // FFI_TYPE_LONGDOUBLE may be FFI_TYPE_DOUBLE but we need a different value here.
112
+ E(0b, FFI_TYPE_DOUBLE + 1)
112
113
  call PLT(C(abort))
113
114
  E(0b, FFI_TYPE_UINT8)
114
115
  movzbl %al, %eax
@@ -29,7 +29,7 @@
29
29
  #if defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__))
30
30
  # define E(BASE, X) ALIGN 8
31
31
  #else
32
- # define E(BASE, X) ALIGN 8; ORG BASE + X * 8
32
+ # define E(BASE, X) ALIGN 8; ORG BASE + (X) * 8
33
33
  #endif
34
34
 
35
35
  .CODE
@@ -107,7 +107,8 @@ E(0b, FFI_TYPE_FLOAT)
107
107
  E(0b, FFI_TYPE_DOUBLE)
108
108
  movsd qword ptr[r8], xmm0; movsd %xmm0, (%r8)
109
109
  epilogue
110
- E(0b, FFI_TYPE_LONGDOUBLE)
110
+ // FFI_TYPE_LONGDOUBLE may be FFI_TYPE_DOUBLE but we need a different value here.
111
+ E(0b, FFI_TYPE_DOUBLE + 1)
111
112
  call PLT(C(abort))
112
113
  E(0b, FFI_TYPE_UINT8)
113
114
  movzx eax, al ;movzbl %al, %eax
@@ -1,7 +1,7 @@
1
- # Makefile.in generated by automake 1.15.1 from Makefile.am.
1
+ # Makefile.in generated by automake 1.16.1 from Makefile.am.
2
2
  # @configure_input@
3
3
 
4
- # Copyright (C) 1994-2017 Free Software Foundation, Inc.
4
+ # Copyright (C) 1994-2018 Free Software Foundation, Inc.
5
5
 
6
6
  # This Makefile.in is free software; the Free Software Foundation
7
7
  # gives unlimited permission to copy and/or distribute it,
@@ -421,8 +421,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
421
421
  *config.status*) \
422
422
  cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
423
423
  *) \
424
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
425
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
424
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
425
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
426
426
  esac;
427
427
 
428
428
  $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -451,7 +451,7 @@ check-DEJAGNU: site.exp
451
451
  EXPECT=$(EXPECT); export EXPECT; \
452
452
  if $(SHELL) -c "$(RUNTEST) --version" > /dev/null 2>&1; then \
453
453
  exit_status=0; l='$(DEJATOOL)'; for tool in $$l; do \
454
- if $(RUNTEST) $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \
454
+ if $(RUNTEST) $(RUNTESTDEFAULTFLAGS) $(AM_RUNTESTFLAGS) $(RUNTESTFLAGS); \
455
455
  then :; else exit_status=1; fi; \
456
456
  done; \
457
457
  else echo "WARNING: could not find '$(RUNTEST)'" 1>&2; :;\
@@ -490,7 +490,10 @@ distclean-DEJAGNU:
490
490
  rm -f $$tool.sum $$tool.log; \
491
491
  done
492
492
 
493
- distdir: $(DISTFILES)
493
+ distdir: $(BUILT_SOURCES)
494
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
495
+
496
+ distdir-am: $(DISTFILES)
494
497
  @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
495
498
  topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
496
499
  list='$(DISTFILES)'; \
@@ -24,6 +24,11 @@ load_lib libgloss.exp
24
24
  load_gcc_lib target-libpath.exp
25
25
  load_gcc_lib wrapper.exp
26
26
 
27
+ proc check_effective_target_gccbug { } {
28
+ global has_gccbug
29
+ return $has_gccbug
30
+ }
31
+
27
32
  # Return 1 if the target matches the effective target 'arg', 0 otherwise.
28
33
  # This can be used with any check_* proc that takes no argument and
29
34
  # returns only 1 or 0. It could be used with check_* procs that take
@@ -477,6 +482,7 @@ proc libffi-dg-runtest { testcases default-extra-flags } {
477
482
 
478
483
  proc run-many-tests { testcases extra_flags } {
479
484
  global compiler_vendor
485
+ global has_gccbug
480
486
  global env
481
487
  switch $compiler_vendor {
482
488
  "clang" {
@@ -538,8 +544,22 @@ proc run-many-tests { testcases extra_flags } {
538
544
  foreach opt $optimizations {
539
545
  foreach abi $abis {
540
546
  set options [concat $common $opt $abi]
541
- verbose "Testing $testname, $options" 1
542
- dg-test $test $options ""
547
+ set has_gccbug false;
548
+ if { [string match $compiler_vendor "gnu"] \
549
+ && [string match "*MSABI*" $abi] \
550
+ && ( ( [string match "*DGTEST=57 *" $common] \
551
+ && [string match "*call.c*" $testname] ) \
552
+ || ( [string match "*DGTEST=54 *" $common] \
553
+ && [string match "*callback*" $testname] ) \
554
+ || [string match "*DGTEST=55 *" $common] \
555
+ || [string match "*DGTEST=56 *" $common] ) } then {
556
+ if [libffi_feature_test "#if (__GNUC__ < 9) || ((__GNUC__ == 9) && (__GNUC_MINOR__ < 3))"] {
557
+ set has_gccbug true;
558
+ }
559
+ }
560
+ verbose "Testing $testname, $options" 1
561
+ verbose "has_gccbug = $has_gccbug" 1
562
+ dg-test $test $options ""
543
563
  }
544
564
  }
545
565
  }