ffi 1.0.11 → 1.0.12.pre

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.

Files changed (159) hide show
  1. data/Rakefile +1 -1
  2. data/ext/ffi_c/AbstractMemory.c +9 -0
  3. data/ext/ffi_c/AbstractMemory.h +4 -0
  4. data/ext/ffi_c/Buffer.c +8 -0
  5. data/ext/ffi_c/Call.c +8 -0
  6. data/ext/ffi_c/ClosurePool.c +12 -0
  7. data/ext/ffi_c/DynamicLibrary.c +7 -1
  8. data/ext/ffi_c/Function.c +11 -1
  9. data/ext/ffi_c/Function.h +6 -0
  10. data/ext/ffi_c/FunctionInfo.c +8 -0
  11. data/ext/ffi_c/LastError.c +8 -0
  12. data/ext/ffi_c/MemoryPointer.c +8 -0
  13. data/ext/ffi_c/MemoryPointer.h +6 -0
  14. data/ext/ffi_c/MethodHandle.c +8 -0
  15. data/ext/ffi_c/Platform.c +8 -0
  16. data/ext/ffi_c/Pointer.c +8 -0
  17. data/ext/ffi_c/Pointer.h +6 -0
  18. data/ext/ffi_c/Struct.c +6 -0
  19. data/ext/ffi_c/StructByReference.c +8 -0
  20. data/ext/ffi_c/StructByValue.c +8 -0
  21. data/ext/ffi_c/StructLayout.c +6 -0
  22. data/ext/ffi_c/Thread.c +7 -0
  23. data/ext/ffi_c/Thread.h +6 -0
  24. data/ext/ffi_c/Type.c +3 -0
  25. data/ext/ffi_c/Types.h +4 -0
  26. data/ext/ffi_c/Variadic.c +8 -0
  27. data/ext/ffi_c/endian.h +3 -0
  28. data/ext/ffi_c/extconf.rb +6 -1
  29. data/ext/ffi_c/libffi.vc.mk +26 -0
  30. data/ext/ffi_c/libffi.vc64.mk +26 -0
  31. data/ext/ffi_c/libffi/ChangeLog +541 -0
  32. data/ext/ffi_c/libffi/ChangeLog.libffi +13 -87
  33. data/ext/ffi_c/libffi/LICENSE +3 -3
  34. data/ext/ffi_c/libffi/Makefile.am +41 -32
  35. data/ext/ffi_c/libffi/Makefile.in +95 -66
  36. data/ext/ffi_c/libffi/Makefile.vc +141 -0
  37. data/ext/ffi_c/libffi/Makefile.vc64 +141 -0
  38. data/ext/ffi_c/libffi/README +40 -4
  39. data/ext/ffi_c/libffi/aclocal.m4 +729 -7854
  40. data/ext/ffi_c/libffi/build-ios.sh +67 -0
  41. data/ext/ffi_c/libffi/compile +11 -10
  42. data/ext/ffi_c/libffi/config.guess +4 -1
  43. data/ext/ffi_c/libffi/config.sub +6 -3
  44. data/ext/ffi_c/libffi/configure +6264 -6354
  45. data/ext/ffi_c/libffi/configure.ac +155 -63
  46. data/ext/ffi_c/libffi/depcomp +81 -35
  47. data/ext/ffi_c/libffi/doc/libffi.info +78 -18
  48. data/ext/ffi_c/libffi/doc/libffi.texi +64 -5
  49. data/ext/ffi_c/libffi/doc/stamp-vti +4 -4
  50. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  51. data/ext/ffi_c/libffi/fficonfig.h.in +18 -0
  52. data/ext/ffi_c/libffi/fficonfig.hw +57 -0
  53. data/ext/ffi_c/libffi/include/Makefile.in +21 -3
  54. data/ext/ffi_c/libffi/include/ffi.h.in +42 -14
  55. data/ext/ffi_c/libffi/include/ffi.h.vc +427 -0
  56. data/ext/ffi_c/libffi/include/ffi.h.vc64 +427 -0
  57. data/ext/ffi_c/libffi/include/ffi_common.h +9 -5
  58. data/ext/ffi_c/libffi/install-sh +364 -167
  59. data/ext/ffi_c/libffi/ltmain.sh +2599 -1369
  60. data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +176 -0
  61. data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +195 -0
  62. data/ext/ffi_c/libffi/m4/ax_check_compiler_flags.m4 +76 -0
  63. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +63 -0
  64. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +70 -0
  65. data/ext/ffi_c/libffi/m4/ax_enable_builddir.m4 +300 -0
  66. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +215 -0
  67. data/ext/ffi_c/libffi/m4/ax_gcc_x86_cpuid.m4 +79 -0
  68. data/ext/ffi_c/libffi/m4/libtool.m4 +1239 -768
  69. data/ext/ffi_c/libffi/m4/ltoptions.m4 +7 -6
  70. data/ext/ffi_c/libffi/m4/ltversion.m4 +6 -6
  71. data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +9 -3
  72. data/ext/ffi_c/libffi/man/Makefile.in +21 -3
  73. data/ext/ffi_c/libffi/mdate-sh +0 -0
  74. data/ext/ffi_c/libffi/missing +60 -44
  75. data/ext/ffi_c/libffi/msvcc.sh +197 -0
  76. data/ext/ffi_c/libffi/src/alpha/osf.S +39 -18
  77. data/ext/ffi_c/libffi/src/arm/ffi.c +443 -24
  78. data/ext/ffi_c/libffi/src/arm/ffitarget.h +17 -1
  79. data/ext/ffi_c/libffi/src/arm/gentramp.sh +118 -0
  80. data/ext/ffi_c/libffi/src/arm/sysv.S +206 -15
  81. data/ext/ffi_c/libffi/src/arm/trampoline.S +4450 -0
  82. data/ext/ffi_c/libffi/src/avr32/ffi.c +4 -2
  83. data/ext/ffi_c/libffi/src/avr32/ffitarget.h +2 -2
  84. data/ext/ffi_c/libffi/src/closures.c +17 -35
  85. data/ext/ffi_c/libffi/src/cris/ffi.c +1 -1
  86. data/ext/ffi_c/libffi/src/cris/ffitarget.h +2 -2
  87. data/ext/ffi_c/libffi/src/dlmalloc.c +66 -4
  88. data/ext/ffi_c/libffi/src/frv/ffitarget.h +2 -6
  89. data/ext/ffi_c/libffi/src/ia64/ffi.c +7 -5
  90. data/ext/ffi_c/libffi/src/ia64/ffitarget.h +2 -2
  91. data/ext/ffi_c/libffi/src/java_raw_api.c +1 -1
  92. data/ext/ffi_c/libffi/src/m32r/ffitarget.h +2 -2
  93. data/ext/ffi_c/libffi/src/m68k/ffi.c +10 -0
  94. data/ext/ffi_c/libffi/src/m68k/ffitarget.h +2 -2
  95. data/ext/ffi_c/libffi/src/m68k/sysv.S +36 -0
  96. data/ext/ffi_c/libffi/src/mips/ffi.c +12 -5
  97. data/ext/ffi_c/libffi/src/mips/ffitarget.h +18 -11
  98. data/ext/ffi_c/libffi/src/mips/n32.S +4 -4
  99. data/ext/ffi_c/libffi/src/moxie/eabi.S +128 -0
  100. data/ext/ffi_c/libffi/src/moxie/ffi.c +276 -0
  101. data/ext/ffi_c/libffi/src/pa/ffi.c +7 -4
  102. data/ext/ffi_c/libffi/src/pa/ffitarget.h +6 -5
  103. data/ext/ffi_c/libffi/src/powerpc/aix.S +5 -1
  104. data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +2 -0
  105. data/ext/ffi_c/libffi/src/powerpc/asm.h +1 -1
  106. data/ext/ffi_c/libffi/src/powerpc/darwin.S +215 -77
  107. data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +358 -100
  108. data/ext/ffi_c/libffi/src/powerpc/ffi.c +11 -5
  109. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +603 -172
  110. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +17 -4
  111. data/ext/ffi_c/libffi/src/prep_cif.c +16 -13
  112. data/ext/ffi_c/libffi/src/s390/ffitarget.h +4 -2
  113. data/ext/ffi_c/libffi/src/sh/ffitarget.h +2 -2
  114. data/ext/ffi_c/libffi/src/sh64/ffitarget.h +2 -2
  115. data/ext/ffi_c/libffi/src/sparc/ffi.c +55 -11
  116. data/ext/ffi_c/libffi/src/sparc/ffitarget.h +5 -3
  117. data/ext/ffi_c/libffi/src/x86/ffi.c +54 -92
  118. data/ext/ffi_c/libffi/src/x86/ffi64.c +17 -8
  119. data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -14
  120. data/ext/ffi_c/libffi/src/x86/sysv.S +40 -26
  121. data/ext/ffi_c/libffi/src/x86/unix64.S +4 -0
  122. data/ext/ffi_c/libffi/src/x86/win32.S +379 -191
  123. data/ext/ffi_c/libffi/src/x86/win64.S +15 -7
  124. data/ext/ffi_c/libffi/testsuite/Makefile.am +1 -1
  125. data/ext/ffi_c/libffi/testsuite/Makefile.in +22 -4
  126. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +350 -0
  127. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +1 -5
  128. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split.c +1 -1
  129. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c +1 -1
  130. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +1 -0
  131. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +1 -0
  132. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double_va.c +3 -0
  133. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble.c +2 -2
  134. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble_va.c +3 -0
  135. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer.c +1 -1
  136. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer_stack.c +1 -1
  137. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c +1 -0
  138. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_abi.c +2 -3
  139. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +2 -1
  140. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +36 -0
  141. data/ext/ffi_c/libffi/testsuite/libffi.call/huge_struct.c +17 -17
  142. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +1 -0
  143. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium2.c +1 -0
  144. data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +1 -1
  145. data/ext/ffi_c/libffi/testsuite/libffi.special/special.exp +1 -3
  146. data/ext/ffi_c/win32/stdint.h +199 -0
  147. data/gen/Rakefile +18 -2
  148. data/lib/ffi/platform/arm-linux/types.conf +102 -0
  149. data/lib/ffi/platform/i486-gnu/types.conf +107 -0
  150. data/lib/ffi/platform/ia64-linux/types.conf +102 -0
  151. data/lib/ffi/platform/mips-linux/types.conf +102 -0
  152. data/lib/ffi/platform/mipsel-linux/types.conf +102 -0
  153. data/lib/ffi/platform/powerpc-linux/types.conf +100 -0
  154. data/lib/ffi/platform/s390-linux/types.conf +102 -0
  155. data/lib/ffi/platform/s390x-linux/types.conf +102 -0
  156. data/lib/ffi/platform/sparc-linux/types.conf +102 -0
  157. data/lib/ffi/tools/types_generator.rb +8 -1
  158. data/lib/ffi_c.bundle +0 -0
  159. metadata +72 -42
@@ -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
- FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
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
- _L__\name:
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
- call_reg(ip)
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
- ldr ip, [fp, #8]
176
- cmp ip, #16
177
- movhs ip, #16
178
- add sp, sp, ip
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
- RETLDM "r0-r3,fp"
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