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
@@ -1,5 +1,5 @@
1
1
  /* -----------------------------------------------------------------------
2
- aix_closure.S - Copyright (c) 2002 2003 Free Software Foundation, Inc.
2
+ aix_closure.S - Copyright (c) 2002, 2003, 2009 Free Software Foundation, Inc.
3
3
  based on darwin_closure.S
4
4
 
5
5
  PowerPC Assembly glue.
@@ -94,65 +94,238 @@ LC..60:
94
94
  .globl ffi_closure_ASM
95
95
  .globl .ffi_closure_ASM
96
96
  .csect ffi_closure_ASM[DS]
97
-
98
97
  ffi_closure_ASM:
99
- .long .ffi_closure_ASM, TOC[tc0], 0
98
+ #ifdef __64BIT__
99
+ .llong .ffi_closure_ASM, TOC[tc0], 0
100
100
  .csect .text[PR]
101
101
  .ffi_closure_ASM:
102
+ /* we want to build up an area for the parameters passed */
103
+ /* in registers (both floating point and integer) */
102
104
 
103
- mflr r0 /* extract return address */
104
- stw r0, 8(r1) /* save the return address */
105
-
106
- /* 24 Bytes (Linkage Area) */
107
- /* 32 Bytes (params) */
105
+ /* we store gpr 3 to gpr 10 (aligned to 4)
106
+ in the parents outgoing area */
107
+ std r3, 48+(0*8)(r1)
108
+ std r4, 48+(1*8)(r1)
109
+ std r5, 48+(2*8)(r1)
110
+ std r6, 48+(3*8)(r1)
111
+ mflr r0
112
+
113
+ std r7, 48+(4*8)(r1)
114
+ std r8, 48+(5*8)(r1)
115
+ std r9, 48+(6*8)(r1)
116
+ std r10, 48+(7*8)(r1)
117
+ std r0, 16(r1) /* save the return address */
118
+
119
+
120
+ /* 48 Bytes (Linkage Area) */
121
+ /* 64 Bytes (params) */
122
+ /* 16 Bytes (result) */
108
123
  /* 104 Bytes (13*8 from FPR) */
109
- /* 8 Bytes (result) */
110
- /* 168 Bytes */
124
+ /* 8 Bytes (alignment) */
125
+ /* 240 Bytes */
126
+
127
+ stdu r1, -240(r1) /* skip over caller save area
128
+ keep stack aligned to 16 */
129
+
130
+ /* next save fpr 1 to fpr 13 (aligned to 8) */
131
+ stfd f1, 128+(0*8)(r1)
132
+ stfd f2, 128+(1*8)(r1)
133
+ stfd f3, 128+(2*8)(r1)
134
+ stfd f4, 128+(3*8)(r1)
135
+ stfd f5, 128+(4*8)(r1)
136
+ stfd f6, 128+(5*8)(r1)
137
+ stfd f7, 128+(6*8)(r1)
138
+ stfd f8, 128+(7*8)(r1)
139
+ stfd f9, 128+(8*8)(r1)
140
+ stfd f10, 128+(9*8)(r1)
141
+ stfd f11, 128+(10*8)(r1)
142
+ stfd f12, 128+(11*8)(r1)
143
+ stfd f13, 128+(12*8)(r1)
144
+
145
+ /* set up registers for the routine that actually does the work */
146
+ /* get the context pointer from the trampoline */
147
+ mr r3, r11
148
+
149
+ /* now load up the pointer to the result storage */
150
+ addi r4, r1, 112
151
+
152
+ /* now load up the pointer to the saved gpr registers */
153
+ addi r5, r1, 288
154
+
155
+ /* now load up the pointer to the saved fpr registers */
156
+ addi r6, r1, 128
157
+
158
+ /* make the call */
159
+ bl .ffi_closure_helper_DARWIN
160
+ nop
161
+
162
+ /* now r3 contains the return type */
163
+ /* so use it to look up in a table */
164
+ /* so we know how to deal with each type */
165
+
166
+ /* look up the proper starting point in table */
167
+ /* by using return type as offset */
168
+ ld r4, LC..60(2) /* get address of jump table */
169
+ sldi r3, r3, 4 /* now multiply return type by 16 */
170
+ ld r0, 240+16(r1) /* load return address */
171
+ add r3, r3, r4 /* add contents of table to table address */
172
+ mtctr r3
173
+ bctr /* jump to it */
174
+
175
+ /* Each fragment must be exactly 16 bytes long (4 instructions).
176
+ Align to 16 byte boundary for cache and dispatch efficiency. */
177
+ .align 4
178
+
179
+ L..60:
180
+ /* case FFI_TYPE_VOID */
181
+ mtlr r0
182
+ addi r1, r1, 240
183
+ blr
184
+ nop
185
+
186
+ /* case FFI_TYPE_INT */
187
+ lwa r3, 112+4(r1)
188
+ mtlr r0
189
+ addi r1, r1, 240
190
+ blr
191
+
192
+ /* case FFI_TYPE_FLOAT */
193
+ lfs f1, 112+0(r1)
194
+ mtlr r0
195
+ addi r1, r1, 240
196
+ blr
111
197
 
112
- stwu r1,-176(r1) /* skip over caller save area
113
- keep stack aligned to 16 */
198
+ /* case FFI_TYPE_DOUBLE */
199
+ lfd f1, 112+0(r1)
200
+ mtlr r0
201
+ addi r1, r1, 240
202
+ blr
203
+
204
+ /* case FFI_TYPE_LONGDOUBLE */
205
+ lfd f1, 112+0(r1)
206
+ mtlr r0
207
+ lfd f2, 112+8(r1)
208
+ b L..finish
209
+
210
+ /* case FFI_TYPE_UINT8 */
211
+ lbz r3, 112+7(r1)
212
+ mtlr r0
213
+ addi r1, r1, 240
214
+ blr
215
+
216
+ /* case FFI_TYPE_SINT8 */
217
+ lbz r3, 112+7(r1)
218
+ mtlr r0
219
+ extsb r3, r3
220
+ b L..finish
221
+
222
+ /* case FFI_TYPE_UINT16 */
223
+ lhz r3, 112+6(r1)
224
+ mtlr r0
225
+ L..finish:
226
+ addi r1, r1, 240
227
+ blr
114
228
 
229
+ /* case FFI_TYPE_SINT16 */
230
+ lha r3, 112+6(r1)
231
+ mtlr r0
232
+ addi r1, r1, 240
233
+ blr
234
+
235
+ /* case FFI_TYPE_UINT32 */
236
+ lwz r3, 112+4(r1)
237
+ mtlr r0
238
+ addi r1, r1, 240
239
+ blr
240
+
241
+ /* case FFI_TYPE_SINT32 */
242
+ lwa r3, 112+4(r1)
243
+ mtlr r0
244
+ addi r1, r1, 240
245
+ blr
246
+
247
+ /* case FFI_TYPE_UINT64 */
248
+ ld r3, 112+0(r1)
249
+ mtlr r0
250
+ addi r1, r1, 240
251
+ blr
252
+
253
+ /* case FFI_TYPE_SINT64 */
254
+ ld r3, 112+0(r1)
255
+ mtlr r0
256
+ addi r1, r1, 240
257
+ blr
258
+
259
+ /* case FFI_TYPE_STRUCT */
260
+ mtlr r0
261
+ addi r1, r1, 240
262
+ blr
263
+ nop
264
+
265
+ /* case FFI_TYPE_POINTER */
266
+ ld r3, 112+0(r1)
267
+ mtlr r0
268
+ addi r1, r1, 240
269
+ blr
270
+
271
+ #else /* ! __64BIT__ */
272
+
273
+ .long .ffi_closure_ASM, TOC[tc0], 0
274
+ .csect .text[PR]
275
+ .ffi_closure_ASM:
115
276
  /* we want to build up an area for the parameters passed */
116
277
  /* in registers (both floating point and integer) */
117
278
 
118
279
  /* we store gpr 3 to gpr 10 (aligned to 4)
119
280
  in the parents outgoing area */
120
- stw r3, 200(r1)
121
- stw r4, 204(r1)
122
- stw r5, 208(r1)
123
- stw r6, 212(r1)
124
- stw r7, 216(r1)
125
- stw r8, 220(r1)
126
- stw r9, 224(r1)
127
- stw r10, 228(r1)
281
+ stw r3, 24+(0*4)(r1)
282
+ stw r4, 24+(1*4)(r1)
283
+ stw r5, 24+(2*4)(r1)
284
+ stw r6, 24+(3*4)(r1)
285
+ mflr r0
286
+
287
+ stw r7, 24+(4*4)(r1)
288
+ stw r8, 24+(5*4)(r1)
289
+ stw r9, 24+(6*4)(r1)
290
+ stw r10, 24+(7*4)(r1)
291
+ stw r0, 8(r1)
292
+
293
+ /* 24 Bytes (Linkage Area) */
294
+ /* 32 Bytes (params) */
295
+ /* 16 Bytes (result) */
296
+ /* 104 Bytes (13*8 from FPR) */
297
+ /* 176 Bytes */
298
+
299
+ stwu r1, -176(r1) /* skip over caller save area
300
+ keep stack aligned to 16 */
128
301
 
