ffi 1.0.9-x86-mingw32 → 1.0.12.pre-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ffi might be problematic. Click here for more details.
- data/Rakefile +16 -16
- data/ext/ffi_c/AbstractMemory.c +376 -14
- data/ext/ffi_c/AbstractMemory.h +8 -0
- data/ext/ffi_c/ArrayType.c +28 -0
- data/ext/ffi_c/Buffer.c +109 -25
- data/ext/ffi_c/Call.c +16 -5
- data/ext/ffi_c/ClosurePool.c +21 -8
- data/ext/ffi_c/DataConverter.c +29 -0
- data/ext/ffi_c/DynamicLibrary.c +71 -2
- data/ext/ffi_c/Function.c +122 -11
- data/ext/ffi_c/Function.h +6 -0
- data/ext/ffi_c/FunctionInfo.c +21 -1
- data/ext/ffi_c/LastError.c +24 -0
- data/ext/ffi_c/MappedType.c +22 -0
- data/ext/ffi_c/MemoryPointer.c +19 -1
- data/ext/ffi_c/MemoryPointer.h +6 -0
- data/ext/ffi_c/MethodHandle.c +26 -11
- data/ext/ffi_c/Platform.c +17 -3
- data/ext/ffi_c/Pointer.c +106 -0
- data/ext/ffi_c/Pointer.h +6 -0
- data/ext/ffi_c/Struct.c +10 -4
- data/ext/ffi_c/Struct.h +2 -1
- data/ext/ffi_c/StructByReference.c +8 -0
- data/ext/ffi_c/StructByValue.c +8 -0
- data/ext/ffi_c/StructLayout.c +8 -2
- data/ext/ffi_c/Thread.c +131 -1
- data/ext/ffi_c/Thread.h +6 -0
- data/ext/ffi_c/Type.c +111 -17
- data/ext/ffi_c/Types.c +9 -2
- data/ext/ffi_c/Types.h +4 -0
- data/ext/ffi_c/Variadic.c +13 -4
- data/ext/ffi_c/compat.h +8 -0
- data/ext/ffi_c/endian.h +10 -1
- data/ext/ffi_c/extconf.rb +51 -35
- data/ext/ffi_c/ffi.c +5 -0
- data/ext/ffi_c/libffi.darwin.mk +15 -15
- data/ext/ffi_c/libffi.gnu.mk +3 -3
- data/ext/ffi_c/libffi.mk +4 -4
- data/ext/ffi_c/libffi.vc.mk +26 -0
- data/ext/ffi_c/libffi.vc64.mk +26 -0
- data/ext/ffi_c/libffi/ChangeLog +541 -0
- data/ext/ffi_c/libffi/ChangeLog.libffi +13 -87
- data/ext/ffi_c/libffi/LICENSE +3 -3
- data/ext/ffi_c/libffi/Makefile.am +41 -32
- data/ext/ffi_c/libffi/Makefile.in +95 -66
- data/ext/ffi_c/libffi/Makefile.vc +141 -0
- data/ext/ffi_c/libffi/Makefile.vc64 +141 -0
- data/ext/ffi_c/libffi/README +40 -4
- data/ext/ffi_c/libffi/aclocal.m4 +729 -7854
- data/ext/ffi_c/libffi/build-ios.sh +67 -0
- data/ext/ffi_c/libffi/compile +11 -10
- data/ext/ffi_c/libffi/config.guess +4 -1
- data/ext/ffi_c/libffi/config.sub +6 -3
- data/ext/ffi_c/libffi/configure +6264 -6354
- data/ext/ffi_c/libffi/configure.ac +155 -63
- data/ext/ffi_c/libffi/depcomp +81 -35
- data/ext/ffi_c/libffi/doc/libffi.info +78 -18
- data/ext/ffi_c/libffi/doc/libffi.texi +64 -5
- data/ext/ffi_c/libffi/doc/stamp-vti +4 -4
- data/ext/ffi_c/libffi/doc/version.texi +4 -4
- data/ext/ffi_c/libffi/fficonfig.h.in +18 -0
- data/ext/ffi_c/libffi/fficonfig.hw +57 -0
- data/ext/ffi_c/libffi/include/Makefile.in +21 -3
- data/ext/ffi_c/libffi/include/ffi.h.in +42 -14
- data/ext/ffi_c/libffi/include/ffi.h.vc +427 -0
- data/ext/ffi_c/libffi/include/ffi.h.vc64 +427 -0
- data/ext/ffi_c/libffi/include/ffi_common.h +9 -5
- data/ext/ffi_c/libffi/install-sh +364 -167
- data/ext/ffi_c/libffi/ltmain.sh +2599 -1369
- data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +176 -0
- data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +195 -0
- data/ext/ffi_c/libffi/m4/ax_check_compiler_flags.m4 +76 -0
- data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +63 -0
- data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +70 -0
- data/ext/ffi_c/libffi/m4/ax_enable_builddir.m4 +300 -0
- data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +215 -0
- data/ext/ffi_c/libffi/m4/ax_gcc_x86_cpuid.m4 +79 -0
- data/ext/ffi_c/libffi/m4/libtool.m4 +1239 -768
- data/ext/ffi_c/libffi/m4/ltoptions.m4 +7 -6
- data/ext/ffi_c/libffi/m4/ltversion.m4 +6 -6
- data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +9 -3
- data/ext/ffi_c/libffi/man/Makefile.in +21 -3
- data/ext/ffi_c/libffi/mdate-sh +0 -0
- data/ext/ffi_c/libffi/missing +60 -44
- data/ext/ffi_c/libffi/msvcc.sh +197 -0
- data/ext/ffi_c/libffi/src/alpha/osf.S +39 -18
- data/ext/ffi_c/libffi/src/arm/ffi.c +443 -24
- data/ext/ffi_c/libffi/src/arm/ffitarget.h +17 -1
- data/ext/ffi_c/libffi/src/arm/gentramp.sh +118 -0
- data/ext/ffi_c/libffi/src/arm/sysv.S +206 -15
- data/ext/ffi_c/libffi/src/arm/trampoline.S +4450 -0
- data/ext/ffi_c/libffi/src/avr32/ffi.c +4 -2
- data/ext/ffi_c/libffi/src/avr32/ffitarget.h +2 -2
- data/ext/ffi_c/libffi/src/closures.c +17 -35
- data/ext/ffi_c/libffi/src/cris/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/cris/ffitarget.h +2 -2
- data/ext/ffi_c/libffi/src/dlmalloc.c +66 -4
- data/ext/ffi_c/libffi/src/frv/ffitarget.h +2 -6
- data/ext/ffi_c/libffi/src/ia64/ffi.c +7 -5
- data/ext/ffi_c/libffi/src/ia64/ffitarget.h +2 -2
- data/ext/ffi_c/libffi/src/java_raw_api.c +1 -1
- data/ext/ffi_c/libffi/src/m32r/ffitarget.h +2 -2
- data/ext/ffi_c/libffi/src/m68k/ffi.c +10 -0
- data/ext/ffi_c/libffi/src/m68k/ffitarget.h +2 -2
- data/ext/ffi_c/libffi/src/m68k/sysv.S +36 -0
- data/ext/ffi_c/libffi/src/mips/ffi.c +12 -5
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +18 -11
- data/ext/ffi_c/libffi/src/mips/n32.S +4 -4
- data/ext/ffi_c/libffi/src/moxie/eabi.S +128 -0
- data/ext/ffi_c/libffi/src/moxie/ffi.c +276 -0
- data/ext/ffi_c/libffi/src/pa/ffi.c +7 -4
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +6 -5
- data/ext/ffi_c/libffi/src/powerpc/aix.S +5 -1
- data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +2 -0
- data/ext/ffi_c/libffi/src/powerpc/asm.h +1 -1
- data/ext/ffi_c/libffi/src/powerpc/darwin.S +215 -77
- data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +358 -100
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +11 -5
- data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +603 -172
- data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +17 -4
- data/ext/ffi_c/libffi/src/prep_cif.c +16 -13
- data/ext/ffi_c/libffi/src/s390/ffitarget.h +4 -2
- data/ext/ffi_c/libffi/src/sh/ffitarget.h +2 -2
- data/ext/ffi_c/libffi/src/sh64/ffitarget.h +2 -2
- data/ext/ffi_c/libffi/src/sparc/ffi.c +55 -11
- data/ext/ffi_c/libffi/src/sparc/ffitarget.h +5 -3
- data/ext/ffi_c/libffi/src/x86/ffi.c +54 -92
- data/ext/ffi_c/libffi/src/x86/ffi64.c +17 -8
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -14
- data/ext/ffi_c/libffi/src/x86/sysv.S +40 -26
- data/ext/ffi_c/libffi/src/x86/unix64.S +4 -0
- data/ext/ffi_c/libffi/src/x86/win32.S +379 -191
- data/ext/ffi_c/libffi/src/x86/win64.S +15 -7
- data/ext/ffi_c/libffi/testsuite/Makefile.am +1 -1
- data/ext/ffi_c/libffi/testsuite/Makefile.in +22 -4
- data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +350 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +1 -5
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double_va.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble_va.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer_stack.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_abi.c +2 -3
- data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +2 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +36 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/huge_struct.c +17 -17
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium2.c +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.special/special.exp +1 -3
- data/ext/ffi_c/win32/stdint.h +199 -0
- data/gen/Rakefile +18 -2
- data/lib/1.8/ffi_c.so +0 -0
- data/lib/ffi.rb +13 -9
- data/lib/ffi/autopointer.rb +88 -26
- data/lib/ffi/enum.rb +42 -0
- data/lib/ffi/errno.rb +6 -1
- data/lib/ffi/ffi.rb +1 -0
- data/lib/ffi/io.rb +13 -2
- data/lib/ffi/library.rb +219 -24
- data/lib/ffi/memorypointer.rb +1 -33
- data/lib/ffi/platform.rb +21 -7
- data/lib/ffi/platform/arm-linux/types.conf +102 -0
- data/lib/ffi/platform/i386-freebsd/types.conf +152 -0
- data/lib/ffi/platform/i386-netbsd/types.conf +126 -0
- data/lib/ffi/platform/i486-gnu/types.conf +107 -0
- data/lib/ffi/platform/ia64-linux/types.conf +102 -0
- data/lib/ffi/platform/mips-linux/types.conf +102 -0
- data/lib/ffi/platform/mipsel-linux/types.conf +102 -0
- data/lib/ffi/platform/powerpc-linux/types.conf +100 -0
- data/lib/ffi/platform/s390-linux/types.conf +102 -0
- data/lib/ffi/platform/s390x-linux/types.conf +102 -0
- data/lib/ffi/platform/sparc-linux/types.conf +102 -0
- data/lib/ffi/platform/x86_64-freebsd/types.conf +126 -0
- data/lib/ffi/platform/x86_64-netbsd/types.conf +126 -0
- data/lib/ffi/pointer.rb +44 -0
- data/lib/ffi/struct.rb +2 -6
- data/lib/ffi/struct_layout_builder.rb +2 -1
- data/lib/ffi/tools/const_generator.rb +78 -26
- data/lib/ffi/tools/types_generator.rb +8 -1
- data/lib/ffi/types.rb +21 -1
- data/spec/ffi/async_callback_spec.rb +2 -2
- data/spec/ffi/bool_spec.rb +6 -6
- data/spec/ffi/buffer_spec.rb +23 -23
- data/spec/ffi/callback_spec.rb +101 -102
- data/spec/ffi/custom_type_spec.rb +20 -24
- data/spec/ffi/dup_spec.rb +7 -7
- data/spec/ffi/enum_spec.rb +127 -127
- data/spec/ffi/errno_spec.rb +2 -2
- data/spec/ffi/ffi_spec.rb +3 -3
- data/spec/ffi/function_spec.rb +10 -10
- data/spec/ffi/library_spec.rb +30 -12
- data/spec/ffi/managed_struct_spec.rb +4 -4
- data/spec/ffi/number_spec.rb +40 -40
- data/spec/ffi/pointer_spec.rb +21 -24
- data/spec/ffi/rbx/memory_pointer_spec.rb +17 -15
- data/spec/ffi/rbx/struct_spec.rb +2 -2
- data/spec/ffi/spec_helper.rb +1 -1
- data/spec/ffi/string_spec.rb +9 -9
- data/spec/ffi/strptr_spec.rb +3 -3
- data/spec/ffi/struct_callback_spec.rb +7 -7
- data/spec/ffi/struct_initialize_spec.rb +2 -2
- data/spec/ffi/struct_packed_spec.rb +6 -6
- data/spec/ffi/struct_spec.rb +94 -84
- data/spec/ffi/typedef_spec.rb +15 -4
- data/spec/ffi/union_spec.rb +3 -3
- data/spec/ffi/variadic_spec.rb +17 -14
- data/tasks/extension.rake +0 -1
- data/tasks/gem.rake +0 -1
- data/tasks/rdoc.rake +1 -1
- data/tasks/yard.rake +11 -0
- metadata +50 -11
- data/lib/1.9/ffi_c.so +0 -0
@@ -1,5 +1,7 @@
|
|
1
1
|
/* -----------------------------------------------------------------*-C-*-
|
2
2
|
ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc.
|
3
|
+
Copyright (c) 2010 CodeSourcery
|
4
|
+
|
3
5
|
Target configuration macros for ARM.
|
4
6
|
|
5
7
|
Permission is hereby granted, free of charge, to any person obtaining
|
@@ -34,11 +36,25 @@ typedef signed long ffi_sarg;
|
|
34
36
|
typedef enum ffi_abi {
|
35
37
|
FFI_FIRST_ABI = 0,
|
36
38
|
FFI_SYSV,
|
39
|
+
FFI_VFP,
|
40
|
+
FFI_LAST_ABI,
|
41
|
+
#ifdef __ARM_PCS_VFP
|
42
|
+
FFI_DEFAULT_ABI = FFI_VFP,
|
43
|
+
#else
|
37
44
|
FFI_DEFAULT_ABI = FFI_SYSV,
|
38
|
-
|
45
|
+
#endif
|
39
46
|
} ffi_abi;
|
40
47
|
#endif
|
41
48
|
|
49
|
+
#define FFI_EXTRA_CIF_FIELDS \
|
50
|
+
int vfp_used; \
|
51
|
+
short vfp_reg_free, vfp_nargs; \
|
52
|
+
signed char vfp_args[16] \
|
53
|
+
|
54
|
+
/* Internally used. */
|
55
|
+
#define FFI_TYPE_STRUCT_VFP_FLOAT (FFI_TYPE_LAST + 1)
|
56
|
+
#define FFI_TYPE_STRUCT_VFP_DOUBLE (FFI_TYPE_LAST + 2)
|
57
|
+
|
42
58
|
/* ---- Definitions for closures ----------------------------------------- */
|
43
59
|
|
44
60
|
#define FFI_CLOSURES 1
|
@@ -0,0 +1,118 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# -----------------------------------------------------------------------
|
4
|
+
# gentramp.sh - Copyright (c) 2010, Plausible Labs Cooperative, Inc.
|
5
|
+
#
|
6
|
+
# ARM Trampoline Page Generator
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# ``Software''), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
13
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
14
|
+
# the following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
20
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
22
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
23
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
24
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
25
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
26
|
+
# DEALINGS IN THE SOFTWARE.
|
27
|
+
# -----------------------------------------------------------------------
|
28
|
+
|
29
|
+
PROGNAME=$0
|
30
|
+
|
31
|
+
# Each trampoline is exactly 3 instructions, or 12 bytes. If any of these values change,
|
32
|
+
# the entire arm trampoline implementation must be updated to match, too.
|
33
|
+
|
34
|
+
# Size of an individual trampoline, in bytes
|
35
|
+
TRAMPOLINE_SIZE=12
|
36
|
+
|
37
|
+
# Page size, in bytes
|
38
|
+
PAGE_SIZE=4096
|
39
|
+
|
40
|
+
# Compute the size of the reachable config page; The first 16 bytes of the config page
|
41
|
+
# are unreachable due to our maximum pc-relative ldr offset.
|
42
|
+
PAGE_AVAIL=`expr $PAGE_SIZE - 16`
|
43
|
+
|
44
|
+
# Compute the number of of available trampolines.
|
45
|
+
TRAMPOLINE_COUNT=`expr $PAGE_AVAIL / $TRAMPOLINE_SIZE`
|
46
|
+
|
47
|
+
header () {
|
48
|
+
echo "# GENERATED CODE - DO NOT EDIT"
|
49
|
+
echo "# This file was generated by $PROGNAME"
|
50
|
+
echo ""
|
51
|
+
|
52
|
+
# Write out the license header
|
53
|
+
cat << EOF
|
54
|
+
# Copyright (c) 2010, Plausible Labs Cooperative, Inc.
|
55
|
+
#
|
56
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
57
|
+
# a copy of this software and associated documentation files (the
|
58
|
+
# ``Software''), to deal in the Software without restriction, including
|
59
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
60
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
61
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
62
|
+
# the following conditions:
|
63
|
+
#
|
64
|
+
# The above copyright notice and this permission notice shall be included
|
65
|
+
# in all copies or substantial portions of the Software.
|
66
|
+
#
|
67
|
+
# THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
68
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
69
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
70
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
71
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
72
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
73
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
74
|
+
# DEALINGS IN THE SOFTWARE.
|
75
|
+
# -----------------------------------------------------------------------
|
76
|
+
|
77
|
+
EOF
|
78
|
+
|
79
|
+
# Write out the trampoline table, aligned to the page boundary
|
80
|
+
echo ".text"
|
81
|
+
echo ".align 12"
|
82
|
+
echo ".globl _ffi_closure_trampoline_table_page"
|
83
|
+
echo "_ffi_closure_trampoline_table_page:"
|
84
|
+
}
|
85
|
+
|
86
|
+
|
87
|
+
# WARNING - Don't modify the trampoline code size without also updating the relevent libffi code
|
88
|
+
trampoline () {
|
89
|
+
cat << END
|
90
|
+
|
91
|
+
// trampoline
|
92
|
+
// Save to stack
|
93
|
+
stmfd sp!, {r0-r3}
|
94
|
+
|
95
|
+
// Load the context argument from the config page.
|
96
|
+
// This places the first usable config value at _ffi_closure_trampoline_table-4080
|
97
|
+
// This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
|
98
|
+
ldr r0, [pc, #-4092]
|
99
|
+
|
100
|
+
// Load the jump address from the config page.
|
101
|
+
ldr pc, [pc, #-4092]
|
102
|
+
|
103
|
+
END
|
104
|
+
}
|
105
|
+
|
106
|
+
main () {
|
107
|
+
# Write out the header
|
108
|
+
header
|
109
|
+
|
110
|
+
# Write out the trampolines
|
111
|
+
local i=0
|
112
|
+
while [ $i -lt ${TRAMPOLINE_COUNT} ]; do
|
113
|
+
trampoline
|
114
|
+
local i=`expr $i + 1`
|
115
|
+
done
|
116
|
+
}
|
117
|
+
|
118
|
+
main
|
@@ -1,5 +1,6 @@
|
|
1
1
|
/* -----------------------------------------------------------------------
|
2
|
-
sysv.S - Copyright (c) 1998, 2008 Red Hat, Inc.
|
2
|
+
sysv.S - Copyright (c) 1998, 2008, 2011 Red Hat, Inc.
|
3
|
+
Copyright (c) 2011 Plausible Labs Cooperative, Inc.
|
3
4
|
|
4
5
|
ARM Foreign Function Interface
|
5
6
|
|
@@ -39,7 +40,11 @@
|
|
39
40
|
#else
|
40
41
|
#define CNAME(x) x
|
41
42
|
#endif
|
43
|
+
#ifdef __APPLE__
|
44
|
+
#define ENTRY(x) .globl CNAME(x); CNAME(x):
|
45
|
+
#else
|
42
46
|
#define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x):
|
47
|
+
#endif /* __APPLE__ */
|
43
48
|
#endif
|
44
49
|
|
45
50
|
#ifdef __ELF__
|
@@ -48,6 +53,12 @@
|
|
48
53
|
#define LSYM(x) x
|
49
54
|
#endif
|
50
55
|
|
56
|
+
/* Use the SOFTFP return value ABI on Mac OS X, as per the iOS ABI
|
57
|
+
Function Call Guide */
|
58
|
+
#ifdef __APPLE__
|
59
|
+
#define __SOFTFP__
|
60
|
+
#endif
|
61
|
+
|
51
62
|
/* We need a better way of testing for this, but for now, this is all
|
52
63
|
we can do. */
|
53
64
|
@ This selects the minimum architecture level required.
|
@@ -74,7 +85,8 @@
|
|
74
85
|
#endif
|
75
86
|
|
76
87
|
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
|
77
|
-
|| defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__)
|
88
|
+
|| defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
|
89
|
+
|| defined(__ARM_ARCH_7EM__)
|
78
90
|
# undef __ARM_ARCH__
|
79
91
|
# define __ARM_ARCH__ 7
|
80
92
|
#endif
|
@@ -104,21 +116,33 @@
|
|
104
116
|
.align 0
|
105
117
|
.thumb
|
106
118
|
.thumb_func
|
119
|
+
#ifdef __APPLE__
|
120
|
+
ENTRY($0)
|
121
|
+
#else
|
107
122
|
ENTRY(\name)
|
123
|
+
#endif
|
108
124
|
bx pc
|
109
125
|
nop
|
110
126
|
.arm
|
111
127
|
UNWIND .fnstart
|
112
128
|
/* A hook to tell gdb that we've switched to ARM mode. Also used to call
|
113
129
|
directly from other local arm routines. */
|
114
|
-
|
130
|
+
#ifdef __APPLE__
|
131
|
+
_L__$0:
|
132
|
+
#else
|
133
|
+
_L__\name:
|
134
|
+
#endif
|
115
135
|
.endm
|
116
136
|
#else
|
117
137
|
.macro ARM_FUNC_START name
|
118
138
|
.text
|
119
139
|
.align 0
|
120
140
|
.arm
|
141
|
+
#ifdef __APPLE__
|
142
|
+
ENTRY($0)
|
143
|
+
#else
|
121
144
|
ENTRY(\name)
|
145
|
+
#endif
|
122
146
|
UNWIND .fnstart
|
123
147
|
.endm
|
124
148
|
#endif
|
@@ -140,13 +164,11 @@ _L__\name:
|
|
140
164
|
#endif
|
141
165
|
.endm
|
142
166
|
|
143
|
-
|
144
167
|
@ r0: ffi_prep_args
|
145
168
|
@ r1: &ecif
|
146
169
|
@ r2: cif->bytes
|
147
170
|
@ r3: fig->flags
|
148
171
|
@ sp+0: ecif.rvalue
|
149
|
-
@ sp+4: fn
|
150
172
|
|
151
173
|
@ This assumes we are using gas.
|
152
174
|
ARM_FUNC_START ffi_call_SYSV
|
@@ -161,24 +183,23 @@ ARM_FUNC_START ffi_call_SYSV
|
|
161
183
|
sub sp, fp, r2
|
162
184
|
|
163
185
|
@ Place all of the ffi_prep_args in position
|
164
|
-
mov ip, r0
|
165
186
|
mov r0, sp
|
166
187
|
@ r1 already set
|
167
188
|
|
168
189
|
@ Call ffi_prep_args(stack, &ecif)
|
169
|
-
|
190
|
+
bl ffi_prep_args
|
170
191
|
|
171
192
|
@ move first 4 parameters in registers
|
172
193
|
ldmia sp, {r0-r3}
|
173
194
|
|
174
195
|
@ and adjust stack
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
196
|
+
sub lr, fp, sp @ cif->bytes == fp - sp
|
197
|
+
ldr ip, [fp] @ load fn() in advance
|
198
|
+
cmp lr, #16
|
199
|
+
movhs lr, #16
|
200
|
+
add sp, sp, lr
|
179
201
|
|
180
202
|
@ call (fn) (...)
|
181
|
-
ldr ip, [fp, #28]
|
182
203
|
call_reg(ip)
|
183
204
|
|
184
205
|
@ Remove the space we pushed for the args
|
@@ -223,11 +244,19 @@ ARM_FUNC_START ffi_call_SYSV
|
|
223
244
|
#endif
|
224
245
|
|
225
246
|
LSYM(Lepilogue):
|
226
|
-
|
247
|
+
#if defined (__INTERWORKING__)
|
248
|
+
ldmia sp!, {r0-r3,fp, lr}
|
249
|
+
bx lr
|
250
|
+
#else
|
251
|
+
ldmia sp!, {r0-r3,fp, pc}
|
252
|
+
#endif
|
227
253
|
|
228
254
|
.ffi_call_SYSV_end:
|
229
255
|
UNWIND .fnend
|
256
|
+
#ifdef __ELF__
|
230
257
|
.size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
|
258
|
+
#endif
|
259
|
+
|
231
260
|
|
232
261
|
/*
|
233
262
|
unsigned int FFI_HIDDEN
|
@@ -243,11 +272,11 @@ ARM_FUNC_START ffi_closure_SYSV
|
|
243
272
|
stmfd sp!, {ip, lr}
|
244
273
|
UNWIND .save {r0, lr}
|
245
274
|
add r2, sp, #8
|
246
|
-
.pad #16
|
275
|
+
UNWIND .pad #16
|
247
276
|
sub sp, sp, #16
|
248
277
|
str sp, [sp, #8]
|
249
278
|
add r1, sp, #8
|
250
|
-
bl ffi_closure_SYSV_inner
|
279
|
+
bl CNAME(ffi_closure_SYSV_inner)
|
251
280
|
cmp r0, #FFI_TYPE_INT
|
252
281
|
beq .Lretint
|
253
282
|
|
@@ -299,7 +328,169 @@ ARM_FUNC_START ffi_closure_SYSV
|
|
299
328
|
|
300
329
|
.ffi_closure_SYSV_end:
|
301
330
|
UNWIND .fnend
|
331
|
+
#ifdef __ELF__
|
302
332
|
.size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV)
|
333
|
+
#endif
|
334
|
+
|
335
|
+
|
336
|
+
/* Below are VFP hard-float ABI call and closure implementations.
|
337
|
+
Add VFP FPU directive here. */
|
338
|
+
.fpu vfp
|
339
|
+
|
340
|
+
@ r0: fn
|
341
|
+
@ r1: &ecif
|
342
|
+
@ r2: cif->bytes
|
343
|
+
@ r3: fig->flags
|
344
|
+
@ sp+0: ecif.rvalue
|
345
|
+
|
346
|
+
ARM_FUNC_START ffi_call_VFP
|
347
|
+
@ Save registers
|
348
|
+
stmfd sp!, {r0-r3, fp, lr}
|
349
|
+
UNWIND .save {r0-r3, fp, lr}
|
350
|
+
mov fp, sp
|
351
|
+
UNWIND .setfp fp, sp
|
352
|
+
|
353
|
+
@ Make room for all of the new args.
|
354
|
+
sub sp, sp, r2
|
355
|
+
|
356
|
+
@ Make room for loading VFP args
|
357
|
+
sub sp, sp, #64
|
358
|
+
|
359
|
+
@ Place all of the ffi_prep_args in position
|
360
|
+
mov r0, sp
|
361
|
+
@ r1 already set
|
362
|
+
sub r2, fp, #64 @ VFP scratch space
|
363
|
+
|
364
|
+
@ Call ffi_prep_args(stack, &ecif, vfp_space)
|
365
|
+
bl ffi_prep_args
|
366
|
+
|
367
|
+
@ Load VFP register args if needed
|
368
|
+
cmp r0, #0
|
369
|
+
beq LSYM(Lbase_args)
|
370
|
+
|
371
|
+
@ Load only d0 if possible
|
372
|
+
cmp r0, #3
|
373
|
+
sub ip, fp, #64
|
374
|
+
flddle d0, [ip]
|
375
|
+
fldmiadgt ip, {d0-d7}
|
376
|
+
|
377
|
+
LSYM(Lbase_args):
|
378
|
+
@ move first 4 parameters in registers
|
379
|
+
ldmia sp, {r0-r3}
|
380
|
+
|
381
|
+
@ and adjust stack
|
382
|
+
sub lr, ip, sp @ cif->bytes == (fp - 64) - sp
|
383
|
+
ldr ip, [fp] @ load fn() in advance
|
384
|
+
cmp lr, #16
|
385
|
+
movhs lr, #16
|
386
|
+
add sp, sp, lr
|
387
|
+
|
388
|
+
@ call (fn) (...)
|
389
|
+
call_reg(ip)
|
390
|
+
|
391
|
+
@ Remove the space we pushed for the args
|
392
|
+
mov sp, fp
|
393
|
+
|
394
|
+
@ Load r2 with the pointer to storage for
|
395
|
+
@ the return value
|
396
|
+
ldr r2, [sp, #24]
|
397
|
+
|
398
|
+
@ Load r3 with the return type code
|
399
|
+
ldr r3, [sp, #12]
|
400
|
+
|
401
|
+
@ If the return value pointer is NULL,
|
402
|
+
@ assume no return value.
|
403
|
+
cmp r2, #0
|
404
|
+
beq LSYM(Lepilogue_vfp)
|
405
|
+
|
406
|
+
cmp r3, #FFI_TYPE_INT
|
407
|
+
streq r0, [r2]
|
408
|
+
beq LSYM(Lepilogue_vfp)
|
409
|
+
|
410
|
+
cmp r3, #FFI_TYPE_SINT64
|
411
|
+
stmeqia r2, {r0, r1}
|
412
|
+
beq LSYM(Lepilogue_vfp)
|
413
|
+
|
414
|
+
cmp r3, #FFI_TYPE_FLOAT
|
415
|
+
fstseq s0, [r2]
|
416
|
+
beq LSYM(Lepilogue_vfp)
|
417
|
+
|
418
|
+
cmp r3, #FFI_TYPE_DOUBLE
|
419
|
+
fstdeq d0, [r2]
|
420
|
+
beq LSYM(Lepilogue_vfp)
|
421
|
+
|
422
|
+
cmp r3, #FFI_TYPE_STRUCT_VFP_FLOAT
|
423
|
+
cmpne r3, #FFI_TYPE_STRUCT_VFP_DOUBLE
|
424
|
+
fstmiadeq r2, {d0-d3}
|
425
|
+
|
426
|
+
LSYM(Lepilogue_vfp):
|
427
|
+
RETLDM "r0-r3,fp"
|
428
|
+
|
429
|
+
.ffi_call_VFP_end:
|
430
|
+
UNWIND .fnend
|
431
|
+
.size CNAME(ffi_call_VFP),.ffi_call_VFP_end-CNAME(ffi_call_VFP)
|
432
|
+
|
433
|
+
|
434
|
+
ARM_FUNC_START ffi_closure_VFP
|
435
|
+
fstmfdd sp!, {d0-d7}
|
436
|
+
@ r0-r3, then d0-d7
|
437
|
+
UNWIND .pad #80
|
438
|
+
add ip, sp, #80
|
439
|
+
stmfd sp!, {ip, lr}
|
440
|
+
UNWIND .save {r0, lr}
|
441
|
+
add r2, sp, #72
|
442
|
+
add r3, sp, #8
|
443
|
+
UNWIND .pad #72
|
444
|
+
sub sp, sp, #72
|
445
|
+
str sp, [sp, #64]
|
446
|
+
add r1, sp, #64
|
447
|
+
bl ffi_closure_SYSV_inner
|
448
|
+
|
449
|
+
cmp r0, #FFI_TYPE_INT
|
450
|
+
beq .Lretint_vfp
|
451
|
+
|
452
|
+
cmp r0, #FFI_TYPE_FLOAT
|
453
|
+
beq .Lretfloat_vfp
|
454
|
+
|
455
|
+
cmp r0, #FFI_TYPE_DOUBLE
|
456
|
+
cmpne r0, #FFI_TYPE_LONGDOUBLE
|
457
|
+
beq .Lretdouble_vfp
|
458
|
+
|
459
|
+
cmp r0, #FFI_TYPE_SINT64
|
460
|
+
beq .Lretlonglong_vfp
|
461
|
+
|
462
|
+
cmp r0, #FFI_TYPE_STRUCT_VFP_FLOAT
|
463
|
+
beq .Lretfloat_struct_vfp
|
464
|
+
|
465
|
+
cmp r0, #FFI_TYPE_STRUCT_VFP_DOUBLE
|
466
|
+
beq .Lretdouble_struct_vfp
|
467
|
+
|
468
|
+
.Lclosure_epilogue_vfp:
|
469
|
+
add sp, sp, #72
|
470
|
+
ldmfd sp, {sp, pc}
|
471
|
+
|
472
|
+
.Lretfloat_vfp:
|
473
|
+
flds s0, [sp]
|
474
|
+
b .Lclosure_epilogue_vfp
|
475
|
+
.Lretdouble_vfp:
|
476
|
+
fldd d0, [sp]
|
477
|
+
b .Lclosure_epilogue_vfp
|
478
|
+
.Lretint_vfp:
|
479
|
+
ldr r0, [sp]
|
480
|
+
b .Lclosure_epilogue_vfp
|
481
|
+
.Lretlonglong_vfp:
|
482
|
+
ldmia sp, {r0, r1}
|
483
|
+
b .Lclosure_epilogue_vfp
|
484
|
+
.Lretfloat_struct_vfp:
|
485
|
+
fldmiad sp, {d0-d1}
|
486
|
+
b .Lclosure_epilogue_vfp
|
487
|
+
.Lretdouble_struct_vfp:
|
488
|
+
fldmiad sp, {d0-d3}
|
489
|
+
b .Lclosure_epilogue_vfp
|
490
|
+
|
491
|
+
.ffi_closure_VFP_end:
|
492
|
+
UNWIND .fnend
|
493
|
+
.size CNAME(ffi_closure_VFP),.ffi_closure_VFP_end-CNAME(ffi_closure_VFP)
|
303
494
|
|
304
495
|
#if defined __ELF__ && defined __linux__
|
305
496
|
.section .note.GNU-stack,"",%progbits
|