ffi 1.13.1 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -0
- data/README.md +10 -2
- data/ext/ffi_c/AbstractMemory.c +25 -26
- data/ext/ffi_c/Buffer.c +2 -7
- data/ext/ffi_c/Call.c +2 -7
- data/ext/ffi_c/ClosurePool.c +64 -11
- data/ext/ffi_c/ClosurePool.h +3 -1
- data/ext/ffi_c/DynamicLibrary.c +1 -6
- data/ext/ffi_c/Function.c +8 -13
- data/ext/ffi_c/FunctionInfo.c +2 -6
- data/ext/ffi_c/LastError.c +2 -6
- data/ext/ffi_c/MemoryPointer.c +2 -7
- data/ext/ffi_c/MethodHandle.c +4 -8
- data/ext/ffi_c/Platform.c +2 -7
- data/ext/ffi_c/Pointer.c +24 -25
- data/ext/ffi_c/Struct.c +3 -6
- data/ext/ffi_c/StructByValue.c +2 -7
- data/ext/ffi_c/StructLayout.c +2 -5
- data/ext/ffi_c/Thread.c +0 -5
- data/ext/ffi_c/Thread.h +1 -6
- data/ext/ffi_c/Type.c +1 -1
- data/ext/ffi_c/Variadic.c +2 -7
- data/ext/ffi_c/extconf.rb +17 -4
- data/ext/ffi_c/libffi/.travis/bfin-sim.exp +1 -1
- 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 +48 -58
- data/ext/ffi_c/libffi/README.md +4 -0
- 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 +6 -1
- 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/msvcc.sh +11 -11
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +45 -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 +1 -1
- 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 +23 -6
- 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/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/prep_cif.c +1 -1
- data/ext/ffi_c/libffi/src/x86/ffi.c +8 -2
- data/ext/ffi_c/libffi/src/x86/ffi64.c +7 -0
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +5 -0
- data/ext/ffi_c/libffi/src/x86/sysv.S +2 -2
- data/ext/ffi_c/libffi/src/x86/unix64.S +1 -2
- data/ext/ffi_c/libffi/src/x86/win64.S +3 -2
- 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 +1 -1
- data/lib/ffi.rb +2 -2
- data/lib/ffi/abstract_memory.rb +44 -0
- data/lib/ffi/ffi.rb +1 -0
- data/lib/ffi/library.rb +1 -1
- data/lib/ffi/platform.rb +15 -6
- data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
- data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
- data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
- data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
- data/lib/ffi/pointer.rb +21 -7
- data/lib/ffi/version.rb +1 -1
- metadata +15 -11
- data/.appveyor.yml +0 -30
- data/.github/workflows/ci.yml +0 -64
- data/.gitignore +0 -25
- data/.gitmodules +0 -4
- data/.travis.yml +0 -58
- data/.yardopts +0 -5
- data/ext/ffi_c/win32/stdbool.h +0 -8
- data/ext/ffi_c/win32/stdint.h +0 -201
@@ -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:
|
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
|
|
@@ -81,7 +81,7 @@ ffi_clear_cache (void *start, void *end)
|
|
81
81
|
sys_icache_invalidate (start, (char *)end - (char *)start);
|
82
82
|
#elif defined (__GNUC__)
|
83
83
|
__builtin___clear_cache (start, end);
|
84
|
-
#elif defined (
|
84
|
+
#elif defined (_WIN32)
|
85
85
|
FlushInstructionCache(GetCurrentProcess(), start, (char*)end - (char*)start);
|
86
86
|
#else
|
87
87
|
#error "Missing builtin to flush instruction cache"
|
@@ -564,6 +564,14 @@ ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs,
|
|
564
564
|
cif->aarch64_nfixedargs = nfixedargs;
|
565
565
|
return status;
|
566
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
|
+
}
|
567
575
|
#endif /* __APPLE__ */
|
568
576
|
|
569
577
|
extern void ffi_call_SYSV (struct call_context *context, void *frame,
|
@@ -580,7 +588,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
|
|
580
588
|
void *stack, *frame, *rvalue;
|
581
589
|
struct arg_state state;
|
582
590
|
size_t stack_bytes, rtype_size, rsize;
|
583
|
-
int i, nargs, flags;
|
591
|
+
int i, nargs, flags, isvariadic = 0;
|
584
592
|
ffi_type *rtype;
|
585
593
|
|
586
594
|
flags = cif->flags;
|
@@ -588,6 +596,12 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
|
|
588
596
|
rtype_size = rtype->size;
|
589
597
|
stack_bytes = cif->bytes;
|
590
598
|
|
599
|
+
if (flags & AARCH64_FLAG_VARARG)
|
600
|
+
{
|
601
|
+
isvariadic = 1;
|
602
|
+
flags &= ~AARCH64_FLAG_VARARG;
|
603
|
+
}
|
604
|
+
|
591
605
|
/* If the target function returns a structure via hidden pointer,
|
592
606
|
then we cannot allow a null rvalue. Otherwise, mash a null
|
593
607
|
rvalue to void return type. */
|
@@ -667,35 +681,31 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
|
|
667
681
|
h = is_vfp_type (ty);
|
668
682
|
if (h)
|
669
683
|
{
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
dest = allocate_to_stack (&state, stack, ty->alignment, s);
|
696
|
-
#ifdef _M_ARM64 /* for handling armasm calling convention */
|
697
|
-
}
|
698
|
-
#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
|
+
}
|
699
709
|
}
|
700
710
|
else if (s > 16)
|
701
711
|
{
|
@@ -814,7 +824,7 @@ ffi_prep_closure_loc (ffi_closure *closure,
|
|
814
824
|
ffi_clear_cache(tramp, tramp + FFI_TRAMPOLINE_SIZE);
|
815
825
|
|
816
826
|
/* Also flush the cache for code mapping. */
|
817
|
-
#ifdef
|
827
|
+
#ifdef _WIN32
|
818
828
|
// Not using dlmalloc.c for Windows ARM64 builds
|
819
829
|
// so calling ffi_data_to_code_pointer() isn't necessary
|
820
830
|
unsigned char *tramp_code = tramp;
|
@@ -920,7 +930,7 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
|
|
920
930
|
if (h)
|
921
931
|
{
|
922
932
|
n = 4 - (h & 3);
|
923
|
-
#ifdef
|
933
|
+
#ifdef _WIN32 /* for handling armasm calling convention */
|
924
934
|
if (cif->is_variadic)
|
925
935
|
{
|
926
936
|
if (state.ngrn + n <= N_X_ARG_REG)
|
@@ -960,7 +970,7 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
|
|
960
970
|
avalue[i] = allocate_to_stack(&state, stack,
|
961
971
|
ty->alignment, s);
|
962
972
|
}
|
963
|
-
#ifdef
|
973
|
+
#ifdef _WIN32 /* for handling armasm calling convention */
|
964
974
|
}
|
965
975
|
#endif /* for handling armasm calling convention */
|
966
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
|
@@ -377,7 +377,7 @@ CNAME(ffi_closure_trampoline_table_page):
|
|
377
377
|
adr x16, -PAGE_MAX_SIZE
|
378
378
|
ldp x17, x16, [x16]
|
379
379
|
BR(x16)
|
380
|
-
nop /* each entry in the trampoline config page is 2*sizeof(void*) so the trampoline itself cannot be smaller
|
380
|
+
nop /* each entry in the trampoline config page is 2*sizeof(void*) so the trampoline itself cannot be smaller than 16 bytes */
|
381
381
|
.endr
|
382
382
|
|
383
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
|
|
@@ -129,11 +129,11 @@ ARM_FUNC_START(ffi_call_VFP)
|
|
129
129
|
|
130
130
|
cmp r3, #3 @ load only d0 if possible
|
131
131
|
#ifdef __clang__
|
132
|
-
vldrle d0, [
|
133
|
-
vldmgt
|
132
|
+
vldrle d0, [r0]
|
133
|
+
vldmgt r0, {d0-d7}
|
134
134
|
#else
|
135
|
-
ldcle p11, cr0, [r0] @ vldrle d0, [
|
136
|
-
ldcgt p11, cr0, [r0], {16} @ vldmgt
|
135
|
+
ldcle p11, cr0, [r0] @ vldrle d0, [r0]
|
136
|
+
ldcgt p11, cr0, [r0], {16} @ vldmgt r0, {d0-d7}
|
137
137
|
#endif
|
138
138
|
add r0, r0, #64 @ discard the vfp register args
|
139
139
|
/* FALLTHRU */
|
@@ -45,6 +45,9 @@
|
|
45
45
|
|
46
46
|
#include <stddef.h>
|
47
47
|
#include <unistd.h>
|
48
|
+
#ifdef HAVE_SYS_MEMFD_H
|
49
|
+
#include <sys/memfd.h>
|
50
|
+
#endif
|
48
51
|
|
49
52
|
static const size_t overhead =
|
50
53
|
(sizeof(max_align_t) > sizeof(void *) + sizeof(size_t)) ?
|
@@ -123,7 +126,7 @@ ffi_closure_free (void *ptr)
|
|
123
126
|
# define FFI_MMAP_EXEC_WRIT 1
|
124
127
|
# define HAVE_MNTENT 1
|
125
128
|
# endif
|
126
|
-
# if defined(
|
129
|
+
# if defined(_WIN32) || defined(__OS2__)
|
127
130
|
/* Windows systems may have Data Execution Protection (DEP) enabled,
|
128
131
|
which requires the use of VirtualMalloc/VirtualFree to alloc/free
|
129
132
|
executable memory. */
|
@@ -392,7 +395,7 @@ ffi_closure_free (void *ptr)
|
|
392
395
|
#endif
|
393
396
|
#include <string.h>
|
394
397
|
#include <stdio.h>
|
395
|
-
#if !defined(
|
398
|
+
#if !defined(_WIN32)
|
396
399
|
#ifdef HAVE_MNTENT
|
397
400
|
#include <mntent.h>
|
398
401
|
#endif /* HAVE_MNTENT */
|
@@ -518,11 +521,11 @@ static int dlmalloc_trim(size_t) MAYBE_UNUSED;
|
|
518
521
|
static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED;
|
519
522
|
static void dlmalloc_stats(void) MAYBE_UNUSED;
|
520
523
|
|
521
|
-
#if !(defined(
|
524
|
+
#if !(defined(_WIN32) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX)
|
522
525
|
/* Use these for mmap and munmap within dlmalloc.c. */
|
523
526
|
static void *dlmmap(void *, size_t, int, int, int, off_t);
|
524
527
|
static int dlmunmap(void *, size_t);
|
525
|
-
#endif /* !(defined(
|
528
|
+
#endif /* !(defined(_WIN32) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
|
526
529
|
|
527
530
|
#define mmap dlmmap
|
528
531
|
#define munmap dlmunmap
|
@@ -532,7 +535,7 @@ static int dlmunmap(void *, size_t);
|
|
532
535
|
#undef mmap
|
533
536
|
#undef munmap
|
534
537
|
|
535
|
-
#if !(defined(
|
538
|
+
#if !(defined(_WIN32) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX)
|
536
539
|
|
537
540
|
/* A mutex used to synchronize access to *exec* variables in this file. */
|
538
541
|
static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER;
|
@@ -544,6 +547,17 @@ static int execfd = -1;
|
|
544
547
|
/* The amount of space already allocated from the temporary file. */
|
545
548
|
static size_t execsize = 0;
|
546
549
|
|
550
|
+
#ifdef HAVE_MEMFD_CREATE
|
551
|
+
/* Open a temporary file name, and immediately unlink it. */
|
552
|
+
static int
|
553
|
+
open_temp_exec_file_memfd (const char *name)
|
554
|
+
{
|
555
|
+
int fd;
|
556
|
+
fd = memfd_create (name, MFD_CLOEXEC);
|
557
|
+
return fd;
|
558
|
+
}
|
559
|
+
#endif
|
560
|
+
|
547
561
|
/* Open a temporary file name, and immediately unlink it. */
|
548
562
|
static int
|
549
563
|
open_temp_exec_file_name (char *name, int flags)
|
@@ -671,6 +685,9 @@ static struct
|
|
671
685
|
const char *arg;
|
672
686
|
int repeat;
|
673
687
|
} open_temp_exec_file_opts[] = {
|
688
|
+
#ifdef HAVE_MEMFD_CREATE
|
689
|
+
{ open_temp_exec_file_memfd, "libffi", 0 },
|
690
|
+
#endif
|
674
691
|
{ open_temp_exec_file_env, "TMPDIR", 0 },
|
675
692
|
{ open_temp_exec_file_dir, "/tmp", 0 },
|
676
693
|
{ open_temp_exec_file_dir, "/var/tmp", 0 },
|
@@ -914,7 +931,7 @@ segment_holding_code (mstate m, char* addr)
|
|
914
931
|
}
|
915
932
|
#endif
|
916
933
|
|
917
|
-
#endif /* !(defined(
|
934
|
+
#endif /* !(defined(_WIN32) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
|
918
935
|
|
919
936
|
/* Allocate a chunk of memory with the given size. Returns a pointer
|
920
937
|
to the writable address, and sets *CODE to the executable
|