ffi 0.5.4-x86-mingw32 → 0.6.3-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ffi might be problematic. Click here for more details.

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,6 +1,6 @@
1
1
  /* -----------------------------------------------------------------------
2
2
  ffi.c - Copyright (c) 1998 Geoffrey Keating
3
- Copyright (C) 2007 Free Software Foundation, Inc
3
+ Copyright (C) 2007, 2008 Free Software Foundation, Inc
4
4
  Copyright (C) 2008 Red Hat, Inc
5
5
 
6
6
  PowerPC Foreign Function Interface
@@ -43,6 +43,11 @@ enum {
43
43
  FLAG_RETURNS_64BITS = 1 << (31-28),
44
44
 
45
45
  FLAG_RETURNS_128BITS = 1 << (31-27), /* cr6 */
46
+ FLAG_SYSV_SMST_R4 = 1 << (31-26), /* use r4 for FFI_SYSV 8 byte
47
+ structs. */
48
+ FLAG_SYSV_SMST_R3 = 1 << (31-25), /* use r3 for FFI_SYSV 4 byte
49
+ structs. */
50
+ /* Bits (31-24) through (31-19) store shift value for SMST */
46
51
 
47
52
  FLAG_ARG_NEEDS_COPY = 1 << (31- 7),
48
53
  FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */
@@ -180,6 +185,7 @@ ffi_prep_args_SYSV (extended_cif *ecif, unsigned *const stack)
180
185
  {
181
186
  *next_arg.f = (float) double_tmp;
182
187
  next_arg.u += 1;
188
+ intarg_count++;
183
189
  }
184
190
  else
185
191
  *fpr_base.d++ = double_tmp;
@@ -680,15 +686,15 @@ ffi_prep_cif_machdep (ffi_cif *cif)
680
686
  The same applies for the structs returned in r3/r4. */
681
687
  if (size <= 4)
682
688
  {
683
- flags |= 1 << (31 - FFI_SYSV_TYPE_SMALL_STRUCT - 1);
684
- flags |= 8 * (4 - size) << 4;
689
+ flags |= FLAG_SYSV_SMST_R3;
690
+ flags |= 8 * (4 - size) << 8;
685
691
  break;
686
692
  }
687
693
  /* These structs are returned in r3 and r4. See above. */
688
694
  if (size <= 8)
689
695
  {
690
- flags |= 1 << (31 - FFI_SYSV_TYPE_SMALL_STRUCT - 2);
691
- flags |= 8 * (8 - size) << 4;
696
+ flags |= FLAG_SYSV_SMST_R3 | FLAG_SYSV_SMST_R4;
697
+ flags |= 8 * (8 - size) << 8;
692
698
  break;
693
699
  }
694
700
  }
@@ -1144,6 +1150,7 @@ ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
1144
1150
  pst++;
1145
1151
  avalue[i] = pst;
1146
1152
  pst += 2;
1153
+ ng = 8;
1147
1154
  }
1148
1155
  break;
1149
1156
 
@@ -1217,6 +1224,7 @@ ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
1217
1224
  {
1218
1225
  avalue[i] = pst;
1219
1226
  pst += 4;
1227
+ ng = 8;
1220
1228
  }
1221
1229
  break;
1222
1230
  }
@@ -1249,10 +1257,15 @@ ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
1249
1257
 
1250
1258
  /* Tell ffi_closure_SYSV how to perform return type promotions.
1251
1259
  Because the FFI_SYSV ABI returns the structures <= 8 bytes in r3/r4
1252
- we have to tell ffi_closure_SYSV how to treat them. */
1260
+ we have to tell ffi_closure_SYSV how to treat them. We combine the base
1261
+ type FFI_SYSV_TYPE_SMALL_STRUCT - 1 with the size of the struct.
1262
+ So a one byte struct gets the return type 16. Return type 1 to 15 are
1263
+ already used and we never have a struct with size zero. That is the reason
1264
+ for the subtraction of 1. See the comment in ffitarget.h about ordering.
1265
+ */
1253
1266
  if (cif->abi == FFI_SYSV && cif->rtype->type == FFI_TYPE_STRUCT
1254
1267
  && size <= 8)
1255
- return FFI_SYSV_TYPE_SMALL_STRUCT + size;
1268
+ return (FFI_SYSV_TYPE_SMALL_STRUCT - 1) + size;
1256
1269
  #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
