ffi 1.12.2 → 1.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +82 -0
- data/Gemfile +4 -2
- data/README.md +10 -2
- data/Rakefile +31 -43
- data/ext/ffi_c/AbstractMemory.c +24 -25
- 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 +3 -6
- data/ext/ffi_c/StructByValue.c +2 -7
- data/ext/ffi_c/StructLayout.c +9 -7
- 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 -23
- 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/autopointer.rb +1 -1
- data/lib/ffi/ffi.rb +1 -0
- data/lib/ffi/io.rb +3 -3
- data/lib/ffi/library.rb +6 -2
- data/lib/ffi/managedstruct.rb +2 -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 +21 -14
- data/lib/ffi/struct.rb +8 -2
- data/lib/ffi/tools/types_generator.rb +2 -0
- data/lib/ffi/variadic.rb +1 -1
- 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
|
@@ -186,7 +186,7 @@ def generate_source_and_headers(generate_osx=True, generate_ios=True):
|
|
|
186
186
|
build_target(desktop64_platform, platform_headers)
|
|
187
187
|
|
|
188
188
|
mkdir_p('darwin_common/include')
|
|
189
|
-
for header_name, tag_tuples in platform_headers.
|
|
189
|
+
for header_name, tag_tuples in platform_headers.items():
|
|
190
190
|
basename, suffix = os.path.splitext(header_name)
|
|
191
191
|
with open(os.path.join('darwin_common/include', header_name), 'w') as header:
|
|
192
192
|
for tag_tuple in tag_tuples:
|
|
@@ -330,6 +330,14 @@ typedef struct {
|
|
|
330
330
|
FFI_API void *ffi_closure_alloc (size_t size, void **code);
|
|
331
331
|
FFI_API void ffi_closure_free (void *);
|
|
332
332
|
|
|
333
|
+
#if defined(PA_LINUX) || defined(PA_HPUX)
|
|
334
|
+
#define FFI_CLOSURE_PTR(X) ((void *)((unsigned int)(X) | 2))
|
|
335
|
+
#define FFI_RESTORE_PTR(X) ((void *)((unsigned int)(X) & ~3))
|
|
336
|
+
#else
|
|
337
|
+
#define FFI_CLOSURE_PTR(X) (X)
|
|
338
|
+
#define FFI_RESTORE_PTR(X) (X)
|
|
339
|
+
#endif
|
|
340
|
+
|
|
333
341
|
FFI_API ffi_status
|
|
334
342
|
ffi_prep_closure (ffi_closure*,
|
|
335
343
|
ffi_cif *,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
/* These version numbers correspond to the libtool-version abi numbers,
|
|
7
7
|
not to the libffi release numbers. */
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
LIBFFI_BASE_8.0 {
|
|
10
10
|
global:
|
|
11
11
|
/* Exported data variables. */
|
|
12
12
|
ffi_type_void;
|
|
@@ -38,27 +38,23 @@ LIBFFI_BASE_7.0 {
|
|
|
38
38
|
ffi_java_raw_to_ptrarray;
|
|
39
39
|
ffi_java_raw_size;
|
|
40
40
|
|
|
41
|
+
ffi_get_struct_offsets;
|
|
41
42
|
local:
|
|
42
43
|
*;
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
LIBFFI_BASE_7.1 {
|
|
46
|
-
global:
|
|
47
|
-
ffi_get_struct_offsets;
|
|
48
|
-
} LIBFFI_BASE_7.0;
|
|
49
|
-
|
|
50
46
|
#ifdef FFI_TARGET_HAS_COMPLEX_TYPE
|
|
51
|
-
|
|
47
|
+
LIBFFI_COMPLEX_8.0 {
|
|
52
48
|
global:
|
|
53
49
|
/* Exported data variables. */
|
|
54
50
|
ffi_type_complex_float;
|
|
55
51
|
ffi_type_complex_double;
|
|
56
52
|
ffi_type_complex_longdouble;
|
|
57
|
-
}
|
|
53
|
+
} LIBFFI_BASE_8.0;
|
|
58
54
|
#endif
|
|
59
55
|
|
|
60
56
|
#if FFI_CLOSURES
|
|
61
|
-
|
|
57
|
+
LIBFFI_CLOSURE_8.0 {
|
|
62
58
|
global:
|
|
63
59
|
ffi_closure_alloc;
|
|
64
60
|
ffi_closure_free;
|
|
@@ -68,13 +64,13 @@ LIBFFI_CLOSURE_7.0 {
|
|
|
68
64
|
ffi_prep_raw_closure_loc;
|
|
69
65
|
ffi_prep_java_raw_closure;
|
|
70
66
|
ffi_prep_java_raw_closure_loc;
|
|
71
|
-
}
|
|
67
|
+
} LIBFFI_BASE_8.0;
|
|
72
68
|
#endif
|
|
73
69
|
|
|
74
70
|
#if FFI_GO_CLOSURES
|
|
75
|
-
|
|
71
|
+
LIBFFI_GO_CLOSURE_8.0 {
|
|
76
72
|
global:
|
|
77
73
|
ffi_call_go;
|
|
78
74
|
ffi_prep_go_closure;
|
|
79
|
-
}
|
|
75
|
+
} LIBFFI_CLOSURE_8.0;
|
|
80
76
|
#endif
|
data/ext/ffi_c/libffi/msvcc.sh
CHANGED
|
@@ -165,24 +165,24 @@ do
|
|
|
165
165
|
shift 1
|
|
166
166
|
;;
|
|
167
167
|
-I)
|
|
168
|
-
p=$(cygpath -
|
|
169
|
-
args="$args -I$p"
|
|
170
|
-
includes="$includes -I$p"
|
|
168
|
+
p=$(cygpath -ma "$2")
|
|
169
|
+
args="$args -I\"$p\""
|
|
170
|
+
includes="$includes -I\"$p\""
|
|
171
171
|
shift 2
|
|
172
172
|
;;
|
|
173
173
|
-I*)
|
|
174
|
-
p=$(cygpath -
|
|
175
|
-
args="$args -I$p"
|
|
176
|
-
includes="$includes -I$p"
|
|
174
|
+
p=$(cygpath -ma "${1#-I}")
|
|
175
|
+
args="$args -I\"$p\""
|
|
176
|
+
includes="$includes -I\"$p\""
|
|
177
177
|
shift 1
|
|
178
178
|
;;
|
|
179
179
|
-L)
|
|
180
|
-
p=$(cygpath -
|
|
180
|
+
p=$(cygpath -ma $2)
|
|
181
181
|
linkargs="$linkargs -LIBPATH:$p"
|
|
182
182
|
shift 2
|
|
183
183
|
;;
|
|
184
184
|
-L*)
|
|
185
|
-
p=$(cygpath -
|
|
185
|
+
p=$(cygpath -ma ${1#-L})
|
|
186
186
|
linkargs="$linkargs -LIBPATH:$p"
|
|
187
187
|
shift 1
|
|
188
188
|
;;
|
|
@@ -256,12 +256,12 @@ do
|
|
|
256
256
|
shift 2
|
|
257
257
|
;;
|
|
258
258
|
*.S)
|
|
259
|
-
src
|
|
259
|
+
src="$(cygpath -ma $1)"
|
|
260
260
|
assembly="true"
|
|
261
261
|
shift 1
|
|
262
262
|
;;
|
|
263
263
|
*.c)
|
|
264
|
-
args="$args $1"
|
|
264
|
+
args="$args $(cygpath -ma $1)"
|
|
265
265
|
shift 1
|
|
266
266
|
;;
|
|
267
267
|
*)
|
|
@@ -312,7 +312,7 @@ if [ -n "$assembly" ]; then
|
|
|
312
312
|
echo "$cl -nologo -EP $includes $defines $src > $ppsrc"
|
|
313
313
|
fi
|
|
314
314
|
|
|
315
|
-
"$cl" -nologo -EP $includes $defines $src > $ppsrc || exit $?
|
|
315
|
+
eval "\"$cl\" -nologo -EP $includes $defines $src" > $ppsrc || exit $?
|
|
316
316
|
output="$(echo $output | sed 's%/F[dpa][^ ]*%%g')"
|
|
317
317
|
if [ $ml = "armasm" ]; then
|
|
318
318
|
args="-nologo -g -oldit $armasm_output $ppsrc -errorReport:prompt"
|
|
@@ -27,7 +27,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
27
27
|
#include <ffi.h>
|
|
28
28
|
#include <ffi_common.h>
|
|
29
29
|
#include "internal.h"
|
|
30
|
-
#ifdef
|
|
30
|
+
#ifdef _WIN32
|
|
31
31
|
#include <windows.h> /* FlushInstructionCache */
|
|
32
32
|
#endif
|
|
33
33
|
|
|
@@ -62,6 +62,9 @@ struct call_context
|
|
|
62
62
|
#if FFI_EXEC_TRAMPOLINE_TABLE
|
|
63
63
|
|
|
64
64
|
#ifdef __MACH__
|
|
65
|
+
#ifdef HAVE_PTRAUTH
|
|
66
|
+
#include <ptrauth.h>
|
|
67
|
+
#endif
|
|
65
68
|
#include <mach/vm_param.h>
|
|
66
69
|
#endif
|
|
67
70
|
|
|
@@ -78,7 +81,7 @@ ffi_clear_cache (void *start, void *end)
|
|
|
78
81
|
sys_icache_invalidate (start, (char *)end - (char *)start);
|
|
79
82
|
#elif defined (__GNUC__)
|
|
80
83
|
__builtin___clear_cache (start, end);
|
|
81
|
-
#elif defined (
|
|
84
|
+
#elif defined (_WIN32)
|
|
82
85
|
FlushInstructionCache(GetCurrentProcess(), start, (char*)end - (char*)start);
|
|
83
86
|
#else
|
|
84
87
|
#error "Missing builtin to flush instruction cache"
|
|
@@ -561,6 +564,14 @@ ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs,
|
|
|
561
564
|
cif->aarch64_nfixedargs = nfixedargs;
|
|
562
565
|
return status;
|
|
563
566
|
}
|
|
567
|
+
#else
|
|
568
|
+
ffi_status FFI_HIDDEN
|
|
569
|
+
ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs, unsigned int ntotalargs)
|
|
570
|
+
{
|
|
571
|
+
ffi_status status = ffi_prep_cif_machdep (cif);
|
|
572
|
+
cif->flags |= AARCH64_FLAG_VARARG;
|
|
573
|
+
return status;
|
|
574
|
+
}
|
|
564
575
|
#endif /* __APPLE__ */
|
|
565
576
|
|
|
566
577
|
extern void ffi_call_SYSV (struct call_context *context, void *frame,
|
|
@@ -577,7 +588,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
|
|
|
577
588
|
void *stack, *frame, *rvalue;
|
|
578
589
|
struct arg_state state;
|
|
579
590
|
size_t stack_bytes, rtype_size, rsize;
|
|
580
|
-
int i, nargs, flags;
|
|
591
|
+
int i, nargs, flags, isvariadic = 0;
|
|
581
592
|
ffi_type *rtype;
|
|
582
593
|
|
|
583
594
|
flags = cif->flags;
|
|
@@ -585,6 +596,12 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
|
|
|
585
596
|
rtype_size = rtype->size;
|
|
586
597
|
stack_bytes = cif->bytes;
|
|
587
598
|
|
|
599
|
+
if (flags & AARCH64_FLAG_VARARG)
|
|
600
|
+
{
|
|
601
|
+
isvariadic = 1;
|
|
602
|
+
flags &= ~AARCH64_FLAG_VARARG;
|
|
603
|
+
}
|
|
604
|
+
|
|
588
605
|
/* If the target function returns a structure via hidden pointer,
|
|
589
606
|
then we cannot allow a null rvalue. Otherwise, mash a null
|
|
590
607
|
rvalue to void return type. */
|
|
@@ -664,35 +681,31 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
|
|
|
664
681
|
h = is_vfp_type (ty);
|
|
665
682
|
if (h)
|
|
666
683
|
{
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
dest = allocate_to_stack (&state, stack, ty->alignment, s);
|
|
693
|
-
#ifdef _M_ARM64 /* for handling armasm calling convention */
|
|
694
|
-
}
|
|
695
|
-
#endif /* for handling armasm calling convention */
|
|
684
|
+
int elems = 4 - (h & 3);
|
|
685
|
+
if (cif->abi == FFI_WIN64 && isvariadic)
|
|
686
|
+
{
|
|
687
|
+
if (state.ngrn + elems <= N_X_ARG_REG)
|
|
688
|
+
{
|
|
689
|
+
dest = &context->x[state.ngrn];
|
|
690
|
+
state.ngrn += elems;
|
|
691
|
+
extend_hfa_type(dest, a, h);
|
|
692
|
+
break;
|
|
693
|
+
}
|
|
694
|
+
state.nsrn = N_X_ARG_REG;
|
|
695
|
+
dest = allocate_to_stack(&state, stack, ty->alignment, s);
|
|
696
|
+
}
|
|
697
|
+
else
|
|
698
|
+
{
|
|
699
|
+
if (state.nsrn + elems <= N_V_ARG_REG)
|
|
700
|
+
{
|
|
701
|
+
dest = &context->v[state.nsrn];
|
|
702
|
+
state.nsrn += elems;
|
|
703
|
+
extend_hfa_type (dest, a, h);
|
|
704
|
+
break;
|
|
705
|
+
}
|
|
706
|
+
state.nsrn = N_V_ARG_REG;
|
|
707
|
+
dest = allocate_to_stack (&state, stack, ty->alignment, s);
|
|
708
|
+
}
|
|
696
709
|
}
|
|
697
710
|
else if (s > 16)
|
|
698
711
|
{
|
|
@@ -789,6 +802,9 @@ ffi_prep_closure_loc (ffi_closure *closure,
|
|
|
789
802
|
|
|
790
803
|
#if FFI_EXEC_TRAMPOLINE_TABLE
|
|
791
804
|
#ifdef __MACH__
|
|
805
|
+
#ifdef HAVE_PTRAUTH
|
|
806
|
+
codeloc = ptrauth_strip (codeloc, ptrauth_key_asia);
|
|
807
|
+
#endif
|
|
792
808
|
void **config = (void **)((uint8_t *)codeloc - PAGE_MAX_SIZE);
|
|
793
809
|
config[0] = closure;
|
|
794
810
|
config[1] = start;
|
|
@@ -808,7 +824,7 @@ ffi_prep_closure_loc (ffi_closure *closure,
|
|
|
808
824
|
ffi_clear_cache(tramp, tramp + FFI_TRAMPOLINE_SIZE);
|
|
809
825
|
|
|
810
826
|
/* Also flush the cache for code mapping. */
|
|
811
|
-
#ifdef
|
|
827
|
+
#ifdef _WIN32
|
|
812
828
|
// Not using dlmalloc.c for Windows ARM64 builds
|
|
813
829
|
// so calling ffi_data_to_code_pointer() isn't necessary
|
|
814
830
|
unsigned char *tramp_code = tramp;
|
|
@@ -914,7 +930,7 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
|
|
|
914
930
|
if (h)
|
|
915
931
|
{
|
|
916
932
|
n = 4 - (h & 3);
|
|
917
|
-
#ifdef
|
|
933
|
+
#ifdef _WIN32 /* for handling armasm calling convention */
|
|
918
934
|
if (cif->is_variadic)
|
|
919
935
|
{
|
|
920
936
|
if (state.ngrn + n <= N_X_ARG_REG)
|
|
@@ -954,7 +970,7 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
|
|
|
954
970
|
avalue[i] = allocate_to_stack(&state, stack,
|
|
955
971
|
ty->alignment, s);
|
|
956
972
|
}
|
|
957
|
-
#ifdef
|
|
973
|
+
#ifdef _WIN32 /* for handling armasm calling convention */
|
|
958
974
|
}
|
|
959
975
|
#endif /* for handling armasm calling convention */
|
|
960
976
|
}
|
|
@@ -32,7 +32,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
32
32
|
#define FFI_SIZEOF_JAVA_RAW 4
|
|
33
33
|
typedef unsigned long long ffi_arg;
|
|
34
34
|
typedef signed long long ffi_sarg;
|
|
35
|
-
#elif defined(
|
|
35
|
+
#elif defined(_WIN32)
|
|
36
36
|
#define FFI_SIZEOF_ARG 8
|
|
37
37
|
typedef unsigned long long ffi_arg;
|
|
38
38
|
typedef signed long long ffi_sarg;
|
|
@@ -45,8 +45,13 @@ typedef enum ffi_abi
|
|
|
45
45
|
{
|
|
46
46
|
FFI_FIRST_ABI = 0,
|
|
47
47
|
FFI_SYSV,
|
|
48
|
+
FFI_WIN64,
|
|
48
49
|
FFI_LAST_ABI,
|
|
50
|
+
#if defined(_WIN32)
|
|
51
|
+
FFI_DEFAULT_ABI = FFI_WIN64
|
|
52
|
+
#else
|
|
49
53
|
FFI_DEFAULT_ABI = FFI_SYSV
|
|
54
|
+
#endif
|
|
50
55
|
} ffi_abi;
|
|
51
56
|
#endif
|
|
52
57
|
|
|
@@ -69,22 +74,22 @@ typedef enum ffi_abi
|
|
|
69
74
|
#define FFI_TRAMPOLINE_CLOSURE_OFFSET FFI_TRAMPOLINE_SIZE
|
|
70
75
|
#endif
|
|
71
76
|
|
|
72
|
-
#ifdef
|
|
77
|
+
#ifdef _WIN32
|
|
73
78
|
#define FFI_EXTRA_CIF_FIELDS unsigned is_variadic
|
|
74
79
|
#endif
|
|
80
|
+
#define FFI_TARGET_SPECIFIC_VARIADIC
|
|
75
81
|
|
|
76
82
|
/* ---- Internal ---- */
|
|
77
83
|
|
|
78
84
|
#if defined (__APPLE__)
|
|
79
|
-
#define FFI_TARGET_SPECIFIC_VARIADIC
|
|
80
85
|
#define FFI_EXTRA_CIF_FIELDS unsigned aarch64_nfixedargs
|
|
81
|
-
#elif !defined(
|
|
86
|
+
#elif !defined(_WIN32)
|
|
82
87
|
/* iOS and Windows reserve x18 for the system. Disable Go closures until
|
|
83
88
|
a new static chain is chosen. */
|
|
84
89
|
#define FFI_GO_CLOSURES 1
|
|
85
90
|
#endif
|
|
86
91
|
|
|
87
|
-
#ifndef
|
|
92
|
+
#ifndef _WIN32
|
|
88
93
|
/* No complex type on Windows */
|
|
89
94
|
#define FFI_TARGET_HAS_COMPLEX_TYPE
|
|
90
95
|
#endif
|
|
@@ -56,6 +56,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
56
56
|
#define PTR_SIZE 4
|
|
57
57
|
#else
|
|
58
58
|
#define PTR_SIZE 8
|
|
59
|
+
#endif
|
|
60
|
+
|
|
61
|
+
#if FFI_EXEC_TRAMPOLINE_TABLE && defined(__MACH__) && defined(HAVE_PTRAUTH)
|
|
62
|
+
# define BR(r) braaz r
|
|
63
|
+
# define BLR(r) blraaz r
|
|
64
|
+
#else
|
|
65
|
+
# define BR(r) br r
|
|
66
|
+
# define BLR(r) blr r
|
|
59
67
|
#endif
|
|
60
68
|
|
|
61
69
|
.text
|
|
@@ -111,7 +119,7 @@ CNAME(ffi_call_SYSV):
|
|
|
111
119
|
/* Deallocate the context, leaving the stacked arguments. */
|
|
112
120
|
add sp, sp, #CALL_CONTEXT_SIZE
|
|
113
121
|
|
|
114
|
-
|
|
122
|
+
BLR(x9) /* call fn */
|
|
115
123
|
|
|
116
124
|
ldp x3, x4, [x29, #16] /* reload rvalue and flags */
|
|
117
125
|
|
|
@@ -271,6 +279,9 @@ CNAME(ffi_closure_SYSV):
|
|
|
271
279
|
bl CNAME(ffi_closure_SYSV_inner)
|
|
272
280
|
|
|
273
281
|
/* Load the return value as directed. */
|
|
282
|
+
#if FFI_EXEC_TRAMPOLINE_TABLE && defined(__MACH__) && defined(HAVE_PTRAUTH)
|
|
283
|
+
autiza x1
|
|
284
|
+
#endif
|
|
274
285
|
adr x1, 0f
|
|
275
286
|
and w0, w0, #AARCH64_RET_MASK
|
|
276
287
|
add x1, x1, x0, lsl #3
|
|
@@ -365,8 +376,8 @@ CNAME(ffi_closure_trampoline_table_page):
|
|
|
365
376
|
.rept PAGE_MAX_SIZE / FFI_TRAMPOLINE_SIZE
|
|
366
377
|
adr x16, -PAGE_MAX_SIZE
|
|
367
378
|
ldp x17, x16, [x16]
|
|
368
|
-
|
|
369
|
-
nop /* each entry in the trampoline config page is 2*sizeof(void*) so the trampoline itself cannot be smaller
|
|
379
|
+
BR(x16)
|
|
380
|
+
nop /* each entry in the trampoline config page is 2*sizeof(void*) so the trampoline itself cannot be smaller than 16 bytes */
|
|
370
381
|
.endr
|
|
371
382
|
|
|
372
383
|
.globl CNAME(ffi_closure_trampoline_table_page)
|
|
@@ -55,6 +55,11 @@ extern unsigned int ffi_arm_trampoline[3] FFI_HIDDEN;
|
|
|
55
55
|
#endif
|
|
56
56
|
#endif
|
|
57
57
|
|
|
58
|
+
#if defined(__FreeBSD__) && defined(__arm__)
|
|
59
|
+
#include <sys/types.h>
|
|
60
|
+
#include <machine/sysarch.h>
|
|
61
|
+
#endif
|
|
62
|
+
|
|
58
63
|
/* Forward declares. */
|
|
59
64
|
static int vfp_type_p (const ffi_type *);
|
|
60
65
|
static void layout_vfp_args (ffi_cif *);
|
|
@@ -421,12 +426,14 @@ ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue)
|
|
|
421
426
|
ffi_call_int (cif, fn, rvalue, avalue, NULL);
|
|
422
427
|
}
|
|
423
428
|
|
|
429
|
+
#ifdef FFI_GO_CLOSURES
|
|
424
430
|
void
|
|
425
431
|
ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue,
|
|
426
432
|
void **avalue, void *closure)
|
|
427
433
|
{
|
|
428
434
|
ffi_call_int (cif, fn, rvalue, avalue, closure);
|
|
429
435
|
}
|
|
436
|
+
#endif
|
|
430
437
|
|
|
431
438
|
static void *
|
|
432
439
|
ffi_prep_incoming_args_SYSV (ffi_cif *cif, void *rvalue,
|
|
@@ -564,11 +571,24 @@ ffi_closure_inner_VFP (ffi_cif *cif,
|
|
|
564
571
|
|
|
565
572
|
void ffi_closure_SYSV (void) FFI_HIDDEN;
|
|
566
573
|
void ffi_closure_VFP (void) FFI_HIDDEN;
|
|
574
|
+
|
|
575
|
+
#ifdef FFI_GO_CLOSURES
|
|
567
576
|
void ffi_go_closure_SYSV (void) FFI_HIDDEN;
|
|
568
577
|
void ffi_go_closure_VFP (void) FFI_HIDDEN;
|
|
578
|
+
#endif
|
|
569
579
|
|
|
570
580
|
/* the cif must already be prep'ed */
|
|
571
581
|
|
|
582
|
+
#if defined(__FreeBSD__) && defined(__arm__)
|
|
583
|
+
#define __clear_cache(start, end) do { \
|
|
584
|
+
struct arm_sync_icache_args ua; \
|
|
585
|
+
\
|
|
586
|
+
ua.addr = (uintptr_t)(start); \
|
|
587
|
+
ua.len = (char *)(end) - (char *)start; \
|
|
588
|
+
sysarch(ARM_SYNC_ICACHE, &ua); \
|
|
589
|
+
} while (0);
|
|
590
|
+
#endif
|
|
591
|
+
|
|
572
592
|
ffi_status
|
|
573
593
|
ffi_prep_closure_loc (ffi_closure * closure,
|
|
574
594
|
ffi_cif * cif,
|
|
@@ -622,6 +642,7 @@ ffi_prep_closure_loc (ffi_closure * closure,
|
|
|
622
642
|
return FFI_OK;
|
|
623
643
|
}
|
|
624
644
|
|
|
645
|
+
#ifdef FFI_GO_CLOSURES
|
|
625
646
|
ffi_status
|
|
626
647
|
ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif,
|
|
627
648
|
void (*fun) (ffi_cif *, void *, void **, void *))
|
|
@@ -643,6 +664,7 @@ ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif,
|
|
|
643
664
|
|
|
644
665
|
return FFI_OK;
|
|
645
666
|
}
|
|
667
|
+
#endif
|
|
646
668
|
|
|
647
669
|
/* Below are routines for VFP hard-float support. */
|
|
648
670
|
|