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.

Files changed (222) hide show
  1. data/History.txt +102 -0
  2. data/LICENSE +1 -27
  3. data/Rakefile +4 -12
  4. data/ext/ffi_c/AbstractMemory.c +6 -8
  5. data/ext/ffi_c/AbstractMemory.h +23 -21
  6. data/ext/ffi_c/AutoPointer.c +0 -1
  7. data/ext/ffi_c/Buffer.c +23 -8
  8. data/ext/ffi_c/Call.c +31 -3
  9. data/ext/ffi_c/Call.h +5 -1
  10. data/ext/ffi_c/DynamicLibrary.c +0 -1
  11. data/ext/ffi_c/Function.c +22 -4
  12. data/ext/ffi_c/MemoryPointer.c +2 -3
  13. data/ext/ffi_c/Pointer.c +23 -9
  14. data/ext/ffi_c/Struct.c +227 -79
  15. data/ext/ffi_c/Struct.h +16 -7
  16. data/ext/ffi_c/StructLayout.c +92 -55
  17. data/ext/ffi_c/Type.c +5 -22
  18. data/ext/ffi_c/Type.h +1 -1
  19. data/ext/ffi_c/Types.c +9 -3
  20. data/ext/ffi_c/Types.h +2 -0
  21. data/ext/ffi_c/extconf.rb +11 -7
  22. data/ext/ffi_c/libffi.gnu.mk +1 -1
  23. data/ext/ffi_c/libffi.mk +1 -1
  24. data/ext/ffi_c/libffi/ChangeLog +900 -84
  25. data/ext/ffi_c/libffi/ChangeLog.libffi +311 -0
  26. data/ext/ffi_c/libffi/LICENSE +1 -1
  27. data/ext/ffi_c/libffi/Makefile.am +14 -4
  28. data/ext/ffi_c/libffi/Makefile.in +362 -211
  29. data/ext/ffi_c/libffi/README +70 -92
  30. data/ext/ffi_c/libffi/aclocal.m4 +6068 -4586
  31. data/ext/ffi_c/libffi/config.guess +125 -143
  32. data/ext/ffi_c/libffi/config.sub +103 -27
  33. data/ext/ffi_c/libffi/configure +11340 -18473
  34. data/ext/ffi_c/libffi/configure.ac +43 -4
  35. data/ext/ffi_c/libffi/doc/libffi.info +15 -15
  36. data/ext/ffi_c/libffi/doc/libffi.texi +1 -1
  37. data/ext/ffi_c/libffi/doc/stamp-vti +4 -4
  38. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  39. data/ext/ffi_c/libffi/fficonfig.h.in +24 -3
  40. data/ext/ffi_c/libffi/include/Makefile.am +1 -1
  41. data/ext/ffi_c/libffi/include/Makefile.in +97 -50
  42. data/ext/ffi_c/libffi/include/ffi.h.in +8 -2
  43. data/ext/ffi_c/libffi/include/ffi_common.h +24 -0
  44. data/ext/ffi_c/libffi/libtool-version +1 -1
  45. data/ext/ffi_c/libffi/ltmain.sh +7346 -5870
  46. data/ext/ffi_c/libffi/m4/libtool.m4 +7360 -0
  47. data/ext/ffi_c/libffi/m4/ltoptions.m4 +368 -0
  48. data/ext/ffi_c/libffi/m4/ltsugar.m4 +123 -0
  49. data/ext/ffi_c/libffi/m4/ltversion.m4 +23 -0
  50. data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +92 -0
  51. data/ext/ffi_c/libffi/man/Makefile.in +115 -62
  52. data/ext/ffi_c/libffi/man/ffi_call.3 +3 -3
  53. data/ext/ffi_c/libffi/missing +15 -8
  54. data/ext/ffi_c/libffi/src/arm/sysv.S +15 -8
  55. data/ext/ffi_c/libffi/src/avr32/ffi.c +421 -0
  56. data/ext/ffi_c/libffi/src/avr32/ffitarget.h +50 -0
  57. data/ext/ffi_c/libffi/src/avr32/sysv.S +208 -0
  58. data/ext/ffi_c/libffi/src/closures.c +47 -10
  59. data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
  60. data/ext/ffi_c/libffi/src/java_raw_api.c +0 -3
  61. data/ext/ffi_c/libffi/src/mips/ffi.c +135 -32
  62. data/ext/ffi_c/libffi/src/mips/ffitarget.h +37 -4
  63. data/ext/ffi_c/libffi/src/mips/n32.S +67 -10
  64. data/ext/ffi_c/libffi/src/mips/o32.S +8 -8
  65. data/ext/ffi_c/libffi/src/pa/ffi.c +7 -0
  66. data/ext/ffi_c/libffi/src/powerpc/aix.S +163 -64
  67. data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +308 -112
  68. data/ext/ffi_c/libffi/src/powerpc/ffi.c +20 -7
  69. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +208 -80
  70. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +11 -3
  71. data/ext/ffi_c/libffi/src/powerpc/sysv.S +12 -23
  72. data/ext/ffi_c/libffi/src/s390/sysv.S +1 -1
  73. data/ext/ffi_c/libffi/src/sh/sysv.S +9 -9
  74. data/ext/ffi_c/libffi/src/sh64/ffi.c +37 -22
  75. data/ext/ffi_c/libffi/src/sh64/sysv.S +23 -14
  76. data/ext/ffi_c/libffi/src/sparc/ffi.c +21 -6
  77. data/ext/ffi_c/libffi/src/sparc/v8.S +55 -14
  78. data/ext/ffi_c/libffi/src/x86/darwin.S +10 -9
  79. data/ext/ffi_c/libffi/src/x86/ffi.c +293 -86
  80. data/ext/ffi_c/libffi/src/x86/ffi64.c +73 -19
  81. data/ext/ffi_c/libffi/src/x86/ffitarget.h +30 -0
  82. data/ext/ffi_c/libffi/src/x86/sysv.S +21 -4
  83. data/ext/ffi_c/libffi/src/x86/unix64.S +8 -4
  84. data/ext/ffi_c/libffi/src/x86/win32.S +633 -147
  85. data/ext/ffi_c/libffi/src/x86/win64.S +460 -0
  86. data/ext/ffi_c/libffi/testsuite/Makefile.am +63 -54
  87. data/ext/ffi_c/libffi/testsuite/Makefile.in +112 -77
  88. data/ext/ffi_c/libffi/testsuite/lib/libffi-dg.exp +12 -1
  89. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +4 -4
  90. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn0.c +7 -15
  91. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn1.c +7 -15
  92. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn2.c +7 -15
  93. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn3.c +7 -15
  94. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn4.c +7 -15
  95. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn5.c +7 -14
  96. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn6.c +7 -15
  97. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_loc_fn0.c +95 -0
  98. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_stdcall.c +6 -14
  99. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_12byte.c +4 -12
  100. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_16byte.c +4 -12
  101. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_18byte.c +4 -12
  102. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_19byte.c +4 -12
  103. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_1_1byte.c +4 -12
  104. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte.c +4 -12
  105. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte1.c +4 -12
  106. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_24byte.c +4 -12
  107. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_2byte.c +4 -12
  108. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3_1byte.c +4 -12
  109. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte1.c +4 -12
  110. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte2.c +4 -12
  111. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4_1byte.c +4 -12
  112. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4byte.c +4 -12
  113. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5_1_byte.c +4 -12
  114. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5byte.c +4 -12
  115. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_64byte.c +4 -12
  116. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6_1_byte.c +4 -12
  117. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6byte.c +4 -12
  118. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7_1_byte.c +4 -12
  119. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7byte.c +4 -12
  120. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_8byte.c +4 -12
  121. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte1.c +4 -12
  122. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte2.c +4 -12
  123. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_double.c +4 -12
  124. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_float.c +4 -12
  125. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble.c +4 -12
  126. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split.c +134 -0
  127. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c +117 -0
  128. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_pointer.c +11 -17
  129. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint16.c +4 -12
  130. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint32.c +4 -12
  131. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +7 -15
  132. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint16.c +4 -12
  133. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint32.c +4 -12
  134. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +7 -15
  135. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_dbls_struct.c +66 -0
  136. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double.c +4 -12
  137. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double_va.c +57 -0
  138. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_float.c +4 -13
  139. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble.c +105 -0
  140. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble_va.c +57 -0
  141. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_schar.c +4 -12
  142. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshort.c +4 -12
  143. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshortchar.c +4 -12
  144. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_uchar.c +4 -12
  145. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushort.c +4 -12
  146. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushortchar.c +4 -12
  147. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer.c +74 -0
  148. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer_stack.c +140 -0
  149. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_schar.c +4 -12
  150. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sint.c +4 -12
  151. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sshort.c +4 -12
  152. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar.c +4 -12
  153. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uint.c +4 -12
  154. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c +8 -16
  155. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort.c +4 -12
  156. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_abi.c +37 -0
  157. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +25 -0
  158. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +31 -0
  159. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +2 -1
  160. data/ext/ffi_c/libffi/testsuite/libffi.call/huge_struct.c +342 -0
  161. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct.c +4 -12
  162. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct1.c +4 -12
  163. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct10.c +4 -12
  164. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct2.c +4 -12
  165. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct3.c +4 -12
  166. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct4.c +4 -12
  167. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct5.c +4 -12
  168. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct6.c +4 -12
  169. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct7.c +4 -12
  170. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct8.c +4 -12
  171. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct9.c +4 -12
  172. data/ext/ffi_c/libffi/testsuite/libffi.call/problem1.c +4 -12
  173. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +1 -1
  174. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +1 -1
  175. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large.c +145 -0
  176. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large2.c +148 -0
  177. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium.c +124 -0
  178. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium2.c +124 -0
  179. data/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c +70 -0
  180. data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +10 -0
  181. data/ext/ffi_c/libffi/testsuite/libffi.special/special.exp +4 -5
  182. data/ext/ffi_c/libffi/testsuite/libffi.special/unwindtest.cc +17 -16
  183. data/ext/ffi_c/libffi/texinfo.tex +155 -427
  184. data/gen/Rakefile +4 -2
  185. data/lib/1.8/ffi_c.so +0 -0
  186. data/lib/1.9/ffi_c.so +0 -0
  187. data/lib/ffi/autopointer.rb +79 -20
  188. data/lib/ffi/callback.rb +4 -10
  189. data/lib/ffi/enum.rb +28 -0
  190. data/lib/ffi/ffi.rb +1 -0
  191. data/lib/ffi/io.rb +28 -0
  192. data/lib/ffi/library.rb +237 -182
  193. data/lib/ffi/memorypointer.rb +28 -62
  194. data/lib/ffi/platform.rb +27 -0
  195. data/lib/ffi/pointer.rb +28 -0
  196. data/lib/ffi/struct.rb +55 -1
  197. data/lib/ffi/types.rb +29 -0
  198. data/lib/ffi/variadic.rb +29 -0
  199. data/spec/ffi/library_spec.rb +31 -5
  200. data/spec/ffi/rbx/attach_function_spec.rb +2 -1
  201. data/spec/ffi/rbx/memory_pointer_spec.rb +2 -1
  202. data/spec/ffi/spec_helper.rb +5 -1
  203. data/spec/ffi/struct_spec.rb +82 -0
  204. data/tasks/ann.rake +80 -0
  205. data/tasks/extension.rake +25 -0
  206. data/tasks/gem.rake +200 -0
  207. data/tasks/git.rake +41 -0
  208. data/tasks/notes.rake +27 -0
  209. data/tasks/post_load.rake +34 -0
  210. data/tasks/rdoc.rake +50 -0
  211. data/tasks/rubyforge.rake +55 -0
  212. data/tasks/setup.rb +300 -0
  213. data/tasks/spec.rake +54 -0
  214. data/tasks/svn.rake +47 -0
  215. data/tasks/test.rake +40 -0
  216. metadata +312 -279
  217. data/ext/ffi_c/libffi/TODO +0 -1
  218. data/ext/ffi_c/libffi/ltcf-c.sh +0 -861
  219. data/ext/ffi_c/libffi/ltcf-cxx.sh +0 -1069
  220. data/ext/ffi_c/libffi/ltcf-gcj.sh +0 -700
  221. data/ext/ffi_c/libffi/ltconfig +0 -2862
  222. data/ext/ffi_c/libffi/mkinstalldirs +0 -158