1257
1270
  else if (cif->rtype->type == FFI_TYPE_LONGDOUBLE
1258
1271
  && cif->abi != FFI_LINUX && cif->abi != FFI_LINUX_SOFT_FLOAT)
@@ -3,7 +3,7 @@
3
3
 
4
4
  Copyright (C) 1998 Geoffrey Keating
5
5
  Copyright (C) 2001 John Hornkvist
6
- Copyright (C) 2002, 2006, 2007 Free Software Foundation, Inc.
6
+ Copyright (C) 2002, 2006, 2007, 2009 Free Software Foundation, Inc.
7
7
 
8
8
  FFI support for Darwin and AIX.
9
9
 
@@ -32,7 +32,7 @@
32
32
 
33
33
  #include <stdlib.h>
34
34
 
35
- extern void ffi_closure_ASM(void);
35
+ extern void ffi_closure_ASM (void);
36
36
 
37
37
  enum {
38
38
  /* The assembly depends on these exact flags. */
@@ -80,34 +80,37 @@ enum { ASM_NEEDS_REGISTERS = 4 };
80
80
 
81
81
  */
82
82
 
83
- void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
83
+ void
84
+ ffi_prep_args (extended_cif *ecif, unsigned long *const stack)
84
85
  {
85
86
  const unsigned bytes = ecif->cif->bytes;
86
87
  const unsigned flags = ecif->cif->flags;
88
+ const unsigned nargs = ecif->cif->nargs;
89
+ const ffi_abi abi = ecif->cif->abi;
87
90
 
88
91
  /* 'stacktop' points at the previous backchain pointer. */
89
- unsigned *const stacktop = stack + (bytes / sizeof(unsigned));
92
+ unsigned long *const stacktop = stack + (bytes / sizeof(unsigned long));
90
93
 
91
94
  /* 'fpr_base' points at the space for fpr1, and grows upwards as
92
95
  we use FPR registers. */
93
- double *fpr_base = (double*) (stacktop - ASM_NEEDS_REGISTERS) - NUM_FPR_ARG_REGISTERS;
96
+ double *fpr_base = (double *) (stacktop - ASM_NEEDS_REGISTERS) - NUM_FPR_ARG_REGISTERS;
94
97
  int fparg_count = 0;
95
98
 
96
99
 
97
100
  /* 'next_arg' grows up as we put parameters in it. */
98
- unsigned *next_arg = stack + 6; /* 6 reserved positions. */
101
+ unsigned long *next_arg = stack + 6; /* 6 reserved positions. */
99
102
 
100
- int i = ecif->cif->nargs;
103
+ int i;
101
104
  double double_tmp;
102
105
  void **p_argv = ecif->avalue;
103
- unsigned gprvalue;
106
+ unsigned long gprvalue;
104
107
  ffi_type** ptr = ecif->cif->arg_types;
105
108
  char *dest_cpy;
106
109
  unsigned size_al = 0;
107
110
 
108
111
  /* Check that everything starts aligned properly. */
109
- FFI_ASSERT(((unsigned)(char *)stack & 0xF) == 0);
110
- FFI_ASSERT(((unsigned)(char *)stacktop & 0xF) == 0);
112
+ FFI_ASSERT(((unsigned) (char *) stack & 0xF) == 0);
113
+ FFI_ASSERT(((unsigned) (char *) stacktop & 0xF) == 0);
111
114
  FFI_ASSERT((bytes & 0xF) == 0);
112
115
 
113
116
  /* Deal with return values that are actually pass-by-reference.
@@ -115,12 +118,10 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
115
118
  Return values are referenced by r3, so r4 is the first parameter. */
116
119
 
117
120
  if (flags & FLAG_RETVAL_REFERENCE)
118
- *next_arg++ = (unsigned)(char *)ecif->rvalue;
121
+ *next_arg++ = (unsigned long) (char *) ecif->rvalue;
119
122
 
120
123
  /* Now for the arguments. */
121
- for (;
122
- i > 0;
123
- i--, ptr++, p_argv++)
124
+ for (i = nargs; i > 0; i--, ptr++, p_argv++)
124
125
  {
125
126
  switch ((*ptr)->type)
126
127
  {
@@ -128,7 +129,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
128
129
  purpose registers are filled, the corresponding GPRs that match
129
130
  the size of the floating-point parameter are skipped. */
130
131
  case FFI_TYPE_FLOAT:
131
- double_tmp = *(float *)*p_argv;
132
+ double_tmp = *(float *) *p_argv;
132
133
  if (fparg_count >= NUM_FPR_ARG_REGISTERS)
133
134
  *(double *)next_arg = double_tmp;
134
135
  else
@@ -139,12 +140,16 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
139
140
  break;
140
141
 
141
142
  case FFI_TYPE_DOUBLE:
142
- double_tmp = *(double *)*p_argv;
143
+ double_tmp = *(double *) *p_argv;
143
144
  if (fparg_count >= NUM_FPR_ARG_REGISTERS)
144
145
  *(double *)next_arg = double_tmp;
145
146
  else
146
147
  *fpr_base++ = double_tmp;
148
+ #ifdef POWERPC64
149
+ next_arg++;
150
+ #else
147
151
  next_arg += 2;
152
+ #endif
148
153
  fparg_count++;
149
154
  FFI_ASSERT(flags & FLAG_FP_ARGUMENTS);
150
155
  break;
@@ -152,42 +157,71 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
152
157
  #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
153
158
 
154
159
  case FFI_TYPE_LONGDOUBLE:
155
- double_tmp = ((double *)*p_argv)[0];
156
- if (fparg_count >= NUM_FPR_ARG_REGISTERS)
157
- *(double *)next_arg = double_tmp;
160
+ #ifdef POWERPC64
161
+ if (fparg_count < NUM_FPR_ARG_REGISTERS)
162
+ *(long double *) fpr_base++ = *(long double *) *p_argv;
158
163
  else
164
+ *(long double *) next_arg = *(long double *) *p_argv;
165
+ next_arg += 2;
166
+ fparg_count += 2;
167
+ #else
168
+ double_tmp = ((double *) *p_argv)[0];
169
+ if (fparg_count < NUM_FPR_ARG_REGISTERS)
159
170
  *fpr_base++ = double_tmp;
171
+ else
172
+ *(double *) next_arg = double_tmp;
160
173
  next_arg += 2;
161
174
  fparg_count++;
162
- double_tmp = ((double *)*p_argv)[1];
163
- if (fparg_count >= NUM_FPR_ARG_REGISTERS)
164
- *(double *)next_arg = double_tmp;
165
- else
175
+
176
+ double_tmp = ((double *) *p_argv)[1];
177
+ if (fparg_count < NUM_FPR_ARG_REGISTERS)
166
178
  *fpr_base++ = double_tmp;
179
+ else
180
+ *(double *) next_arg = double_tmp;
167
181
  next_arg += 2;
168
182
  fparg_count++;
183
+ #endif
169
184
  FFI_ASSERT(flags & FLAG_FP_ARGUMENTS);
170
185
  break;
171
186
  #endif
172
187
  case FFI_TYPE_UINT64:
173
188
  case FFI_TYPE_SINT64:
174
- *(long long *)next_arg = *(long long *)*p_argv;
175
- next_arg+=2;
189
+ #ifdef POWERPC64
190
+ gprvalue = *(long long *) *p_argv;
191
+ goto putgpr;
192
+ #else
193
+ *(long long *) next_arg = *(long long *) *p_argv;
194
+ next_arg += 2;
195
+ #endif
176
196
  break;
197
+ case FFI_TYPE_POINTER:
198
+ gprvalue = *(unsigned long *) *p_argv;
199
+ goto putgpr;
177
200
  case FFI_TYPE_UINT8:
178
- gprvalue = *(unsigned char *)*p_argv;
201
+ gprvalue = *(unsigned char *) *p_argv;
179
202
  goto putgpr;
180
203
  case FFI_TYPE_SINT8:
181
- gprvalue = *(signed char *)*p_argv;
204
+ gprvalue = *(signed char *) *p_argv;
182
205
  goto putgpr;
183
206
  case FFI_TYPE_UINT16:
184
- gprvalue = *(unsigned short *)*p_argv;
207
+ gprvalue = *(unsigned short *) *p_argv;
185
208
  goto putgpr;
186
209
  case FFI_TYPE_SINT16:
187
- gprvalue = *(signed short *)*p_argv;
210
+ gprvalue = *(signed short *) *p_argv;
188
211
  goto putgpr;
189
212
 
190
213
  case FFI_TYPE_STRUCT:
214
+ #ifdef POWERPC64
215
+ dest_cpy = (char *) next_arg;
216
+ size_al = (*ptr)->size;
217
+ if ((*ptr)->elements[0]->type == 3)
218
+ size_al = ALIGN((*ptr)->size, 8);
219
+ if (size_al < 3 && abi == FFI_DARWIN)
220
+ dest_cpy += 4 - size_al;
221
+
222
+ memcpy ((char *) dest_cpy, (char *) *p_argv, size_al);
223
+ next_arg += (size_al + 7) / 8;
224
+ #else
191
225
  dest_cpy = (char *) next_arg;
192
226
 
193
227
  /* Structures that match the basic modes (QI 1 byte, HI 2 bytes,
@@ -195,22 +229,24 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
195
229
  Structures with 3 byte in size are padded upwards. */
196
230
  size_al = (*ptr)->size;
197
231
  /* If the first member of the struct is a double, then align
198
- the struct to double-word.
199
- Type 3 is defined in include/ffi.h. #define FFI_TYPE_DOUBLE 3. */
200
- if ((*ptr)->elements[0]->type == 3)
232
+ the struct to double-word. */
233
+ if ((*ptr)->elements[0]->type == FFI_TYPE_DOUBLE)
201
234
  size_al = ALIGN((*ptr)->size, 8);
202
- if (size_al < 3 && ecif->cif->abi == FFI_DARWIN)
235
+ if (size_al < 3 && abi == FFI_DARWIN)
203
236
  dest_cpy += 4 - size_al;
204
237
 
205
- memcpy((char *)dest_cpy, (char *)*p_argv, size_al);
238
+ memcpy((char *) dest_cpy, (char *) *p_argv, size_al);
206
239
  next_arg += (size_al + 3) / 4;
240
+ #endif
207
241
  break;
208
242
 
209
243
  case FFI_TYPE_INT:
210
- case FFI_TYPE_UINT32:
211
244
  case FFI_TYPE_SINT32:
212
- case FFI_TYPE_POINTER:
213
- gprvalue = *(unsigned *)*p_argv;
245
+ gprvalue = *(signed int *) *p_argv;
246
+ goto putgpr;
247
+
248
+ case FFI_TYPE_UINT32:
249
+ gprvalue = *(unsigned int *) *p_argv;
214
250
  putgpr:
215
251
  *next_arg++ = gprvalue;
216
252
  break;
@@ -268,8 +304,44 @@ darwin_adjust_aggregate_sizes (ffi_type *s)
268
304
  /* Do not add additional tail padding. */
269
305
  }
270
306
 
307
+ /* Adjust the size of S to be correct for AIX.
308
+ Word-align double unless it is the first member of a structure. */
309
+
310
+ static void
311
+ aix_adjust_aggregate_sizes (ffi_type *s)
312
+ {
313
+ int i;
314
+
315
+ if (s->type != FFI_TYPE_STRUCT)
316
+ return;
317
+
318
+ s->size = 0;
319
+ for (i = 0; s->elements[i] != NULL; i++)
320
+ {
321
+ ffi_type *p;
322
+ int align;
323
+
324
+ p = s->elements[i];
325
+ aix_adjust_aggregate_sizes (p);
326
+ align = p->alignment;
327
+ if (i != 0 && p->type == FFI_TYPE_DOUBLE)
328
+ align = 4;
329
+ s->size = ALIGN(s->size, align) + p->size;
330
+ }
331
+
332
+ s->size = ALIGN(s->size, s->alignment);
333
+
334
+ if (s->elements[0]->type == FFI_TYPE_UINT64
335
+ || s->elements[0]->type == FFI_TYPE_SINT64
336
+ || s->elements[0]->type == FFI_TYPE_DOUBLE
337
+ || s->elements[0]->alignment == 8)
338
+ s->alignment = s->alignment > 8 ? s->alignment : 8;
339
+ /* Do not add additional tail padding. */
340
+ }
341
+
271
342
  /* Perform machine dependent cif processing. */
272
- ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
343
+ ffi_status
344
+ ffi_prep_cif_machdep (ffi_cif *cif)
273
345
  {
274
346
  /* All this is for the DARWIN ABI. */
275
347
  int i;
@@ -290,6 +362,13 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
290
362
  darwin_adjust_aggregate_sizes (cif->arg_types[i]);
291
363
  }
292
364
 
365
+ if (cif->abi == FFI_AIX)
366
+ {
367
+ aix_adjust_aggregate_sizes (cif->rtype);
368
+ for (i = 0; i < cif->nargs; i++)
369
+ aix_adjust_aggregate_sizes (cif->arg_types[i]);
370
+ }
371
+
293
372
  /* Space for the frame pointer, callee's LR, CR, etc, and for
294
373
  the asm's temp regs. */
295
374
 
@@ -324,6 +403,9 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
324
403
 
325
404
  case FFI_TYPE_UINT64:
326
405
  case FFI_TYPE_SINT64:
406
+ #ifdef POWERPC64
407
+ case FFI_TYPE_POINTER:
408
+ #endif
327
409
  flags |= FLAG_RETURNS_64BITS;
328
410
  break;
329
411
 
@@ -387,11 +469,14 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
387
469
  case FFI_TYPE_STRUCT:
388
470
  size_al = (*ptr)->size;
389
471
  /* If the first member of the struct is a double, then align
390
- the struct to double-word.
391
- Type 3 is defined in include/ffi.h. #define FFI_TYPE_DOUBLE 3. */
392
- if ((*ptr)->elements[0]->type == 3)
472
+ the struct to double-word. */
473
+ if ((*ptr)->elements[0]->type == FFI_TYPE_DOUBLE)
393
474
  size_al = ALIGN((*ptr)->size, 8);
475
+ #ifdef POWERPC64
476
+ intarg_count += (size_al + 7) / 8;
477
+ #else
394
478
  intarg_count += (size_al + 3) / 4;
479
+ #endif
395
480
  break;
396
481
 
397
482
  default:
@@ -410,8 +495,13 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
410
495
  bytes += NUM_FPR_ARG_REGISTERS * sizeof(double);
411
496
 
412
497
  /* Stack space. */
498
+ #ifdef POWERPC64
499
+ if ((intarg_count + fparg_count) > NUM_GPR_ARG_REGISTERS)
500
+ bytes += (intarg_count + fparg_count) * sizeof(long);
501
+ #else
413
502
  if ((intarg_count + 2 * fparg_count) > NUM_GPR_ARG_REGISTERS)
414
503
  bytes += (intarg_count + 2 * fparg_count) * sizeof(long);
504
+ #endif
415
505
  else
416
506
  bytes += NUM_GPR_ARG_REGISTERS * sizeof(long);
417
507
 
@@ -424,12 +514,13 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
424
514
  return FFI_OK;
425
515
  }
426
516
 
427
- extern void ffi_call_AIX(extended_cif *, unsigned, unsigned, unsigned *,
517
+ extern void ffi_call_AIX(extended_cif *, long, unsigned, unsigned *,
428
518
  void (*fn)(void), void (*fn2)(void));
429
- extern void ffi_call_DARWIN(extended_cif *, unsigned, unsigned, unsigned *,
519
+ extern void ffi_call_DARWIN(extended_cif *, long, unsigned, unsigned *,
430
520
  void (*fn)(void), void (*fn2)(void));
431
521
 
432
- void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
522
+ void
523
+ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
433
524
  {
434
525
  extended_cif ecif;
435
526
 
@@ -442,7 +533,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
442
533
  if ((rvalue == NULL) &&
443
534
  (cif->rtype->type == FFI_TYPE_STRUCT))
444
535
  {
445
- ecif.rvalue = alloca(cif->rtype->size);
536
+ ecif.rvalue = alloca (cif->rtype->size);
446
537
  }
447
538
  else
448
539
  ecif.rvalue = rvalue;
@@ -450,11 +541,11 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
450
541
  switch (cif->abi)
451
542
  {
452
543
  case FFI_AIX:
453
- ffi_call_AIX(&ecif, -cif->bytes, cif->flags, ecif.rvalue, fn,
544
+ ffi_call_AIX(&ecif, -(long)cif->bytes, cif->flags, ecif.rvalue, fn,
454
545
  ffi_prep_args);
455
546
  break;
456
547
  case FFI_DARWIN:
457
- ffi_call_DARWIN(&ecif, -cif->bytes, cif->flags, ecif.rvalue, fn,
548
+ ffi_call_DARWIN(&ecif, -(long)cif->bytes, cif->flags, ecif.rvalue, fn,
458
549
  ffi_prep_args);
459
550
  break;
460
551
  default:
@@ -617,8 +708,9 @@ typedef union
617
708
  double d;
618
709
  } ffi_dblfl;
619
710
 
620
- int ffi_closure_helper_DARWIN (ffi_closure*, void*,
621
- unsigned long*, ffi_dblfl*);
711
+ int
712
+ ffi_closure_helper_DARWIN (ffi_closure *, void *,
713
+ unsigned long *, ffi_dblfl *);
622
714
 
623
715
  /* Basically the trampoline invokes ffi_closure_ASM, and on
624
716
  entry, r11 holds the address of the closure.
@@ -627,8 +719,9 @@ int ffi_closure_helper_DARWIN (ffi_closure*, void*,
627
719
  up space for a return value, ffi_closure_ASM invokes the
628
720
  following helper function to do most of the work. */
629
721
 
630
- int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
631
- unsigned long * pgr, ffi_dblfl * pfr)
722
+ int
723
+ ffi_closure_helper_DARWIN (ffi_closure *closure, void *rvalue,
724
+ unsigned long *pgr, ffi_dblfl *pfr)
632
725
  {
633
726
  /* rvalue is the pointer to space for return value in closure assembly
634
727
  pgr is the pointer to where r3-r10 are stored in ffi_closure_ASM
@@ -645,18 +738,12 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
645
738
  void ** avalue;
646
739
  ffi_type ** arg_types;
647
740
  long i, avn;
648
- long nf; /* number of floating registers already used. */
649
- long ng; /* number of general registers already used. */
650
741
  ffi_cif * cif;
651
- double temp;
742
+ ffi_dblfl * end_pfr = pfr + NUM_FPR_ARG_REGISTERS;
652
743
  unsigned size_al;
653
- union ldu temp_ld;
654
744
 
655
745
  cif = closure->cif;
656
- avalue = alloca(cif->nargs * sizeof(void *));
657
-
658
- nf = 0;
659
- ng = 0;
746
+ avalue = alloca (cif->nargs * sizeof(void *));
660
747
 
661
748
  /* Copy the caller's structure return value address so that the closure
662
749
  returns the data directly to the caller. */
@@ -664,7 +751,6 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
664
751
  {
665
752
  rvalue = (void *) *pgr;
666
753
  pgr++;
667
- ng++;
668
754
  }
669
755
 
670
756
  i = 0;
@@ -678,58 +764,82 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
678
764
  {
679
765
  case FFI_TYPE_SINT8:
680
766
  case FFI_TYPE_UINT8:
767
+ #ifdef POWERPC64
768
+ avalue[i] = (char *) pgr + 7;
769
+ #else
681
770
  avalue[i] = (char *) pgr + 3;
682
- ng++;
771
+ #endif
683
772
  pgr++;
684
773
  break;
685
774
 
686
775
  case FFI_TYPE_SINT16:
687
776
  case FFI_TYPE_UINT16:
777
+ #ifdef POWERPC64
778
+ avalue[i] = (char *) pgr + 6;
779
+ #else
688
780
  avalue[i] = (char *) pgr + 2;
689
- ng++;
781
+ #endif
690
782
  pgr++;
691
783
  break;
692
784
 
693
785
  case FFI_TYPE_SINT32:
694
786
  case FFI_TYPE_UINT32:
787
+ #ifdef POWERPC64
788
+ avalue[i] = (char *) pgr + 4;
789
+ #else
695
790
  case FFI_TYPE_POINTER:
696
791
  avalue[i] = pgr;
697
- ng++;
792
+ #endif
698
793
  pgr++;
699
794
  break;
700
795
 
701
796
  case FFI_TYPE_STRUCT:
797
+ #ifdef POWERPC64
798
+ size_al = arg_types[i]->size;
799
+ if (arg_types[i]->elements[0]->type == FFI_TYPE_DOUBLE)
800
+ size_al = ALIGN (arg_types[i]->size, 8);
801
+ if (size_al < 3 && cif->abi == FFI_DARWIN)
802
+ avalue[i] = (void *) pgr + 8 - size_al;
803
+ else
804
+ avalue[i] = (void *) pgr;
805
+ pgr += (size_al + 7) / 8;
806
+ #else
702
807
  /* Structures that match the basic modes (QI 1 byte, HI 2 bytes,
703
808
  SI 4 bytes) are aligned as if they were those modes. */
704
809
  size_al = arg_types[i]->size;
705
810
  /* If the first member of the struct is a double, then align
706
- the struct to double-word.
707
- Type 3 is defined in include/ffi.h. #define FFI_TYPE_DOUBLE 3. */
708
- if (arg_types[i]->elements[0]->type == 3)
811
+ the struct to double-word. */
812
+ if (arg_types[i]->elements[0]->type == FFI_TYPE_DOUBLE)
709
813
  size_al = ALIGN(arg_types[i]->size, 8);
710
814
  if (size_al < 3 && cif->abi == FFI_DARWIN)
711
815
  avalue[i] = (void*) pgr + 4 - size_al;
712
816
  else
713
817
  avalue[i] = (void*) pgr;
714
- ng += (size_al + 3) / 4;
715
818
  pgr += (size_al + 3) / 4;
819
+ #endif
716
820
  break;
717
821
 
718
822
  case FFI_TYPE_SINT64:
719
823
  case FFI_TYPE_UINT64:
824
+ #ifdef POWERPC64
825
+ case FFI_TYPE_POINTER:
826
+ avalue[i] = pgr;
827
+ pgr++;
828
+ break;
829
+ #else
720
830
  /* Long long ints are passed in two gpr's. */
721
831
  avalue[i] = pgr;
722
- ng += 2;
723
832
  pgr += 2;
724
833
  break;
834
+ #endif
725
835
 
726
836
  case FFI_TYPE_FLOAT:
727
837
  /* A float value consumes a GPR.
728
838
  There are 13 64bit floating point registers. */
729
- if (nf < NUM_FPR_ARG_REGISTERS)
839
+ if (pfr < end_pfr)
730
840
  {
731
- temp = pfr->d;
732
- pfr->f = (float)temp;
841
+ double temp = pfr->d;
842
+ pfr->f = (float) temp;
733
843
  avalue[i] = pfr;
734
844
  pfr++;
735
845
  }
@@ -737,15 +847,13 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
737
847
  {
738
848
  avalue[i] = pgr;
739
849
  }
740
- nf++;
741
- ng++;
742
850
  pgr++;
743
851
  break;
744
852
 
745
853
  case FFI_TYPE_DOUBLE:
746
854
  /* A double value consumes two GPRs.
747
855
  There are 13 64bit floating point registers. */
748
- if (nf < NUM_FPR_ARG_REGISTERS)
856
+ if (pfr < end_pfr)
749
857
  {
750
858
  avalue[i] = pfr;
751
859
  pfr++;
@@ -754,17 +862,36 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
754
862
  {
755
863
  avalue[i] = pgr;
756
864
  }
757
- nf++;
758
- ng += 2;
865
+ #ifdef POWERPC64
866
+ pgr++;
867
+ #else
759
868
  pgr += 2;
869
+ #endif
760
870
  break;
761
871
 
762
872
  #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
763
873
 
764
874
  case FFI_TYPE_LONGDOUBLE:
875
+ #ifdef POWERPC64
876
+ if (pfr + 1 < end_pfr)
877
+ {
878
+ avalue[i] = pfr;
879
+ pfr += 2;
880
+ }
881
+ else
882
+ {
883
+ if (pfr < end_pfr)
884
+ {
885
+ *pgr = *(unsigned long *) pfr;
886
+ pfr++;
887
+ }
888
+ avalue[i] = pgr;
889
+ }
890
+ pgr += 2;
891
+ #else /* POWERPC64 */
765
892
  /* A long double value consumes four GPRs and two FPRs.
766
893
  There are 13 64bit floating point registers. */
767
- if (nf < NUM_FPR_ARG_REGISTERS - 1)
894
+ if (pfr + 1 < end_pfr)
768
895
  {
769
896
  avalue[i] = pfr;
770
897
  pfr += 2;
@@ -772,19 +899,20 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
772
899
  /* Here we have the situation where one part of the long double
773
900
  is stored in fpr13 and the other part is already on the stack.
774
901
  We use a union to pass the long double to avalue[i]. */
775
- else if (nf == NUM_FPR_ARG_REGISTERS - 1)
902
+ else if (pfr + 1 == end_pfr)
776
903
  {
904
+ union ldu temp_ld;
777
905
  memcpy (&temp_ld.lb[0], pfr, sizeof(ldbits));
778
906
  memcpy (&temp_ld.lb[1], pgr + 2, sizeof(ldbits));
779
907
  avalue[i] = &temp_ld.ld;
908
+ pfr++;
780
909
  }
781
910
  else
782
911
  {
783
912
  avalue[i] = pgr;
784
913
  }
785
- nf += 2;
786
- ng += 4;
787
914
  pgr += 4;
915
+ #endif /* POWERPC64 */
788
916
  break;
789
917
  #endif
790
918
  default: