ffi 0.5.4-x86-mswin32 → 0.6.3-x86-mswin32
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/History.txt +102 -0
- data/LICENSE +1 -27
- data/Rakefile +4 -12
- data/ext/ffi_c/AbstractMemory.c +6 -8
- data/ext/ffi_c/AbstractMemory.h +23 -21
- data/ext/ffi_c/AutoPointer.c +0 -1
- data/ext/ffi_c/Buffer.c +23 -8
- data/ext/ffi_c/Call.c +31 -3
- data/ext/ffi_c/Call.h +5 -1
- data/ext/ffi_c/DynamicLibrary.c +0 -1
- data/ext/ffi_c/Function.c +22 -4
- data/ext/ffi_c/MemoryPointer.c +2 -3
- data/ext/ffi_c/Pointer.c +23 -9
- data/ext/ffi_c/Struct.c +227 -79
- data/ext/ffi_c/Struct.h +16 -7
- data/ext/ffi_c/StructLayout.c +92 -55
- data/ext/ffi_c/Type.c +5 -22
- data/ext/ffi_c/Type.h +1 -1
- data/ext/ffi_c/Types.c +9 -3
- data/ext/ffi_c/Types.h +2 -0
- data/ext/ffi_c/extconf.rb +11 -7
- data/ext/ffi_c/libffi.gnu.mk +1 -1
- data/ext/ffi_c/libffi.mk +1 -1
- data/ext/ffi_c/libffi/ChangeLog +900 -84
- data/ext/ffi_c/libffi/ChangeLog.libffi +311 -0
- data/ext/ffi_c/libffi/LICENSE +1 -1
- data/ext/ffi_c/libffi/Makefile.am +14 -4
- data/ext/ffi_c/libffi/Makefile.in +362 -211
- data/ext/ffi_c/libffi/README +70 -92
- data/ext/ffi_c/libffi/aclocal.m4 +6068 -4586
- data/ext/ffi_c/libffi/config.guess +125 -143
- data/ext/ffi_c/libffi/config.sub +103 -27
- data/ext/ffi_c/libffi/configure +11340 -18473
- data/ext/ffi_c/libffi/configure.ac +43 -4
- data/ext/ffi_c/libffi/doc/libffi.info +15 -15
- data/ext/ffi_c/libffi/doc/libffi.texi +1 -1
- 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 +24 -3
- data/ext/ffi_c/libffi/include/Makefile.am +1 -1
- data/ext/ffi_c/libffi/include/Makefile.in +97 -50
- data/ext/ffi_c/libffi/include/ffi.h.in +8 -2
- data/ext/ffi_c/libffi/include/ffi_common.h +24 -0
- data/ext/ffi_c/libffi/libtool-version +1 -1
- data/ext/ffi_c/libffi/ltmain.sh +7346 -5870
- data/ext/ffi_c/libffi/m4/libtool.m4 +7360 -0
- data/ext/ffi_c/libffi/m4/ltoptions.m4 +368 -0
- data/ext/ffi_c/libffi/m4/ltsugar.m4 +123 -0
- data/ext/ffi_c/libffi/m4/ltversion.m4 +23 -0
- data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +92 -0
- data/ext/ffi_c/libffi/man/Makefile.in +115 -62
- data/ext/ffi_c/libffi/man/ffi_call.3 +3 -3
- data/ext/ffi_c/libffi/missing +15 -8
- data/ext/ffi_c/libffi/src/arm/sysv.S +15 -8
- data/ext/ffi_c/libffi/src/avr32/ffi.c +421 -0
- data/ext/ffi_c/libffi/src/avr32/ffitarget.h +50 -0
- data/ext/ffi_c/libffi/src/avr32/sysv.S +208 -0
- data/ext/ffi_c/libffi/src/closures.c +47 -10
- data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/java_raw_api.c +0 -3
- data/ext/ffi_c/libffi/src/mips/ffi.c +135 -32
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +37 -4
- data/ext/ffi_c/libffi/src/mips/n32.S +67 -10
- data/ext/ffi_c/libffi/src/mips/o32.S +8 -8
- data/ext/ffi_c/libffi/src/pa/ffi.c +7 -0
- data/ext/ffi_c/libffi/src/powerpc/aix.S +163 -64
- data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +308 -112
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +20 -7
- data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +208 -80
- data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +11 -3
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +12 -23
- data/ext/ffi_c/libffi/src/s390/sysv.S +1 -1
- data/ext/ffi_c/libffi/src/sh/sysv.S +9 -9
- data/ext/ffi_c/libffi/src/sh64/ffi.c +37 -22
- data/ext/ffi_c/libffi/src/sh64/sysv.S +23 -14
- data/ext/ffi_c/libffi/src/sparc/ffi.c +21 -6
- data/ext/ffi_c/libffi/src/sparc/v8.S +55 -14
- data/ext/ffi_c/libffi/src/x86/darwin.S +10 -9
- data/ext/ffi_c/libffi/src/x86/ffi.c +293 -86
- data/ext/ffi_c/libffi/src/x86/ffi64.c +73 -19
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +30 -0
- data/ext/ffi_c/libffi/src/x86/sysv.S +21 -4
- data/ext/ffi_c/libffi/src/x86/unix64.S +8 -4
- data/ext/ffi_c/libffi/src/x86/win32.S +633 -147
- data/ext/ffi_c/libffi/src/x86/win64.S +460 -0
- data/ext/ffi_c/libffi/testsuite/Makefile.am +63 -54
- data/ext/ffi_c/libffi/testsuite/Makefile.in +112 -77
- data/ext/ffi_c/libffi/testsuite/lib/libffi-dg.exp +12 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn0.c +7 -15
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn1.c +7 -15
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn2.c +7 -15
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn3.c +7 -15
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn4.c +7 -15
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn5.c +7 -14
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn6.c +7 -15
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_loc_fn0.c +95 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_stdcall.c +6 -14
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_12byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_16byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_18byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_19byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_1_1byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte1.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_24byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_2byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3_1byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte1.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte2.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4_1byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5_1_byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_64byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6_1_byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7_1_byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_8byte.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte1.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte2.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_double.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_float.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split.c +134 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c +117 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_pointer.c +11 -17
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint16.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint32.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +7 -15
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint16.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint32.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +7 -15
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_dbls_struct.c +66 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double_va.c +57 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_float.c +4 -13
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble.c +105 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble_va.c +57 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_schar.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshort.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshortchar.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_uchar.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushort.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushortchar.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer.c +74 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer_stack.c +140 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_schar.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sint.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sshort.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uint.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c +8 -16
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_abi.c +37 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +25 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +31 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +2 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/huge_struct.c +342 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct1.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct10.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct2.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct3.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct4.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct5.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct6.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct7.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct8.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct9.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/problem1.c +4 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large.c +145 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large2.c +148 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium.c +124 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium2.c +124 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c +70 -0
- data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.special/special.exp +4 -5
- data/ext/ffi_c/libffi/testsuite/libffi.special/unwindtest.cc +17 -16
- data/ext/ffi_c/libffi/texinfo.tex +155 -427
- data/gen/Rakefile +4 -2
- data/lib/1.8/ffi_c.so +0 -0
- data/lib/1.9/ffi_c.so +0 -0
- data/lib/ffi/autopointer.rb +79 -20
- data/lib/ffi/callback.rb +4 -10
- data/lib/ffi/enum.rb +28 -0
- data/lib/ffi/ffi.rb +1 -0
- data/lib/ffi/io.rb +28 -0
- data/lib/ffi/library.rb +237 -182
- data/lib/ffi/memorypointer.rb +28 -62
- data/lib/ffi/platform.rb +27 -0
- data/lib/ffi/pointer.rb +28 -0
- data/lib/ffi/struct.rb +55 -1
- data/lib/ffi/types.rb +29 -0
- data/lib/ffi/variadic.rb +29 -0
- data/spec/ffi/library_spec.rb +31 -5
- data/spec/ffi/rbx/attach_function_spec.rb +2 -1
- data/spec/ffi/rbx/memory_pointer_spec.rb +2 -1
- data/spec/ffi/spec_helper.rb +5 -1
- data/spec/ffi/struct_spec.rb +82 -0
- data/tasks/ann.rake +80 -0
- data/tasks/extension.rake +25 -0
- data/tasks/gem.rake +200 -0
- data/tasks/git.rake +41 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +34 -0
- data/tasks/rdoc.rake +50 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +300 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- metadata +312 -279
- data/ext/ffi_c/libffi/TODO +0 -1
- data/ext/ffi_c/libffi/ltcf-c.sh +0 -861
- data/ext/ffi_c/libffi/ltcf-cxx.sh +0 -1069
- data/ext/ffi_c/libffi/ltcf-gcj.sh +0 -700
- data/ext/ffi_c/libffi/ltconfig +0 -2862
- data/ext/ffi_c/libffi/mkinstalldirs +0 -158
data/ext/ffi_c/libffi/missing
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#! /bin/sh
|
2
2
|
# Common stub for a few missing GNU programs while installing.
|
3
3
|
|
4
|
-
scriptversion=
|
4
|
+
scriptversion=2005-06-08.21
|
5
5
|
|
6
|
-
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004
|
6
|
+
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
|
7
7
|
# Free Software Foundation, Inc.
|
8
8
|
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
9
9
|
|
@@ -19,8 +19,8 @@ scriptversion=2004-09-07.08
|
|
19
19
|
|
20
20
|
# You should have received a copy of the GNU General Public License
|
21
21
|
# along with this program; if not, write to the Free Software
|
22
|
-
# Foundation, Inc.,
|
23
|
-
#
|
22
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
23
|
+
# 02110-1301, USA.
|
24
24
|
|
25
25
|
# As a special exception to the GNU General Public License, if you
|
26
26
|
# distribute this file as part of a program that contains a
|
@@ -87,12 +87,12 @@ Supported PROGRAM values:
|
|
87
87
|
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
|
88
88
|
|
89
89
|
Send bug reports to <bug-automake@gnu.org>."
|
90
|
-
exit
|
90
|
+
exit $?
|
91
91
|
;;
|
92
92
|
|
93
93
|
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
94
94
|
echo "missing $scriptversion (GNU Automake)"
|
95
|
-
exit
|
95
|
+
exit $?
|
96
96
|
;;
|
97
97
|
|
98
98
|
-*)
|
@@ -288,11 +288,18 @@ WARNING: \`$1' is $msg. You should only need it if
|
|
288
288
|
call might also be the consequence of using a buggy \`make' (AIX,
|
289
289
|
DU, IRIX). You might want to install the \`Texinfo' package or
|
290
290
|
the \`GNU make' package. Grab either from any GNU archive site."
|
291
|
+
# The file to touch is that specified with -o ...
|
291
292
|
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
|
292
293
|
if test -z "$file"; then
|
293
|
-
|
294
|
-
|
294
|
+
# ... or it is the one specified with @setfilename ...
|
295
|
+
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
|
296
|
+
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
|
297
|
+
# ... or it is derived from the source name (dir/f.texi becomes f.info)
|
298
|
+
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
|
295
299
|
fi
|
300
|
+
# If the file does not exist, the user really needs makeinfo;
|
301
|
+
# let's fail without touching anything.
|
302
|
+
test -f $file || exit 1
|
296
303
|
touch $file
|
297
304
|
;;
|
298
305
|
|
@@ -67,11 +67,18 @@
|
|
67
67
|
|
68
68
|
#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
|
69
69
|
|| defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \
|
70
|
-
|| defined(__ARM_ARCH_6ZK__)
|
70
|
+
|| defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) \
|
71
|
+
|| defined(__ARM_ARCH_6M__)
|
71
72
|
# undef __ARM_ARCH__
|
72
73
|
# define __ARM_ARCH__ 6
|
73
74
|
#endif
|
74
75
|
|
76
|
+
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
|
77
|
+
|| defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__)
|
78
|
+
# undef __ARM_ARCH__
|
79
|
+
# define __ARM_ARCH__ 7
|
80
|
+
#endif
|
81
|
+
|
75
82
|
#if __ARM_ARCH__ >= 5
|
76
83
|
# define call_reg(x) blx x
|
77
84
|
#elif defined (__ARM_ARCH_4T__)
|
@@ -189,7 +196,7 @@ ARM_FUNC_START ffi_call_SYSV
|
|
189
196
|
|
190
197
|
@ return INT
|
191
198
|
cmp r3, #FFI_TYPE_INT
|
192
|
-
#
|
199
|
+
#if defined(__SOFTFP__) || defined(__ARM_EABI__)
|
193
200
|
cmpne r3, #FFI_TYPE_FLOAT
|
194
201
|
#endif
|
195
202
|
streq r0, [r2]
|
@@ -197,12 +204,12 @@ ARM_FUNC_START ffi_call_SYSV
|
|
197
204
|
|
198
205
|
@ return INT64
|
199
206
|
cmp r3, #FFI_TYPE_SINT64
|
200
|
-
#
|
207
|
+
#if defined(__SOFTFP__) || defined(__ARM_EABI__)
|
201
208
|
cmpne r3, #FFI_TYPE_DOUBLE
|
202
209
|
#endif
|
203
210
|
stmeqia r2, {r0, r1}
|
204
211
|
|
205
|
-
#
|
212
|
+
#if !defined(__SOFTFP__) && !defined(__ARM_EABI__)
|
206
213
|
beq LSYM(Lepilogue)
|
207
214
|
|
208
215
|
@ return FLOAT
|
@@ -245,21 +252,21 @@ ARM_FUNC_START ffi_closure_SYSV
|
|
245
252
|
beq .Lretint
|
246
253
|
|
247
254
|
cmp r0, #FFI_TYPE_FLOAT
|
248
|
-
#
|
255
|
+
#if defined(__SOFTFP__) || defined(__ARM_EABI__)
|
249
256
|
beq .Lretint
|
250
257
|
#else
|
251
258
|
beq .Lretfloat
|
252
259
|
#endif
|
253
260
|
|
254
261
|
cmp r0, #FFI_TYPE_DOUBLE
|
255
|
-
#
|
262
|
+
#if defined(__SOFTFP__) || defined(__ARM_EABI__)
|
256
263
|
beq .Lretlonglong
|
257
264
|
#else
|
258
265
|
beq .Lretdouble
|
259
266
|
#endif
|
260
267
|
|
261
268
|
cmp r0, #FFI_TYPE_LONGDOUBLE
|
262
|
-
#
|
269
|
+
#if defined(__SOFTFP__) || defined(__ARM_EABI__)
|
263
270
|
beq .Lretlonglong
|
264
271
|
#else
|
265
272
|
beq .Lretlongdouble
|
@@ -278,7 +285,7 @@ ARM_FUNC_START ffi_closure_SYSV
|
|
278
285
|
ldr r1, [sp, #4]
|
279
286
|
b .Lclosure_epilogue
|
280
287
|
|
281
|
-
#
|
288
|
+
#if !defined(__SOFTFP__) && !defined(__ARM_EABI__)
|
282
289
|
.Lretfloat:
|
283
290
|
ldfs f0, [sp]
|
284
291
|
b .Lclosure_epilogue
|
@@ -0,0 +1,421 @@
|
|
1
|
+
/* -----------------------------------------------------------------------
|
2
|
+
ffi.c - Copyright (c) 2009 Bradley Smith <brad@brad-smith.co.uk>
|
3
|
+
|
4
|
+
AVR32 Foreign Function Interface
|
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
|
+
#include <ffi.h>
|
28
|
+
#include <ffi_common.h>
|
29
|
+
|
30
|
+
#include <stdlib.h>
|
31
|
+
#include <stdio.h>
|
32
|
+
#include <unistd.h>
|
33
|
+
#include <asm/unistd.h>
|
34
|
+
|
35
|
+
/* #define DEBUG */
|
36
|
+
|
37
|
+
extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *,
|
38
|
+
unsigned int, unsigned int, unsigned int*, unsigned int,
|
39
|
+
void (*fn)(void));
|
40
|
+
extern void ffi_closure_SYSV (ffi_closure *);
|
41
|
+
|
42
|
+
unsigned int pass_struct_on_stack(ffi_type *type)
|
43
|
+
{
|
44
|
+
if(type->type != FFI_TYPE_STRUCT)
|
45
|
+
return 0;
|
46
|
+
|
47
|
+
if(type->alignment < type->size &&
|
48
|
+
!(type->size == 4 || type->size == 8) &&
|
49
|
+
!(type->size == 8 && type->alignment >= 4))
|
50
|
+
return 1;
|
51
|
+
|
52
|
+
if(type->size == 3 || type->size == 5 || type->size == 6 ||
|
53
|
+
type->size == 7)
|
54
|
+
return 1;
|
55
|
+
|
56
|
+
return 0;
|
57
|
+
}
|
58
|
+
|
59
|
+
/* ffi_prep_args is called by the assembly routine once stack space
|
60
|
+
* has been allocated for the function's arguments
|
61
|
+
*
|
62
|
+
* This is annoyingly complex since we need to keep track of used
|
63
|
+
* registers.
|
64
|
+
*/
|
65
|
+
|
66
|
+
void ffi_prep_args(char *stack, extended_cif *ecif)
|
67
|
+
{
|
68
|
+
unsigned int i;
|
69
|
+
void **p_argv;
|
70
|
+
ffi_type **p_arg;
|
71
|
+
char *reg_base = stack;
|
72
|
+
char *stack_base = stack + 20;
|
73
|
+
unsigned int stack_offset = 0;
|
74
|
+
unsigned int reg_mask = 0;
|
75
|
+
|
76
|
+
p_argv = ecif->avalue;
|
77
|
+
|
78
|
+
/* If cif->flags is struct then we know it's not passed in registers */
|
79
|
+
if(ecif->cif->flags == FFI_TYPE_STRUCT)
|
80
|
+
{
|
81
|
+
*(void**)reg_base = ecif->rvalue;
|
82
|
+
reg_mask |= 1;
|
83
|
+
}
|
84
|
+
|
85
|
+
for(i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs;
|
86
|
+
i++, p_arg++)
|
87
|
+
{
|
88
|
+
size_t z = (*p_arg)->size;
|
89
|
+
int alignment = (*p_arg)->alignment;
|
90
|
+
int type = (*p_arg)->type;
|
91
|
+
char *addr = 0;
|
92
|
+
|
93
|
+
if(z % 4 != 0)
|
94
|
+
z += (4 - z % 4);
|
95
|
+
|
96
|
+
if(reg_mask != 0x1f)
|
97
|
+
{
|
98
|
+
if(pass_struct_on_stack(*p_arg))
|
99
|
+
{
|
100
|
+
addr = stack_base + stack_offset;
|
101
|
+
stack_offset += z;
|
102
|
+
}
|
103
|
+
else if(z == sizeof(int))
|
104
|
+
{
|
105
|
+
char index = 0;
|
106
|
+
|
107
|
+
while((reg_mask >> index) & 1)
|
108
|
+
index++;
|
109
|
+
|
110
|
+
addr = reg_base + (index * 4);
|
111
|
+
reg_mask |= (1 << index);
|
112
|
+
}
|
113
|
+
else if(z == 2 * sizeof(int))
|
114
|
+
{
|
115
|
+
if(!((reg_mask >> 1) & 1))
|
116
|
+
{
|
117
|
+
addr = reg_base + 4;
|
118
|
+
reg_mask |= (3 << 1);
|
119
|
+
}
|
120
|
+
else if(!((reg_mask >> 3) & 1))
|
121
|
+
{
|
122
|
+
addr = reg_base + 12;
|
123
|
+
reg_mask |= (3 << 3);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
if(!addr)
|
129
|
+
{
|
130
|
+
addr = stack_base + stack_offset;
|
131
|
+
stack_offset += z;
|
132
|
+
}
|
133
|
+
|
134
|
+
if(type == FFI_TYPE_STRUCT && (*p_arg)->elements[1] == NULL)
|
135
|
+
type = (*p_arg)->elements[0]->type;
|
136
|
+
|
137
|
+
switch(type)
|
138
|
+
{
|
139
|
+
case FFI_TYPE_UINT8:
|
140
|
+
*(unsigned int *)addr = (unsigned int)*(UINT8 *)(*p_argv);
|
141
|
+
break;
|
142
|
+
case FFI_TYPE_SINT8:
|
143
|
+
*(signed int *)addr = (signed int)*(SINT8 *)(*p_argv);
|
144
|
+
break;
|
145
|
+
case FFI_TYPE_UINT16:
|
146
|
+
*(unsigned int *)addr = (unsigned int)*(UINT16 *)(*p_argv);
|
147
|
+
break;
|
148
|
+
case FFI_TYPE_SINT16:
|
149
|
+
*(signed int *)addr = (signed int)*(SINT16 *)(*p_argv);
|
150
|
+
break;
|
151
|
+
default:
|
152
|
+
memcpy(addr, *p_argv, z);
|
153
|
+
}
|
154
|
+
|
155
|
+
p_argv++;
|
156
|
+
}
|
157
|
+
|
158
|
+
#ifdef DEBUG
|
159
|
+
/* Debugging */
|
160
|
+
for(i = 0; i < 5; i++)
|
161
|
+
{
|
162
|
+
if((reg_mask & (1 << i)) == 0)
|
163
|
+
printf("r%d: (unused)\n", 12 - i);
|
164
|
+
else
|
165
|
+
printf("r%d: 0x%08x\n", 12 - i, ((unsigned int*)reg_base)[i]);
|
166
|
+
}
|
167
|
+
|
168
|
+
for(i = 0; i < stack_offset / 4; i++)
|
169
|
+
{
|
170
|
+
printf("sp+%d: 0x%08x\n", i*4, ((unsigned int*)stack_base)[i]);
|
171
|
+
}
|
172
|
+
#endif
|
173
|
+
}
|
174
|
+
|
175
|
+
/* Perform machine dependent cif processing */
|
176
|
+
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
|
177
|
+
{
|
178
|
+
/* Round the stack up to a multiple of 8 bytes. This isn't needed
|
179
|
+
* everywhere, but it is on some platforms, and it doesn't harm
|
180
|
+
* anything when it isn't needed. */
|
181
|
+
cif->bytes = (cif->bytes + 7) & ~7;
|
182
|
+
|
183
|
+
/* Flag to indicate that he return value is in fact a struct */
|
184
|
+
cif->rstruct_flag = 0;
|
185
|
+
|
186
|
+
/* Set the return type flag */
|
187
|
+
switch(cif->rtype->type)
|
188
|
+
{
|
189
|
+
case FFI_TYPE_SINT8:
|
190
|
+
case FFI_TYPE_UINT8:
|
191
|
+
cif->flags = (unsigned)FFI_TYPE_UINT8;
|
192
|
+
break;
|
193
|
+
case FFI_TYPE_SINT16:
|
194
|
+
case FFI_TYPE_UINT16:
|
195
|
+
cif->flags = (unsigned)FFI_TYPE_UINT16;
|
196
|
+
break;
|
197
|
+
case FFI_TYPE_FLOAT:
|
198
|
+
case FFI_TYPE_SINT32:
|
199
|
+
case FFI_TYPE_UINT32:
|
200
|
+
case FFI_TYPE_POINTER:
|
201
|
+
cif->flags = (unsigned)FFI_TYPE_UINT32;
|
202
|
+
break;
|
203
|
+
case FFI_TYPE_DOUBLE:
|
204
|
+
case FFI_TYPE_SINT64:
|
205
|
+
case FFI_TYPE_UINT64:
|
206
|
+
cif->flags = (unsigned)FFI_TYPE_UINT64;
|
207
|
+
break;
|
208
|
+
case FFI_TYPE_STRUCT:
|
209
|
+
cif->rstruct_flag = 1;
|
210
|
+
if(!pass_struct_on_stack(cif->rtype))
|
211
|
+
{
|
212
|
+
if(cif->rtype->size <= 1)
|
213
|
+
cif->flags = (unsigned)FFI_TYPE_UINT8;
|
214
|
+
else if(cif->rtype->size <= 2)
|
215
|
+
cif->flags = (unsigned)FFI_TYPE_UINT16;
|
216
|
+
else if(cif->rtype->size <= 4)
|
217
|
+
cif->flags = (unsigned)FFI_TYPE_UINT32;
|
218
|
+
else if(cif->rtype->size <= 8)
|
219
|
+
cif->flags = (unsigned)FFI_TYPE_UINT64;
|
220
|
+
else
|
221
|
+
cif->flags = (unsigned)cif->rtype->type;
|
222
|
+
}
|
223
|
+
else
|
224
|
+
cif->flags = (unsigned)cif->rtype->type;
|
225
|
+
break;
|
226
|
+
default:
|
227
|
+
cif->flags = (unsigned)cif->rtype->type;
|
228
|
+
break;
|
229
|
+
}
|
230
|
+
|
231
|
+
return FFI_OK;
|
232
|
+
}
|
233
|
+
|
234
|
+
void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
|
235
|
+
{
|
236
|
+
extended_cif ecif;
|
237
|
+
|
238
|
+
unsigned int size = 0, i = 0;
|
239
|
+
ffi_type **p_arg;
|
240
|
+
|
241
|
+
ecif.cif = cif;
|
242
|
+
ecif.avalue = avalue;
|
243
|
+
|
244
|
+
for(i = 0, p_arg = cif->arg_types; i < cif->nargs; i++, p_arg++)
|
245
|
+
size += (*p_arg)->size + (4 - (*p_arg)->size % 4);
|
246
|
+
|
247
|
+
/* If the return value is a struct and we don't have a return value
|
248
|
+
* address then we need to make one */
|
249
|
+
|
250
|
+
/* If cif->flags is struct then it's not suitable for registers */
|
251
|
+
if((rvalue == NULL) && (cif->flags == FFI_TYPE_STRUCT))
|
252
|
+
ecif.rvalue = alloca(cif->rtype->size);
|
253
|
+
else
|
254
|
+
ecif.rvalue = rvalue;
|
255
|
+
|
256
|
+
switch(cif->abi)
|
257
|
+
{
|
258
|
+
case FFI_SYSV:
|
259
|
+
ffi_call_SYSV(ffi_prep_args, &ecif, size, cif->flags,
|
260
|
+
ecif.rvalue, cif->rstruct_flag, fn);
|
261
|
+
break;
|
262
|
+
default:
|
263
|
+
FFI_ASSERT(0);
|
264
|
+
break;
|
265
|
+
}
|
266
|
+
}
|
267
|
+
|
268
|
+
static void ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
|
269
|
+
void **avalue, ffi_cif *cif)
|
270
|
+
{
|
271
|
+
register unsigned int i, reg_mask = 0;
|
272
|
+
register void **p_argv;
|
273
|
+
register ffi_type **p_arg;
|
274
|
+
register char *reg_base = stack;
|
275
|
+
register char *stack_base = stack + 20;
|
276
|
+
register unsigned int stack_offset = 0;
|
277
|
+
|
278
|
+
#ifdef DEBUG
|
279
|
+
/* Debugging */
|
280
|
+
for(i = 0; i < cif->nargs + 7; i++)
|
281
|
+
{
|
282
|
+
printf("sp+%d: 0x%08x\n", i*4, ((unsigned int*)stack)[i]);
|
283
|
+
}
|
284
|
+
#endif
|
285
|
+
|
286
|
+
/* If cif->flags is struct then we know it's not passed in registers */
|
287
|
+
if(cif->flags == FFI_TYPE_STRUCT)
|
288
|
+
{
|
289
|
+
*rvalue = *(void **)reg_base;
|
290
|
+
reg_mask |= 1;
|
291
|
+
}
|
292
|
+
|
293
|
+
p_argv = avalue;
|
294
|
+
|
295
|
+
for(i = 0, p_arg = cif->arg_types; i < cif->nargs; i++, p_arg++)
|
296
|
+
{
|
297
|
+
size_t z = (*p_arg)->size;
|
298
|
+
int alignment = (*p_arg)->alignment;
|
299
|
+
|
300
|
+
*p_argv = 0;
|
301
|
+
|
302
|
+
if(z % 4 != 0)
|
303
|
+
z += (4 - z % 4);
|
304
|
+
|
305
|
+
if(reg_mask != 0x1f)
|
306
|
+
{
|
307
|
+
if(pass_struct_on_stack(*p_arg))
|
308
|
+
{
|
309
|
+
*p_argv = (void*)stack_base + stack_offset;
|
310
|
+
stack_offset += z;
|
311
|
+
}
|
312
|
+
else if(z <= sizeof(int))
|
313
|
+
{
|
314
|
+
char index = 0;
|
315
|
+
|
316
|
+
while((reg_mask >> index) & 1)
|
317
|
+
index++;
|
318
|
+
|
319
|
+
*p_argv = (void*)reg_base + (index * 4);
|
320
|
+
reg_mask |= (1 << index);
|
321
|
+
}
|
322
|
+
else if(z == 2 * sizeof(int))
|
323
|
+
{
|
324
|
+
if(!((reg_mask >> 1) & 1))
|
325
|
+
{
|
326
|
+
*p_argv = (void*)reg_base + 4;
|
327
|
+
reg_mask |= (3 << 1);
|
328
|
+
}
|
329
|
+
else if(!((reg_mask >> 3) & 1))
|
330
|
+
{
|
331
|
+
*p_argv = (void*)reg_base + 12;
|
332
|
+
reg_mask |= (3 << 3);
|
333
|
+
}
|
334
|
+
}
|
335
|
+
}
|
336
|
+
|
337
|
+
if(!*p_argv)
|
338
|
+
{
|
339
|
+
*p_argv = (void*)stack_base + stack_offset;
|
340
|
+
stack_offset += z;
|
341
|
+
}
|
342
|
+
|
343
|
+
if((*p_arg)->type != FFI_TYPE_STRUCT ||
|
344
|
+
(*p_arg)->elements[1] == NULL)
|
345
|
+
{
|
346
|
+
if(alignment == 1)
|
347
|
+
**(unsigned int**)p_argv <<= 24;
|
348
|
+
else if(alignment == 2)
|
349
|
+
**(unsigned int**)p_argv <<= 16;
|
350
|
+
}
|
351
|
+
|
352
|
+
p_argv++;
|
353
|
+
}
|
354
|
+
|
355
|
+
#ifdef DEBUG
|
356
|
+
/* Debugging */
|
357
|
+
for(i = 0; i < cif->nargs; i++)
|
358
|
+
{
|
359
|
+
printf("sp+%d: 0x%08x\n", i*4, *(((unsigned int**)avalue)[i]));
|
360
|
+
}
|
361
|
+
#endif
|
362
|
+
}
|
363
|
+
|
364
|
+
/* This function is jumped to by the trampoline */
|
365
|
+
|
366
|
+
unsigned int ffi_closure_SYSV_inner(ffi_closure *closure, void **respp,
|
367
|
+
void *args)
|
368
|
+
{
|
369
|
+
ffi_cif *cif;
|
370
|
+
void **arg_area;
|
371
|
+
unsigned int i, size = 0;
|
372
|
+
ffi_type **p_arg;
|
373
|
+
|
374
|
+
cif = closure->cif;
|
375
|
+
|
376
|
+
for(i = 0, p_arg = cif->arg_types; i < cif->nargs; i++, p_arg++)
|
377
|
+
size += (*p_arg)->size + (4 - (*p_arg)->size % 4);
|
378
|
+
|
379
|
+
arg_area = (void **)alloca(size);
|
380
|
+
|
381
|
+
/* this call will initialize ARG_AREA, such that each element in that
|
382
|
+
* array points to the corresponding value on the stack; and if the
|
383
|
+
* function returns a structure, it will re-set RESP to point to the
|
384
|
+
* structure return address. */
|
385
|
+
|
386
|
+
ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif);
|
387
|
+
|
388
|
+
(closure->fun)(cif, *respp, arg_area, closure->user_data);
|
389
|
+
|
390
|
+
return cif->flags;
|
391
|
+
}
|
392
|
+
|
393
|
+
ffi_status ffi_prep_closure_loc(ffi_closure* closure, ffi_cif* cif,
|
394
|
+
void (*fun)(ffi_cif*, void*, void**, void*), void *user_data,
|
395
|
+
void *codeloc)
|
396
|
+
{
|
397
|
+
FFI_ASSERT(cif->abi == FFI_SYSV);
|
398
|
+
|
399
|
+
unsigned char *__tramp = (unsigned char*)(&closure->tramp[0]);
|
400
|
+
unsigned int __fun = (unsigned int)(&ffi_closure_SYSV);
|
401
|
+
unsigned int __ctx = (unsigned int)(codeloc);
|
402
|
+
unsigned int __rstruct_flag = (unsigned int)(cif->rstruct_flag);
|
403
|
+
unsigned int __inner = (unsigned int)(&ffi_closure_SYSV_inner);
|
404
|
+
*(unsigned int*) &__tramp[0] = 0xebcd1f00; /* pushm r8-r12 */
|
405
|
+
*(unsigned int*) &__tramp[4] = 0xfefc0010; /* ld.w r12, pc[16] */
|
406
|
+
*(unsigned int*) &__tramp[8] = 0xfefb0010; /* ld.w r11, pc[16] */
|
407
|
+
*(unsigned int*) &__tramp[12] = 0xfefa0010; /* ld.w r10, pc[16] */
|
408
|
+
*(unsigned int*) &__tramp[16] = 0xfeff0010; /* ld.w pc, pc[16] */
|
409
|
+
*(unsigned int*) &__tramp[20] = __ctx;
|
410
|
+
*(unsigned int*) &__tramp[24] = __rstruct_flag;
|
411
|
+
*(unsigned int*) &__tramp[28] = __inner;
|
412
|
+
*(unsigned int*) &__tramp[32] = __fun;
|
413
|
+
syscall(__NR_cacheflush, 0, (&__tramp[0]), 36);
|
414
|
+
|
415
|
+
closure->cif = cif;
|
416
|
+
closure->user_data = user_data;
|
417
|
+
closure->fun = fun;
|
418
|
+
|
419
|
+
return FFI_OK;
|
420
|
+
}
|
421
|
+
|