@@ -0,0 +1,50 @@
1
+ /* -----------------------------------------------------------------*-C-*-
2
+ ffitarget.h - Copyright (c) 2009 Bradley Smith <brad@brad-smith.co.uk>
3
+ Target configuration macros for AVR32.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ ``Software''), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included
14
+ in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23
+ DEALINGS IN THE SOFTWARE.
24
+
25
+ ----------------------------------------------------------------------- */
26
+
27
+ #ifndef LIBFFI_TARGET_H
28
+ #define LIBFFI_TARGET_H
29
+
30
+ #ifndef LIBFFI_ASM
31
+ typedef unsigned long ffi_arg;
32
+ typedef signed long ffi_sarg;
33
+
34
+ typedef enum ffi_abi {
35
+ FFI_FIRST_ABI = 0,
36
+ FFI_SYSV,
37
+ FFI_DEFAULT_ABI = FFI_SYSV,
38
+ FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
39
+ } ffi_abi;
40
+ #endif
41
+
42
+ #define FFI_EXTRA_CIF_FIELDS unsigned int rstruct_flag
43
+
44
+ /* Definitions for closures */
45
+
46
+ #define FFI_CLOSURES 1
47
+ #define FFI_TRAMPOLINE_SIZE 36
48
+ #define FFI_NATIVE_RAW_API 0
49
+
50
+ #endif
@@ -0,0 +1,208 @@
1
+ /* -----------------------------------------------------------------------
2
+ sysv.S - 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 NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ --------------------------------------------------------------------- */
25
+
26
+ #define LIBFFI_ASM
27
+ #include <fficonfig.h>
28
+ #include <ffi.h>
29
+
30
+ /* r12: ffi_prep_args
31
+ * r11: &ecif
32
+ * r10: size
33
+ * r9: cif->flags
34
+ * r8: ecif.rvalue
35
+ * sp+0: cif->rstruct_flag
36
+ * sp+4: fn */
37
+
38
+ .text
39
+ .align 1
40
+ .globl ffi_call_SYSV
41
+ .type ffi_call_SYSV, @function
42
+ ffi_call_SYSV:
43
+ stm --sp, r0,r1,lr
44
+ stm --sp, r8-r12
45
+ mov r0, sp
46
+
47
+ /* Make room for all of the new args. */
48
+ sub sp, r10
49
+ /* Pad to make way for potential skipped registers */
50
+ sub sp, 20
51
+
52
+ /* Call ffi_prep_args(stack, &ecif). */
53
+ /* r11 already set */
54
+ mov r1, r12
55
+ mov r12, sp
56
+ icall r1
57
+
58
+ /* Save new argument size */
59
+ mov r1, r12
60
+
61
+ /* Move first 5 parameters in registers. */
62
+ ldm sp++, r8-r12
63
+
64
+ /* call (fn) (...). */
65
+ ld.w r1, r0[36]
66
+ icall r1
67
+
68
+ /* Remove the space we pushed for the args. */
69
+ mov sp, r0
70
+
71
+ /* Load r1 with the rstruct flag. */
72
+ ld.w r1, sp[32]
73
+
74
+ /* Load r9 with the return type code. */
75
+ ld.w r9, sp[12]
76
+
77
+ /* Load r8 with the return value pointer. */
78
+ ld.w r8, sp[16]
79
+
80
+ /* If the return value pointer is NULL, assume no return value. */
81
+ cp.w r8, 0
82
+ breq .Lend
83
+
84
+ /* Check if return type is actually a struct */
85
+ cp.w r1, 0
86
+ breq 1f
87
+
88
+ /* Return 8bit */
89
+ cp.w r9, FFI_TYPE_UINT8
90
+ breq .Lstore8
91
+
92
+ /* Return 16bit */
93
+ cp.w r9, FFI_TYPE_UINT16
94
+ breq .Lstore16
95
+
96
+ 1:
97
+ /* Return 32bit */
98
+ cp.w r9, FFI_TYPE_UINT32
99
+ breq .Lstore32
100
+ cp.w r9, FFI_TYPE_UINT16
101
+ breq .Lstore32
102
+ cp.w r9, FFI_TYPE_UINT8
103
+ breq .Lstore32
104
+
105
+ /* Return 64bit */
106
+ cp.w r9, FFI_TYPE_UINT64
107
+ breq .Lstore64
108
+
109
+ /* Didn't match anything */
110
+ bral .Lend
111
+
112
+ .Lstore64:
113
+ st.w r8[0], r11
114
+ st.w r8[4], r10
115
+ bral .Lend
116
+
117
+ .Lstore32:
118
+ st.w r8[0], r12
119
+ bral .Lend
120
+
121
+ .Lstore16:
122
+ st.h r8[0], r12
123
+ bral .Lend
124
+
125
+ .Lstore8:
126
+ st.b r8[0], r12
127
+ bral .Lend
128
+
129
+ .Lend:
130
+ sub sp, -20
131
+ ldm sp++, r0,r1,pc
132
+
133
+ .size ffi_call_SYSV, . - ffi_call_SYSV
134
+
135
+
136
+ /* r12: __ctx
137
+ * r11: __rstruct_flag
138
+ * r10: __inner */
139
+
140
+ .align 1
141
+ .globl ffi_closure_SYSV
142
+ .type ffi_closure_SYSV, @function
143
+ ffi_closure_SYSV:
144
+ stm --sp, r0,lr
145
+ mov r0, r11
146
+ mov r8, r10
147
+ sub r10, sp, -8
148
+ sub sp, 12
149
+ st.w sp[8], sp
150
+ sub r11, sp, -8
151
+ icall r8
152
+
153
+ /* Check if return type is actually a struct */
154
+ cp.w r0, 0
155
+ breq 1f
156
+
157
+ /* Return 8bit */
158
+ cp.w r12, FFI_TYPE_UINT8
159
+ breq .Lget8
160
+
161
+ /* Return 16bit */
162
+ cp.w r12, FFI_TYPE_UINT16
163
+ breq .Lget16
164
+
165
+ 1:
166
+ /* Return 32bit */
167
+ cp.w r12, FFI_TYPE_UINT32
168
+ breq .Lget32
169
+ cp.w r12, FFI_TYPE_UINT16
170
+ breq .Lget32
171
+ cp.w r12, FFI_TYPE_UINT8
172
+ breq .Lget32
173
+
174
+ /* Return 64bit */
175
+ cp.w r12, FFI_TYPE_UINT64
176
+ breq .Lget64
177
+
178
+ /* Didn't match anything */
179
+ bral .Lclend
180
+
181
+ .Lget64:
182
+ ld.w r11, sp[0]
183
+ ld.w r10, sp[4]
184
+ bral .Lclend
185
+
186
+ .Lget32:
187
+ ld.w r12, sp[0]
188
+ bral .Lclend
189
+
190
+ .Lget16:
191
+ ld.uh r12, sp[0]
192
+ bral .Lclend
193
+
194
+ .Lget8:
195
+ ld.ub r12, sp[0]
196
+ bral .Lclend
197
+
198
+ .Lclend:
199
+ sub sp, -12
200
+ ldm sp++, r0,lr
201
+ sub sp, -20
202
+ mov pc, lr
203
+
204
+ .size ffi_closure_SYSV, . - ffi_closure_SYSV
205
+
206
+ #if defined __ELF__ && defined __linux__
207
+ .section .note.GNU-stack,"",@progbits
208
+ #endif
@@ -1,6 +1,6 @@
1
1
  /* -----------------------------------------------------------------------
2
- closures.c - Copyright (c) 2007 Red Hat, Inc.
3
- Copyright (C) 2007 Free Software Foundation, Inc
2
+ closures.c - Copyright (c) 2007, 2009 Red Hat, Inc.
3
+ Copyright (C) 2007, 2009 Free Software Foundation, Inc
4
4
 
5
5
  Code to allocate and deallocate memory for closures.
6
6
 
@@ -44,7 +44,7 @@
44
44
  # define FFI_MMAP_EXEC_WRIT 1
45
45
  # define HAVE_MNTENT 1
46
46
  # endif
47
- # ifdef X86_WIN32
47
+ # if defined(X86_WIN32) || defined(X86_WIN64)
48
48
  /* Windows systems may have Data Execution Protection (DEP) enabled,
49
49
  which requires the use of VirtualMalloc/VirtualFree to alloc/free
50
50
  executable memory. */
@@ -67,7 +67,11 @@
67
67
 
68
68
  #define USE_LOCKS 1
69
69
  #define USE_DL_PREFIX 1
70
+ #ifdef __GNUC__
71
+ #ifndef USE_BUILTIN_FFS
70
72
  #define USE_BUILTIN_FFS 1
73
+ #endif
74
+ #endif
71
75
 
72
76
  /* We need to use mmap, not sbrk. */
73
77
  #define HAVE_MORECORE 0
@@ -97,10 +101,12 @@
97
101
  #include <sys/stat.h>
98
102
  #include <fcntl.h>
99
103
  #include <errno.h>
104
+ #ifndef _MSC_VER
100
105
  #include <unistd.h>
106
+ #endif
101
107
  #include <string.h>
102
108
  #include <stdio.h>
103
- #ifndef X86_WIN32
109
+ #if !defined(X86_WIN32) && !defined(X86_WIN64)
104
110
  #ifdef HAVE_MNTENT
105
111
  #include <mntent.h>
106
112
  #endif /* HAVE_MNTENT */
@@ -159,8 +165,16 @@ selinux_enabled_check (void)
159
165
 
160
166
  #define is_selinux_enabled() 0
161
167
 
162
- #endif
163
- #endif /* X86_WIN32 */
168
+ #endif /* !FFI_MMAP_EXEC_SELINUX */
169
+
170
+ #elif defined (__CYGWIN__)
171
+
172
+ #include <sys/mman.h>
173
+
174
+ /* Cygwin is Linux-like, but not quite that Linux-like. */
175
+ #define is_selinux_enabled() 0
176
+
177
+ #endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */
164
178
 
165
179
  /* Declare all functions defined in dlmalloc.c as static. */
166
180
  static void *dlmalloc(size_t);
@@ -179,11 +193,11 @@ static int dlmalloc_trim(size_t) MAYBE_UNUSED;
179
193
  static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED;
180
194
  static void dlmalloc_stats(void) MAYBE_UNUSED;
181
195
 
182
- #ifndef X86_WIN32
196
+ #if !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__)
183
197
  /* Use these for mmap and munmap within dlmalloc.c. */
184
198
  static void *dlmmap(void *, size_t, int, int, int, off_t);
185
199
  static int dlmunmap(void *, size_t);
186
- #endif /* X86_WIN32 */
200
+ #endif /* !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__) */
187
201
 
188
202
  #define mmap dlmmap
189
203
  #define munmap dlmunmap
@@ -193,7 +207,9 @@ static int dlmunmap(void *, size_t);
193
207
  #undef mmap
194
208
  #undef munmap
195
209
 
196
- #ifndef X86_WIN32
210
+ #if !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__)
211
+
212
+ #if FFI_MMAP_EXEC_SELINUX
197
213
 
198
214
  /* A mutex used to synchronize access to *exec* variables in this file. */
199
215
  static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -464,6 +480,27 @@ dlmmap (void *start, size_t length, int prot,
464
480
  return dlmmap_locked (start, length, prot, flags, offset);
465
481
  }
466
482
 
483
+ #else
484
+
485
+ static void *
486
+ dlmmap (void *start, size_t length, int prot,
487
+ int flags, int fd, off_t offset)
488
+ {
489
+
490
+ assert (start == NULL && length % malloc_getpagesize == 0
491
+ && prot == (PROT_READ | PROT_WRITE)
492
+ && flags == (MAP_PRIVATE | MAP_ANONYMOUS)
493
+ && fd == -1 && offset == 0);
494
+
495
+ #if FFI_CLOSURE_TEST
496
+ printf ("mapping in %zi\n", length);
497
+ #endif
498
+
499
+ return mmap (start, length, prot | PROT_EXEC, flags, fd, offset);
500
+ }
501
+
502
+ #endif
503
+
467
504
  /* Release memory at the given address, as well as the corresponding
468
505
  executable page if it's separate. */
469
506
  static int
@@ -508,7 +545,7 @@ segment_holding_code (mstate m, char* addr)
508
545
  }
509
546
  #endif
510
547
 
511
- #endif /* X86_WIN32 */
548
+ #endif /* !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__) */
512
549
 
513
550
  /* Allocate a chunk of memory with the given size. Returns a pointer
514
551
  to the writable address, and sets *CODE to the executable
@@ -1,6 +1,6 @@
1
1
  /* -----------------------------------------------------------------------
2
2
  ffi.c - Copyright (C) 2004 Anthony Green
3
- Copyright (C) 2007 Free Software Foundation, Inc.
3
+ Copyright (C) 2007 Free Software Foundation, Inc.
4
4
  Copyright (C) 2008 Red Hat, Inc.
5
5
 
6
6
  FR-V Foreign Function Interface
@@ -276,9 +276,6 @@ ffi_java_raw_to_rvalue (ffi_cif *cif, void *rvalue)
276
276
  case FFI_TYPE_SINT16:
277
277
  case FFI_TYPE_SINT32:
278
278
  case FFI_TYPE_INT:
279
- #if FFI_SIZEOF_JAVA_RAW == 4
280
- case FFI_TYPE_POINTER:
281
- #endif
282
279
  *(SINT64 *)rvalue >>= 32;
283
280
  break;
284
281
 
@@ -99,7 +99,7 @@ static void ffi_prep_args(char *stack,
99
99
 
100
100
  p_argv = ecif->avalue;
101
101
 
102
- for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; i; i--, p_arg++)
102
+ for (i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs; i++, p_arg++)
103
103
  {
104
104
  size_t z;
105
105
  unsigned int a;
@@ -123,9 +123,25 @@ static void ffi_prep_args(char *stack,
123
123
 
124
124
  /* The size of a pointer depends on the ABI */
125
125
  if (type == FFI_TYPE_POINTER)
126
- type =
127
- (ecif->cif->abi == FFI_N64) ? FFI_TYPE_SINT64 : FFI_TYPE_SINT32;
126
+ type = (ecif->cif->abi == FFI_N64
127
+ || ecif->cif->abi == FFI_N64_SOFT_FLOAT)
128
+ ? FFI_TYPE_SINT64 : FFI_TYPE_SINT32;
128
129
 
130
+ if (i < 8 && (ecif->cif->abi == FFI_N32_SOFT_FLOAT
131
+ || ecif->cif->abi == FFI_N64_SOFT_FLOAT))
132
+ {
133
+ switch (type)
134
+ {
135
+ case FFI_TYPE_FLOAT:
136
+ type = FFI_TYPE_UINT32;
137
+ break;
138
+ case FFI_TYPE_DOUBLE:
139
+ type = FFI_TYPE_UINT64;
140
+ break;
141
+ default:
142
+ break;
143
+ }
144
+ }
129
145
  switch (type)
130
146
  {
131
147
  case FFI_TYPE_SINT8:
@@ -205,13 +221,17 @@ static void ffi_prep_args(char *stack,
205
221
  definitions and generates the appropriate flags. */
206
222
 
207
223
  static unsigned
208
- calc_n32_struct_flags(ffi_type *arg, unsigned *loc, unsigned *arg_reg)
224
+ calc_n32_struct_flags(int soft_float, ffi_type *arg,
225
+ unsigned *loc, unsigned *arg_reg)
209
226
  {
210
227
  unsigned flags = 0;
211
228
  unsigned index = 0;
212
229
 
213
230
  ffi_type *e;
214
231
 
232
+ if (soft_float)
233
+ return 0;
234
+
215
235
  while ((e = arg->elements[index]))
216
236
  {
217
237
  /* Align this object. */
@@ -236,7 +256,7 @@ calc_n32_struct_flags(ffi_type *arg, unsigned *loc, unsigned *arg_reg)
236
256
  }
237
257
 
238
258
  static unsigned
239
- calc_n32_return_struct_flags(ffi_type *arg)
259
+ calc_n32_return_struct_flags(int soft_float, ffi_type *arg)
240
260
  {
241
261
  unsigned flags = 0;
242
262
  unsigned small = FFI_TYPE_SMALLSTRUCT;
@@ -256,6 +276,7 @@ calc_n32_return_struct_flags(ffi_type *arg)
256
276
  small = FFI_TYPE_SMALLSTRUCT2;
257
277
 
258
278
  e = arg->elements[0];
279
+
259
280
  if (e->type == FFI_TYPE_DOUBLE)
260
281
  flags = FFI_TYPE_DOUBLE;
261
282
  else if (e->type == FFI_TYPE_FLOAT)
@@ -276,6 +297,8 @@ calc_n32_return_struct_flags(ffi_type *arg)
276
297
  floats! This must be passed the old way. */
277
298
  return small;
278
299
  }
300
+ if (soft_float)
301
+ flags += FFI_TYPE_STRUCT_SOFT;
279
302
  }
280
303
  else
281
304
  if (!flags)
@@ -382,16 +405,19 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
382
405
  #ifdef FFI_MIPS_N32
383
406
  /* Set the flags necessary for N32 processing */
384
407
  {
408
+ int type;
385
409
  unsigned arg_reg = 0;
386
410
  unsigned loc = 0;
387
411
  unsigned count = (cif->nargs < 8) ? cif->nargs : 8;
388
412
  unsigned index = 0;
389
413
 
390
414
  unsigned struct_flags = 0;
415
+ int soft_float = (cif->abi == FFI_N32_SOFT_FLOAT
416
+ || cif->abi == FFI_N64_SOFT_FLOAT);
391
417
 
392
418
  if (cif->rtype->type == FFI_TYPE_STRUCT)
393
419
  {
394
- struct_flags = calc_n32_return_struct_flags(cif->rtype);
420
+ struct_flags = calc_n32_return_struct_flags(soft_float, cif->rtype);
395
421
 
396
422
  if (struct_flags == 0)
397
423
  {
@@ -411,7 +437,22 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
411
437
 
412
438
  while (count-- > 0 && arg_reg < 8)
413
439
  {
414
- switch ((cif->arg_types)[index]->type)
440
+ type = (cif->arg_types)[index]->type;
441
+ if (soft_float)
442
+ {
443
+ switch (type)
444
+ {
445
+ case FFI_TYPE_FLOAT:
446
+ type = FFI_TYPE_UINT32;
447
+ break;
448
+ case FFI_TYPE_DOUBLE:
449
+ type = FFI_TYPE_UINT64;
450
+ break;
451
+ default:
452
+ break;
453
+ }
454
+ }
455
+ switch (type)
415
456
  {
416
457
  case FFI_TYPE_FLOAT:
417
458
  case FFI_TYPE_DOUBLE:
@@ -423,17 +464,25 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
423
464
  /* Align it. */
424
465
  arg_reg = ALIGN(arg_reg, 2);
425
466
  /* Treat it as two adjacent doubles. */
426
- cif->flags +=
427
- (FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
428
- arg_reg++;
429
- cif->flags +=
430
- (FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
431
- arg_reg++;
467
+ if (soft_float)
468
+ {
469
+ arg_reg += 2;
470
+ }
471
+ else
472
+ {
473
+ cif->flags +=
474
+ (FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
475
+ arg_reg++;
476
+ cif->flags +=
477
+ (FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
478
+ arg_reg++;
479
+ }
432
480
  break;
433
481
 
434
482
  case FFI_TYPE_STRUCT:
435
483
  loc = arg_reg * FFI_SIZEOF_ARG;
436
- cif->flags += calc_n32_struct_flags((cif->arg_types)[index],
484
+ cif->flags += calc_n32_struct_flags(soft_float,
485
+ (cif->arg_types)[index],
437
486
  &loc, &arg_reg);
438
487
  break;
439
488
 
@@ -469,17 +518,43 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
469
518
  case FFI_TYPE_VOID:
470
519
  /* Do nothing, 'cause FFI_TYPE_VOID is 0 */
471
520
  break;
472
-
521
+
522
+ case FFI_TYPE_POINTER:
523
+ if (cif->abi == FFI_N32_SOFT_FLOAT || cif->abi == FFI_N32)
524
+ cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8);
525
+ else
526
+ cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
527
+ break;
528
+
473
529
  case FFI_TYPE_FLOAT:
530
+ if (soft_float)
531
+ {
532
+ cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8);
533
+ break;
534
+ }
535
+ /* else fall through */
474
536
  case FFI_TYPE_DOUBLE:
475
- cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8);
537
+ if (soft_float)
538
+ cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
539
+ else
540
+ cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8);
476
541
  break;
542
+
477
543
  case FFI_TYPE_LONGDOUBLE:
478
544
  /* Long double is returned as if it were a struct containing
479
545
  two doubles. */
480
- cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8);
481
- cif->flags += (FFI_TYPE_DOUBLE + (FFI_TYPE_DOUBLE << FFI_FLAG_BITS))
482
- << (4 + (FFI_FLAG_BITS * 8));
546
+ if (soft_float)
547
+ {
548
+ cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8);
549
+ cif->flags += FFI_TYPE_SMALLSTRUCT2 << (4 + (FFI_FLAG_BITS * 8));
550
+ }
551
+ else
552
+ {
553
+ cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8);
554
+ cif->flags += (FFI_TYPE_DOUBLE
555
+ + (FFI_TYPE_DOUBLE << FFI_FLAG_BITS))
556
+ << (4 + (FFI_FLAG_BITS * 8));
557
+ }
483
558
  break;
484
559
  default:
485
560
  cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
@@ -499,7 +574,7 @@ extern int ffi_call_O32(void (*)(char *, extended_cif *, int, int),
499
574
  /* Low level routine for calling N32 functions */
500
575
  extern int ffi_call_N32(void (*)(char *, extended_cif *, int, int),
501
576
  extended_cif *, unsigned,
502
- unsigned, unsigned *, void (*)(void));
577
+ unsigned, void *, void (*)(void));
503
578
 
504
579
  void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
505
580
  {
@@ -529,10 +604,13 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
529
604
 
530
605
  #ifdef FFI_MIPS_N32
531
606
  case FFI_N32:
607
+ case FFI_N32_SOFT_FLOAT:
532
608
  case FFI_N64:
609
+ case FFI_N64_SOFT_FLOAT:
533
610
  {
534
611
  int copy_rvalue = 0;
535
- void *rvalue_copy = ecif.rvalue;
612
+ int copy_offset = 0;
613
+ char *rvalue_copy = ecif.rvalue;
536
614
  if (cif->rtype->type == FFI_TYPE_STRUCT && cif->rtype->size < 16)
537
615
  {
538
616
  /* For structures smaller than 16 bytes we clobber memory
@@ -541,10 +619,20 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
541
619
  rvalue_copy = alloca(16);
542
620
  copy_rvalue = 1;
543
621
  }
622
+ else if (cif->rtype->type == FFI_TYPE_FLOAT
623
+ && (cif->abi == FFI_N64_SOFT_FLOAT
624
+ || cif->abi == FFI_N32_SOFT_FLOAT))
625
+ {
626
+ rvalue_copy = alloca (8);
627
+ copy_rvalue = 1;
628
+ #if defined(__MIPSEB__) || defined(_MIPSEB)
629
+ copy_offset = 4;
630
+ #endif
631
+ }
544
632
  ffi_call_N32(ffi_prep_args, &ecif, cif->bytes,
545
633
  cif->flags, rvalue_copy, fn);
546
634
  if (copy_rvalue)
547
- memcpy(ecif.rvalue, rvalue_copy, cif->rtype->size);
635
+ memcpy(ecif.rvalue, rvalue_copy + copy_offset, cif->rtype->size);
548
636
  }
549
637
  break;
550
638
  #endif
@@ -684,9 +772,10 @@ ffi_closure_mips_inner_O32 (ffi_closure *closure,
684
772
  {
685
773
  if (i < 2 && !seen_int &&
686
774
  (arg_types[i]->type == FFI_TYPE_FLOAT ||
687
- arg_types[i]->type == FFI_TYPE_DOUBLE))
775
+ arg_types[i]->type == FFI_TYPE_DOUBLE ||
776
+ arg_types[i]->type == FFI_TYPE_LONGDOUBLE))
688
777
  {
689
- #ifdef __MIPSEB__
778
+ #if defined(__MIPSEB__) || defined(_MIPSEB)
690
779
  if (arg_types[i]->type == FFI_TYPE_FLOAT)
691
780
  avaluep[i] = ((char *) &fpr[i]) + sizeof (float);
692
781
  else
@@ -755,7 +844,7 @@ ffi_closure_mips_inner_O32 (ffi_closure *closure,
755
844
  static void
756
845
  copy_struct_N32(char *target, unsigned offset, ffi_abi abi, ffi_type *type,
757
846
  int argn, unsigned arg_offset, ffi_arg *ar,
758
- ffi_arg *fpr)
847
+ ffi_arg *fpr, int soft_float)
759
848
  {
760
849
  ffi_type **elt_typep = type->elements;
761
850
  while(*elt_typep)
@@ -777,7 +866,7 @@ copy_struct_N32(char *target, unsigned offset, ffi_abi abi, ffi_type *type,
777
866
 
778
867
  tp = target + offset;
779
868
 
780
- if (elt_type->type == FFI_TYPE_DOUBLE)
869
+ if (elt_type->type == FFI_TYPE_DOUBLE && !soft_float)
781
870
  *(double *)tp = *(double *)fpp;
782
871
  else
783
872
  memcpy(tp, argp + arg_offset, elt_type->size);
@@ -815,8 +904,12 @@ ffi_closure_mips_inner_N32 (ffi_closure *closure,
815
904
  ffi_arg *avalue;
816
905
  ffi_type **arg_types;
817
906
  int i, avn, argn;
907
+ int soft_float;
908
+ ffi_arg *argp;
818
909
 
819
910
  cif = closure->cif;
911
+ soft_float = cif->abi == FFI_N64_SOFT_FLOAT
912
+ || cif->abi == FFI_N32_SOFT_FLOAT;
820
913
  avalue = alloca (cif->nargs * sizeof (ffi_arg));
821
914
  avaluep = alloca (cif->nargs * sizeof (ffi_arg));
822
915
 
@@ -839,10 +932,16 @@ ffi_closure_mips_inner_N32 (ffi_closure *closure,
839
932
  while (i < avn)
840
933
  {
841
934
  if (arg_types[i]->type == FFI_TYPE_FLOAT
842
- || arg_types[i]->type == FFI_TYPE_DOUBLE)
935
+ || arg_types[i]->type == FFI_TYPE_DOUBLE
936
+ || arg_types[i]->type == FFI_TYPE_LONGDOUBLE)
843
937
  {
844
- ffi_arg *argp = argn >= 8 ? ar + argn : fpr + argn;
845
- #ifdef __MIPSEB__
938
+ argp = (argn >= 8 || soft_float) ? ar + argn : fpr + argn;
939
+ if ((arg_types[i]->type == FFI_TYPE_LONGDOUBLE) && ((unsigned)argp & (arg_types[i]->alignment-1)))
940
+ {
941
+ argp=(ffi_arg*)ALIGN(argp,arg_types[i]->alignment);
942
+ argn++;
943
+ }
944
+ #if defined(__MIPSEB__) || defined(_MIPSEB)
846
945
  if (arg_types[i]->type == FFI_TYPE_FLOAT && argn < 8)
847
946
  avaluep[i] = ((char *) argp) + sizeof (float);
848
947
  else
@@ -856,11 +955,15 @@ ffi_closure_mips_inner_N32 (ffi_closure *closure,
856
955
  if (arg_types[i]->alignment > sizeof(ffi_arg))
857
956
  argn = ALIGN(argn, arg_types[i]->alignment / sizeof(ffi_arg));
858
957
 
859
- ffi_arg *argp = ar + argn;
958
+ argp = ar + argn;
860
959
 
861
960
  /* The size of a pointer depends on the ABI */
862
961
  if (type == FFI_TYPE_POINTER)
863
- type = (cif->abi == FFI_N64) ? FFI_TYPE_SINT64 : FFI_TYPE_SINT32;
962
+ type = (cif->abi == FFI_N64 || cif->abi == FFI_N64_SOFT_FLOAT)
963
+ ? FFI_TYPE_SINT64 : FFI_TYPE_SINT32;
964
+
965
+ if (soft_float && type == FFI_TYPE_FLOAT)
966
+ type = FFI_TYPE_UINT32;
864
967
 
865
968
  switch (type)
866
969
  {
@@ -901,7 +1004,7 @@ ffi_closure_mips_inner_N32 (ffi_closure *closure,
901
1004
  it was passed in registers. */
902
1005
  avaluep[i] = alloca(arg_types[i]->size);
903
1006
  copy_struct_N32(avaluep[i], 0, cif->abi, arg_types[i],
904
- argn, 0, ar, fpr);
1007
+ argn, 0, ar, fpr, soft_float);
905
1008
 
906
1009
  break;
907
1010
  }