129
302
  /* next save fpr 1 to fpr 13 (aligned to 8) */
130
- stfd f1, 56(r1)
131
- stfd f2, 64(r1)
132
- stfd f3, 72(r1)
133
- stfd f4, 80(r1)
134
- stfd f5, 88(r1)
135
- stfd f6, 96(r1)
136
- stfd f7, 104(r1)
137
- stfd f8, 112(r1)
138
- stfd f9, 120(r1)
139
- stfd f10, 128(r1)
140
- stfd f11, 136(r1)
141
- stfd f12, 144(r1)
142
- stfd f13, 152(r1)
303
+ stfd f1, 72+(0*8)(r1)
304
+ stfd f2, 72+(1*8)(r1)
305
+ stfd f3, 72+(2*8)(r1)
306
+ stfd f4, 72+(3*8)(r1)
307
+ stfd f5, 72+(4*8)(r1)
308
+ stfd f6, 72+(5*8)(r1)
309
+ stfd f7, 72+(6*8)(r1)
310
+ stfd f8, 72+(7*8)(r1)
311
+ stfd f9, 72+(8*8)(r1)
312
+ stfd f10, 72+(9*8)(r1)
313
+ stfd f11, 72+(10*8)(r1)
314
+ stfd f12, 72+(11*8)(r1)
315
+ stfd f13, 72+(12*8)(r1)
143
316
 
144
317
  /* set up registers for the routine that actually does the work */
145
318
  /* get the context pointer from the trampoline */
146
- mr r3,r11
319
+ mr r3, r11
147
320
 
148
321
  /* now load up the pointer to the result storage */
149
- addi r4,r1,160
322
+ addi r4, r1, 56
150
323
 
151
324
  /* now load up the pointer to the saved gpr registers */
152
- addi r5,r1,200
325
+ addi r5, r1, 200
153
326
 
154
327
  /* now load up the pointer to the saved fpr registers */
155
- addi r6,r1,56
328
+ addi r6, r1, 72
156
329
 
157
330
  /* make the call */
158
331
  bl .ffi_closure_helper_DARWIN
@@ -164,84 +337,107 @@ ffi_closure_ASM:
164
337
 
165
338
  /* look up the proper starting point in table */
166
339
  /* by using return type as offset */
167
- addi r5,r1,160 /* get pointer to results area */
168
- lwz r4,LC..60(2) /* get address of jump table */
169
- slwi r3,r3,2 /* now multiply return type by 4 */
170
- lwzx r3,r4,r3 /* get the contents of that table value */
171
- add r3,r3,r4 /* add contents of table to table address */
172
- mtctr r3
340
+ lwz r4, LC..60(2) /* get address of jump table */
341
+ slwi r3, r3, 4 /* now multiply return type by 4 */
342
+ lwz r0, 176+8(r1) /* load return address */
343
+ add r3, r3, r4 /* add contents of table to table address */
344
+ mtctr r3
173
345
  bctr /* jump to it */
174
346
 
347
+ /* Each fragment must be exactly 16 bytes long (4 instructions).
348
+ Align to 16 byte boundary for cache and dispatch efficiency. */
349
+ .align 4
350
+
175
351
  L..60:
176
- .long L..44-L..60 /* FFI_TYPE_VOID */
177
- .long L..50-L..60 /* FFI_TYPE_INT */
178
- .long L..47-L..60 /* FFI_TYPE_FLOAT */
179
- .long L..46-L..60 /* FFI_TYPE_DOUBLE */
180
- .long L..46-L..60 /* FFI_TYPE_LONGDOUBLE */
181
- .long L..56-L..60 /* FFI_TYPE_UINT8 */
182
- .long L..55-L..60 /* FFI_TYPE_SINT8 */
183
- .long L..58-L..60 /* FFI_TYPE_UINT16 */
184
- .long L..57-L..60 /* FFI_TYPE_SINT16 */
185
- .long L..50-L..60 /* FFI_TYPE_UINT32 */
186
- .long L..50-L..60 /* FFI_TYPE_SINT32 */
187
- .long L..48-L..60 /* FFI_TYPE_UINT64 */
188
- .long L..48-L..60 /* FFI_TYPE_SINT64 */
189
- .long L..44-L..60 /* FFI_TYPE_STRUCT */
190
- .long L..50-L..60 /* FFI_TYPE_POINTER */
191
-
192
-
193
- /* case double */
194
- L..46:
195
- lfd f1,0(r5)
196
- b L..44
197
-
198
- /* case float */
199
- L..47:
200
- lfs f1,0(r5)
201
- b L..44
202
-
203
- /* case long long */
204
- L..48:
205
- lwz r3,0(r5)
206
- lwz r4,4(r5)
207
- b L..44
208
-
209
- /* case default / int32 / pointer */
210
- L..50:
211
- lwz r3,0(r5)
212
- b L..44
213
-
214
- /* case signed int8 */
215
- L..55:
216
- addi r5,r5,3
217
- lbz r3,0(r5)
218
- slwi r3,r3,24
219
- srawi r3,r3,24
220
- b L..44
221
-
222
- /* case unsigned int8 */
223
- L..56:
224
- addi r5,r5,3
225
- lbz r3,0(r5)
226
- b L..44
227
-
228
- /* case signed int16 */
229
- L..57:
230
- addi r5,r5,2
231
- lhz r3,0(r5)
232
- extsh r3,r3
233
- b L..44
234
-
235
- /* case unsigned int16 */
236
- L..58:
237
- addi r5,r5,2
238
- lhz r3,0(r5)
239
-
240
- /* case void / done */
241
- L..44:
242
- addi r1,r1,176 /* restore stack pointer */
243
- lwz r0,8(r1) /* get return address */
244
- mtlr r0 /* reset link register */
352
+ /* case FFI_TYPE_VOID */
353
+ mtlr r0
354
+ addi r1, r1, 176
245
355
  blr
356
+ nop
357
+
358
+ /* case FFI_TYPE_INT */
359
+ lwz r3, 56+0(r1)
360
+ mtlr r0
361
+ addi r1, r1, 176
362
+ blr
363
+
364
+ /* case FFI_TYPE_FLOAT */
365
+ lfs f1, 56+0(r1)
366
+ mtlr r0
367
+ addi r1, r1, 176
368
+ blr
369
+
370
+ /* case FFI_TYPE_DOUBLE */
371
+ lfd f1, 56+0(r1)
372
+ mtlr r0
373
+ addi r1, r1, 176
374
+ blr
375
+
376
+ /* case FFI_TYPE_LONGDOUBLE */
377
+ lfd f1, 56+0(r1)
378
+ mtlr r0
379
+ lfd f2, 56+8(r1)
380
+ b L..finish
381
+
382
+ /* case FFI_TYPE_UINT8 */
383
+ lbz r3, 56+3(r1)
384
+ mtlr r0
385
+ addi r1, r1, 176
386
+ blr
387
+
388
+ /* case FFI_TYPE_SINT8 */
389
+ lbz r3, 56+3(r1)
390
+ mtlr r0
391
+ extsb r3, r3
392
+ b L..finish
246
393
 
394
+ /* case FFI_TYPE_UINT16 */
395
+ lhz r3, 56+2(r1)
396
+ mtlr r0
397
+ addi r1, r1, 176
398
+ blr
399
+
400
+ /* case FFI_TYPE_SINT16 */
401
+ lha r3, 56+2(r1)
402
+ mtlr r0
403
+ addi r1, r1, 176
404
+ blr
405
+
406
+ /* case FFI_TYPE_UINT32 */
407
+ lwz r3, 56+0(r1)
408
+ mtlr r0
409
+ addi r1, r1, 176
410
+ blr
411
+
412
+ /* case FFI_TYPE_SINT32 */
413
+ lwz r3, 56+0(r1)
414
+ mtlr r0
415
+ addi r1, r1, 176
416
+ blr
417
+
418
+ /* case FFI_TYPE_UINT64 */
419
+ lwz r3, 56+0(r1)
420
+ mtlr r0
421
+ lwz r4, 56+4(r1)
422
+ b L..finish
423
+
424
+ /* case FFI_TYPE_SINT64 */
425
+ lwz r3, 56+0(r1)
426
+ mtlr r0
427
+ lwz r4, 56+4(r1)
428
+ b L..finish
429
+
430
+ /* case FFI_TYPE_STRUCT */
431
+ mtlr r0
432
+ addi r1, r1, 176
433
+ blr
434
+ nop
435
+
436
+ /* case FFI_TYPE_POINTER */
437
+ lwz r3, 56+0(r1)
438
+ mtlr r0
439
+ L..finish:
440
+ addi r1, r1, 176
441
+ blr
442
+ #endif
247
443
  /* END(ffi_closure_ASM) */