ffi 1.0.9-x86-mingw32 → 1.0.12.pre-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 (218) hide show
  1. data/Rakefile +16 -16
  2. data/ext/ffi_c/AbstractMemory.c +376 -14
  3. data/ext/ffi_c/AbstractMemory.h +8 -0
  4. data/ext/ffi_c/ArrayType.c +28 -0
  5. data/ext/ffi_c/Buffer.c +109 -25
  6. data/ext/ffi_c/Call.c +16 -5
  7. data/ext/ffi_c/ClosurePool.c +21 -8
  8. data/ext/ffi_c/DataConverter.c +29 -0
  9. data/ext/ffi_c/DynamicLibrary.c +71 -2
  10. data/ext/ffi_c/Function.c +122 -11
  11. data/ext/ffi_c/Function.h +6 -0
  12. data/ext/ffi_c/FunctionInfo.c +21 -1
  13. data/ext/ffi_c/LastError.c +24 -0
  14. data/ext/ffi_c/MappedType.c +22 -0
  15. data/ext/ffi_c/MemoryPointer.c +19 -1
  16. data/ext/ffi_c/MemoryPointer.h +6 -0
  17. data/ext/ffi_c/MethodHandle.c +26 -11
  18. data/ext/ffi_c/Platform.c +17 -3
  19. data/ext/ffi_c/Pointer.c +106 -0
  20. data/ext/ffi_c/Pointer.h +6 -0
  21. data/ext/ffi_c/Struct.c +10 -4
  22. data/ext/ffi_c/Struct.h +2 -1
  23. data/ext/ffi_c/StructByReference.c +8 -0
  24. data/ext/ffi_c/StructByValue.c +8 -0
  25. data/ext/ffi_c/StructLayout.c +8 -2
  26. data/ext/ffi_c/Thread.c +131 -1
  27. data/ext/ffi_c/Thread.h +6 -0
  28. data/ext/ffi_c/Type.c +111 -17
  29. data/ext/ffi_c/Types.c +9 -2
  30. data/ext/ffi_c/Types.h +4 -0
  31. data/ext/ffi_c/Variadic.c +13 -4
  32. data/ext/ffi_c/compat.h +8 -0
  33. data/ext/ffi_c/endian.h +10 -1
  34. data/ext/ffi_c/extconf.rb +51 -35
  35. data/ext/ffi_c/ffi.c +5 -0
  36. data/ext/ffi_c/libffi.darwin.mk +15 -15
  37. data/ext/ffi_c/libffi.gnu.mk +3 -3
  38. data/ext/ffi_c/libffi.mk +4 -4
  39. data/ext/ffi_c/libffi.vc.mk +26 -0
  40. data/ext/ffi_c/libffi.vc64.mk +26 -0
  41. data/ext/ffi_c/libffi/ChangeLog +541 -0
  42. data/ext/ffi_c/libffi/ChangeLog.libffi +13 -87
  43. data/ext/ffi_c/libffi/LICENSE +3 -3
  44. data/ext/ffi_c/libffi/Makefile.am +41 -32
  45. data/ext/ffi_c/libffi/Makefile.in +95 -66
  46. data/ext/ffi_c/libffi/Makefile.vc +141 -0
  47. data/ext/ffi_c/libffi/Makefile.vc64 +141 -0
  48. data/ext/ffi_c/libffi/README +40 -4
  49. data/ext/ffi_c/libffi/aclocal.m4 +729 -7854
  50. data/ext/ffi_c/libffi/build-ios.sh +67 -0
  51. data/ext/ffi_c/libffi/compile +11 -10
  52. data/ext/ffi_c/libffi/config.guess +4 -1
  53. data/ext/ffi_c/libffi/config.sub +6 -3
  54. data/ext/ffi_c/libffi/configure +6264 -6354
  55. data/ext/ffi_c/libffi/configure.ac +155 -63
  56. data/ext/ffi_c/libffi/depcomp +81 -35
  57. data/ext/ffi_c/libffi/doc/libffi.info +78 -18
  58. data/ext/ffi_c/libffi/doc/libffi.texi +64 -5
  59. data/ext/ffi_c/libffi/doc/stamp-vti +4 -4
  60. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  61. data/ext/ffi_c/libffi/fficonfig.h.in +18 -0
  62. data/ext/ffi_c/libffi/fficonfig.hw +57 -0
  63. data/ext/ffi_c/libffi/include/Makefile.in +21 -3
  64. data/ext/ffi_c/libffi/include/ffi.h.in +42 -14
  65. data/ext/ffi_c/libffi/include/ffi.h.vc +427 -0
  66. data/ext/ffi_c/libffi/include/ffi.h.vc64 +427 -0
  67. data/ext/ffi_c/libffi/include/ffi_common.h +9 -5
  68. data/ext/ffi_c/libffi/install-sh +364 -167
  69. data/ext/ffi_c/libffi/ltmain.sh +2599 -1369
  70. data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +176 -0
  71. data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +195 -0
  72. data/ext/ffi_c/libffi/m4/ax_check_compiler_flags.m4 +76 -0
  73. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +63 -0
  74. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +70 -0
  75. data/ext/ffi_c/libffi/m4/ax_enable_builddir.m4 +300 -0
  76. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +215 -0
  77. data/ext/ffi_c/libffi/m4/ax_gcc_x86_cpuid.m4 +79 -0
  78. data/ext/ffi_c/libffi/m4/libtool.m4 +1239 -768
  79. data/ext/ffi_c/libffi/m4/ltoptions.m4 +7 -6
  80. data/ext/ffi_c/libffi/m4/ltversion.m4 +6 -6
  81. data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +9 -3
  82. data/ext/ffi_c/libffi/man/Makefile.in +21 -3
  83. data/ext/ffi_c/libffi/mdate-sh +0 -0
  84. data/ext/ffi_c/libffi/missing +60 -44
  85. data/ext/ffi_c/libffi/msvcc.sh +197 -0
  86. data/ext/ffi_c/libffi/src/alpha/osf.S +39 -18
  87. data/ext/ffi_c/libffi/src/arm/ffi.c +443 -24
  88. data/ext/ffi_c/libffi/src/arm/ffitarget.h +17 -1
  89. data/ext/ffi_c/libffi/src/arm/gentramp.sh +118 -0
  90. data/ext/ffi_c/libffi/src/arm/sysv.S +206 -15
  91. data/ext/ffi_c/libffi/src/arm/trampoline.S +4450 -0
  92. data/ext/ffi_c/libffi/src/avr32/ffi.c +4 -2
  93. data/ext/ffi_c/libffi/src/avr32/ffitarget.h +2 -2
  94. data/ext/ffi_c/libffi/src/closures.c +17 -35
  95. data/ext/ffi_c/libffi/src/cris/ffi.c +1 -1
  96. data/ext/ffi_c/libffi/src/cris/ffitarget.h +2 -2
  97. data/ext/ffi_c/libffi/src/dlmalloc.c +66 -4
  98. data/ext/ffi_c/libffi/src/frv/ffitarget.h +2 -6
  99. data/ext/ffi_c/libffi/src/ia64/ffi.c +7 -5
  100. data/ext/ffi_c/libffi/src/ia64/ffitarget.h +2 -2
  101. data/ext/ffi_c/libffi/src/java_raw_api.c +1 -1
  102. data/ext/ffi_c/libffi/src/m32r/ffitarget.h +2 -2
  103. data/ext/ffi_c/libffi/src/m68k/ffi.c +10 -0
  104. data/ext/ffi_c/libffi/src/m68k/ffitarget.h +2 -2
  105. data/ext/ffi_c/libffi/src/m68k/sysv.S +36 -0
  106. data/ext/ffi_c/libffi/src/mips/ffi.c +12 -5
  107. data/ext/ffi_c/libffi/src/mips/ffitarget.h +18 -11
  108. data/ext/ffi_c/libffi/src/mips/n32.S +4 -4
  109. data/ext/ffi_c/libffi/src/moxie/eabi.S +128 -0
  110. data/ext/ffi_c/libffi/src/moxie/ffi.c +276 -0
  111. data/ext/ffi_c/libffi/src/pa/ffi.c +7 -4
  112. data/ext/ffi_c/libffi/src/pa/ffitarget.h +6 -5
  113. data/ext/ffi_c/libffi/src/powerpc/aix.S +5 -1
  114. data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +2 -0
  115. data/ext/ffi_c/libffi/src/powerpc/asm.h +1 -1
  116. data/ext/ffi_c/libffi/src/powerpc/darwin.S +215 -77
  117. data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +358 -100
  118. data/ext/ffi_c/libffi/src/powerpc/ffi.c +11 -5
  119. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +603 -172
  120. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +17 -4
  121. data/ext/ffi_c/libffi/src/prep_cif.c +16 -13
  122. data/ext/ffi_c/libffi/src/s390/ffitarget.h +4 -2
  123. data/ext/ffi_c/libffi/src/sh/ffitarget.h +2 -2
  124. data/ext/ffi_c/libffi/src/sh64/ffitarget.h +2 -2
  125. data/ext/ffi_c/libffi/src/sparc/ffi.c +55 -11
  126. data/ext/ffi_c/libffi/src/sparc/ffitarget.h +5 -3
  127. data/ext/ffi_c/libffi/src/x86/ffi.c +54 -92
  128. data/ext/ffi_c/libffi/src/x86/ffi64.c +17 -8
  129. data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -14
  130. data/ext/ffi_c/libffi/src/x86/sysv.S +40 -26
  131. data/ext/ffi_c/libffi/src/x86/unix64.S +4 -0
  132. data/ext/ffi_c/libffi/src/x86/win32.S +379 -191
  133. data/ext/ffi_c/libffi/src/x86/win64.S +15 -7
  134. data/ext/ffi_c/libffi/testsuite/Makefile.am +1 -1
  135. data/ext/ffi_c/libffi/testsuite/Makefile.in +22 -4
  136. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +350 -0
  137. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +1 -5
  138. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split.c +1 -1
  139. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c +1 -1
  140. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +1 -0
  141. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +1 -0
  142. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double_va.c +3 -0
  143. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble.c +2 -2
  144. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble_va.c +3 -0
  145. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer.c +1 -1
  146. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer_stack.c +1 -1
  147. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c +1 -0
  148. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_abi.c +2 -3
  149. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +2 -1
  150. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +36 -0
  151. data/ext/ffi_c/libffi/testsuite/libffi.call/huge_struct.c +17 -17
  152. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +1 -0
  153. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium2.c +1 -0
  154. data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +1 -1
  155. data/ext/ffi_c/libffi/testsuite/libffi.special/special.exp +1 -3
  156. data/ext/ffi_c/win32/stdint.h +199 -0
  157. data/gen/Rakefile +18 -2
  158. data/lib/1.8/ffi_c.so +0 -0
  159. data/lib/ffi.rb +13 -9
  160. data/lib/ffi/autopointer.rb +88 -26
  161. data/lib/ffi/enum.rb +42 -0
  162. data/lib/ffi/errno.rb +6 -1
  163. data/lib/ffi/ffi.rb +1 -0
  164. data/lib/ffi/io.rb +13 -2
  165. data/lib/ffi/library.rb +219 -24
  166. data/lib/ffi/memorypointer.rb +1 -33
  167. data/lib/ffi/platform.rb +21 -7
  168. data/lib/ffi/platform/arm-linux/types.conf +102 -0
  169. data/lib/ffi/platform/i386-freebsd/types.conf +152 -0
  170. data/lib/ffi/platform/i386-netbsd/types.conf +126 -0
  171. data/lib/ffi/platform/i486-gnu/types.conf +107 -0
  172. data/lib/ffi/platform/ia64-linux/types.conf +102 -0
  173. data/lib/ffi/platform/mips-linux/types.conf +102 -0
  174. data/lib/ffi/platform/mipsel-linux/types.conf +102 -0
  175. data/lib/ffi/platform/powerpc-linux/types.conf +100 -0
  176. data/lib/ffi/platform/s390-linux/types.conf +102 -0
  177. data/lib/ffi/platform/s390x-linux/types.conf +102 -0
  178. data/lib/ffi/platform/sparc-linux/types.conf +102 -0
  179. data/lib/ffi/platform/x86_64-freebsd/types.conf +126 -0
  180. data/lib/ffi/platform/x86_64-netbsd/types.conf +126 -0
  181. data/lib/ffi/pointer.rb +44 -0
  182. data/lib/ffi/struct.rb +2 -6
  183. data/lib/ffi/struct_layout_builder.rb +2 -1
  184. data/lib/ffi/tools/const_generator.rb +78 -26
  185. data/lib/ffi/tools/types_generator.rb +8 -1
  186. data/lib/ffi/types.rb +21 -1
  187. data/spec/ffi/async_callback_spec.rb +2 -2
  188. data/spec/ffi/bool_spec.rb +6 -6
  189. data/spec/ffi/buffer_spec.rb +23 -23
  190. data/spec/ffi/callback_spec.rb +101 -102
  191. data/spec/ffi/custom_type_spec.rb +20 -24
  192. data/spec/ffi/dup_spec.rb +7 -7
  193. data/spec/ffi/enum_spec.rb +127 -127
  194. data/spec/ffi/errno_spec.rb +2 -2
  195. data/spec/ffi/ffi_spec.rb +3 -3
  196. data/spec/ffi/function_spec.rb +10 -10
  197. data/spec/ffi/library_spec.rb +30 -12
  198. data/spec/ffi/managed_struct_spec.rb +4 -4
  199. data/spec/ffi/number_spec.rb +40 -40
  200. data/spec/ffi/pointer_spec.rb +21 -24
  201. data/spec/ffi/rbx/memory_pointer_spec.rb +17 -15
  202. data/spec/ffi/rbx/struct_spec.rb +2 -2
  203. data/spec/ffi/spec_helper.rb +1 -1
  204. data/spec/ffi/string_spec.rb +9 -9
  205. data/spec/ffi/strptr_spec.rb +3 -3
  206. data/spec/ffi/struct_callback_spec.rb +7 -7
  207. data/spec/ffi/struct_initialize_spec.rb +2 -2
  208. data/spec/ffi/struct_packed_spec.rb +6 -6
  209. data/spec/ffi/struct_spec.rb +94 -84
  210. data/spec/ffi/typedef_spec.rb +15 -4
  211. data/spec/ffi/union_spec.rb +3 -3
  212. data/spec/ffi/variadic_spec.rb +17 -14
  213. data/tasks/extension.rake +0 -1
  214. data/tasks/gem.rake +0 -1
  215. data/tasks/rdoc.rake +1 -1
  216. data/tasks/yard.rake +11 -0
  217. metadata +50 -11
  218. data/lib/1.9/ffi_c.so +0 -0
@@ -1,9 +1,11 @@
1
1
  /* -----------------------------------------------------------------------
2
- ffi.c - (c) 2003-2004 Randolph Chung <tausq@debian.org>
2
+ ffi.c - (c) 2011 Anthony Green
3
3
  (c) 2008 Red Hat, Inc.
4
-
4
+ (c) 2006 Free Software Foundation, Inc.
5
+ (c) 2003-2004 Randolph Chung <tausq@debian.org>
6
+
5
7
  HPPA Foreign Function Interface
6
- HP-UX PA ABI support (c) 2006 Free Software Foundation, Inc.
8
+ HP-UX PA ABI support
7
9
 
8
10
  Permission is hereby granted, free of charge, to any person obtaining
9
11
  a copy of this software and associated documentation files (the
@@ -633,7 +635,8 @@ ffi_prep_closure_loc (ffi_closure* closure,
633
635
  UINT32 *tmp;
634
636
  #endif
635
637
 
636
- FFI_ASSERT (cif->abi == FFI_PA32);
638
+ if (cif->abi != FFI_PA32)
639
+ return FFI_BAD_ABI;
637
640
 
638
641
  /* Make a small trampoline that will branch to our
639
642
  handler function. Use PC-relative addressing. */
@@ -38,21 +38,22 @@ typedef enum ffi_abi {
38
38
 
39
39
  #ifdef PA_LINUX
40
40
  FFI_PA32,
41
- FFI_DEFAULT_ABI = FFI_PA32,
41
+ FFI_LAST_ABI,
42
+ FFI_DEFAULT_ABI = FFI_PA32
42
43
  #endif
43
44
 
44
45
  #ifdef PA_HPUX
45
46
  FFI_PA32,
46
- FFI_DEFAULT_ABI = FFI_PA32,
47
+ FFI_LAST_ABI,
48
+ FFI_DEFAULT_ABI = FFI_PA32
47
49
  #endif
48
50
 
49
51
  #ifdef PA64_HPUX
50
52
  #error "PA64_HPUX FFI is not yet implemented"
51
53
  FFI_PA64,
52
- FFI_DEFAULT_ABI = FFI_PA64,
54
+ FFI_LAST_ABI,
55
+ FFI_DEFAULT_ABI = FFI_PA64
53
56
  #endif
54
-
55
- FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
56
57
  } ffi_abi;
57
58
  #endif
58
59
 
@@ -1,5 +1,5 @@
1
1
  /* -----------------------------------------------------------------------
2
- aix.S - Copyright (c) 2002,2009 Free Software Foundation, Inc.
2
+ aix.S - Copyright (c) 2002, 2009 Free Software Foundation, Inc.
3
3
  based on darwin.S by John Hornkvist
4
4
 
5
5
  PowerPC Assembly glue.
@@ -79,6 +79,8 @@
79
79
  .set f20,20
80
80
  .set f21,21
81
81
 
82
+ .extern .ffi_prep_args
83
+
82
84
  #define LIBFFI_ASM
83
85
  #include <fficonfig.h>
84
86
  #include <ffi.h>
@@ -125,6 +127,7 @@ ffi_call_AIX:
125
127
  /* Call ffi_prep_args. */
126
128
  mr r4, r1
127
129
  bl .ffi_prep_args
130
+ nop
128
131
 
129
132
  /* Now do the call. */
130
133
  ld r0, 0(r29)
@@ -226,6 +229,7 @@ L(float_return_value):
226
229
  /* Call ffi_prep_args. */
227
230
  mr r4, r1
228
231
  bl .ffi_prep_args
232
+ nop
229
233
 
230
234
  /* Now do the call. */
231
235
  lwz r0, 0(r29)
@@ -79,6 +79,8 @@
79
79
  .set f20,20
80
80
  .set f21,21
81
81
 
82
+ .extern .ffi_closure_helper_DARWIN
83
+
82
84
  #define LIBFFI_ASM
83
85
  #define JUMPTARGET(name) name
84
86
  #define L(x) x
@@ -42,7 +42,7 @@
42
42
 
43
43
  /* If compiled for profiling, call `_mcount' at the start of each function. */
44
44
  #ifdef PROF
45
- /* The mcount code relies on a the return address being on the stack
45
+ /* The mcount code relies on the return address being on the stack
46
46
  to locate our caller and so it can restore it; so store one just
47
47
  for its benefit. */
48
48
  #ifdef PIC
@@ -1,6 +1,6 @@
1
1
  /* -----------------------------------------------------------------------
2
2
  darwin.S - Copyright (c) 2000 John Hornkvist
3
- Copyright (c) 2004 Free Software Foundation, Inc.
3
+ Copyright (c) 2004, 2010 Free Software Foundation, Inc.
4
4
 
5
5
  PowerPC Assembly glue.
6
6
 
@@ -24,51 +24,92 @@
24
24
  OTHER DEALINGS IN THE SOFTWARE.
25
25
  ----------------------------------------------------------------------- */
26
26
 
27
+ #define LIBFFI_ASM
27
28
  #if defined(__ppc64__)
28
29
  #define MODE_CHOICE(x, y) y
29
30
  #else
30
31
  #define MODE_CHOICE(x, y) x
31
32
  #endif
32
33
 
33
- #define g_long MODE_CHOICE(long, quad) /* usage is ".g_long" */
34
+ #define machine_choice MODE_CHOICE(ppc7400,ppc64)
34
35
 
35
- #define LOG2_GPR_BYTES MODE_CHOICE(2,3) /* log2(GPR_BYTES) */
36
+ ; Define some pseudo-opcodes for size-independent load & store of GPRs ...
37
+ #define lgu MODE_CHOICE(lwzu, ldu)
38
+ #define lg MODE_CHOICE(lwz,ld)
39
+ #define sg MODE_CHOICE(stw,std)
40
+ #define sgu MODE_CHOICE(stwu,stdu)
41
+ #define sgux MODE_CHOICE(stwux,stdux)
42
+
43
+ ; ... and the size of GPRs and their storage indicator.
44
+ #define GPR_BYTES MODE_CHOICE(4,8)
45
+ #define LOG2_GPR_BYTES MODE_CHOICE(2,3) /* log2(GPR_BYTES) */
46
+ #define g_long MODE_CHOICE(long, quad) /* usage is ".g_long" */
47
+
48
+ ; From the ABI doc: "Mac OS X ABI Function Call Guide" Version 2009-02-04.
49
+ #define LINKAGE_SIZE MODE_CHOICE(24,48)
50
+ #define PARAM_AREA MODE_CHOICE(32,64)
51
+ #define SAVED_LR_OFFSET MODE_CHOICE(8,16) /* save position for lr */
52
+
53
+ /* If there is any FP stuff we make space for all of the regs. */
54
+ #define SAVED_FPR_COUNT 13
55
+ #define FPR_SIZE 8
56
+ #define RESULT_BYTES 16
57
+
58
+ /* This should be kept in step with the same value in ffi_darwin.c. */
59
+ #define ASM_NEEDS_REGISTERS 4
60
+ #define SAVE_REGS_SIZE (ASM_NEEDS_REGISTERS * GPR_BYTES)
36
61
 
37
- #define LIBFFI_ASM
38
62
  #include <fficonfig.h>
39
63
  #include <ffi.h>
64
+
40
65
  #define JUMPTARGET(name) name
41
66
  #define L(x) x
42
- .text
43
- .align 2
44
- .globl _ffi_prep_args
45
67
 
46
- .text
68
+ .text
47
69
  .align 2
48
- .globl _ffi_call_DARWIN
49
- .text
70
+ .globl _ffi_prep_args
71
+
50
72
  .align 2
73
+ .globl _ffi_call_DARWIN
74
+
75
+ /* We arrive here with:
76
+ r3 = ptr to extended cif.
77
+ r4 = -bytes.
78
+ r5 = cif flags.
79
+ r6 = ptr to return value.
80
+ r7 = fn pointer (user func).
81
+ r8 = fn pointer (ffi_prep_args).
82
+ r9 = ffi_type* for the ret val. */
83
+
51
84
  _ffi_call_DARWIN:
52
- LFB0:
85
+ Lstartcode:
53
86
  mr r12,r8 /* We only need r12 until the call,
54
- so it doesn't have to be saved. */
87
+ so it does not have to be saved. */
55
88
  LFB1:
56
89
  /* Save the old stack pointer as AP. */
57
90
  mr r8,r1
58
91
  LCFI0:
92
+
93
+ /* Save the retval type in parents frame. */
94
+ sg r9,(LINKAGE_SIZE+6*GPR_BYTES)(r8)
95
+
59
96
  /* Allocate the stack space we need. */
60
- stwux r1,r1,r4
97
+ sgux r1,r1,r4
61
98
 
62
99
  /* Save registers we use. */
63
100
  mflr r9
101
+ sg r9,SAVED_LR_OFFSET(r8)
102
+
103
+ sg r28,-(4 * GPR_BYTES)(r8)
104
+ sg r29,-(3 * GPR_BYTES)(r8)
105
+ sg r30,-(2 * GPR_BYTES)(r8)
106
+ sg r31,-( GPR_BYTES)(r8)
64
107
 
65
- stw r28,-16(r8)
66
- stw r29,-12(r8)
67
- stw r30,-8(r8)
68
- stw r31,-4(r8)
108
+ #if !defined(POWERPC_DARWIN)
109
+ /* The TOC slot is reserved in the Darwin ABI and r2 is volatile. */
110
+ sg r2,(5 * GPR_BYTES)(r1)
111
+ #endif
69
112
 
70
- stw r9,8(r8)
71
- stw r2,20(r1)
72
113
  LCFI1:
73
114
 
74
115
  /* Save arguments over call. */
@@ -77,14 +118,17 @@ LCFI1:
77
118
  mr r29,r7 /* function address, */
78
119
  mr r28,r8 /* our AP. */
79
120
  LCFI2:
80
- /* Call ffi_prep_args. */
121
+ /* Call ffi_prep_args. r3 = extended cif, r4 = stack ptr copy. */
81
122
  mr r4,r1
82
123
  li r9,0
83
124
 
84
125
  mtctr r12 /* r12 holds address of _ffi_prep_args. */
85
126
  bctrl
86
- lwz r2,20(r1)
87
127
 
128
+ #if !defined(POWERPC_DARWIN)
129
+ /* The TOC slot is reserved in the Darwin ABI and r2 is volatile. */
130
+ lg r2,(5 * GPR_BYTES)(r1)
131
+ #endif
88
132
  /* Now do the call.
89
133
  Set up cr1 with bits 4-7 of the flags. */
90
134
  mtcrf 0x40,r31
@@ -92,71 +136,130 @@ LCFI2:
92
136
  mtctr r29
93
137
  /* Load all those argument registers.
94
138
  We have set up a nice stack frame, just load it into registers. */
95
- lwz r3,20+(1*4)(r1)
96
- lwz r4,20+(2*4)(r1)
97
- lwz r5,20+(3*4)(r1)
98
- lwz r6,20+(4*4)(r1)
139
+ lg r3, (LINKAGE_SIZE )(r1)
140
+ lg r4, (LINKAGE_SIZE + GPR_BYTES)(r1)
141
+ lg r5, (LINKAGE_SIZE + 2 * GPR_BYTES)(r1)
142
+ lg r6, (LINKAGE_SIZE + 3 * GPR_BYTES)(r1)
99
143
  nop
100
- lwz r7,20+(5*4)(r1)
101
- lwz r8,20+(6*4)(r1)
102
- lwz r9,20+(7*4)(r1)
103
- lwz r10,20+(8*4)(r1)
144
+ lg r7, (LINKAGE_SIZE + 4 * GPR_BYTES)(r1)
145
+ lg r8, (LINKAGE_SIZE + 5 * GPR_BYTES)(r1)
146
+ lg r9, (LINKAGE_SIZE + 6 * GPR_BYTES)(r1)
147
+ lg r10,(LINKAGE_SIZE + 7 * GPR_BYTES)(r1)
104
148
 
105
149
  L1:
106
- /* Load all the FP registers. */
150
+ /* ... Load all the FP registers. */
107
151
  bf 6,L2 /* No floats to load. */
108
- lfd f1,-16-(13*8)(r28)
109
- lfd f2,-16-(12*8)(r28)
110
- lfd f3,-16-(11*8)(r28)
111
- lfd f4,-16-(10*8)(r28)
152
+ lfd f1, -SAVE_REGS_SIZE-(13*FPR_SIZE)(r28)
153
+ lfd f2, -SAVE_REGS_SIZE-(12*FPR_SIZE)(r28)
154
+ lfd f3, -SAVE_REGS_SIZE-(11*FPR_SIZE)(r28)
155
+ lfd f4, -SAVE_REGS_SIZE-(10*FPR_SIZE)(r28)
112
156
  nop
113
- lfd f5,-16-(9*8)(r28)
114
- lfd f6,-16-(8*8)(r28)
115
- lfd f7,-16-(7*8)(r28)
116
- lfd f8,-16-(6*8)(r28)
157
+ lfd f5, -SAVE_REGS_SIZE-( 9*FPR_SIZE)(r28)
158
+ lfd f6, -SAVE_REGS_SIZE-( 8*FPR_SIZE)(r28)
159
+ lfd f7, -SAVE_REGS_SIZE-( 7*FPR_SIZE)(r28)
160
+ lfd f8, -SAVE_REGS_SIZE-( 6*FPR_SIZE)(r28)
117
161
  nop
118
- lfd f9,-16-(5*8)(r28)
119
- lfd f10,-16-(4*8)(r28)
120
- lfd f11,-16-(3*8)(r28)
121
- lfd f12,-16-(2*8)(r28)
162
+ lfd f9, -SAVE_REGS_SIZE-( 5*FPR_SIZE)(r28)
163
+ lfd f10,-SAVE_REGS_SIZE-( 4*FPR_SIZE)(r28)
164
+ lfd f11,-SAVE_REGS_SIZE-( 3*FPR_SIZE)(r28)
165
+ lfd f12,-SAVE_REGS_SIZE-( 2*FPR_SIZE)(r28)
122
166
  nop
123
- lfd f13,-16-(1*8)(r28)
167
+ lfd f13,-SAVE_REGS_SIZE-( 1*FPR_SIZE)(r28)
124
168
 
125
169
  L2:
126
170
  mr r12,r29 /* Put the target address in r12 as specified. */
127
171
  mtctr r12
128
172
  nop
129
173
  nop
174
+
130
175
  /* Make the call. */
131
176
  bctrl
132
177
 
133
178
  /* Now, deal with the return value. */
134
- mtcrf 0x01,r31
135
179
 
136
- bt 30,L(done_return_value)
137
- bt 29,L(fp_return_value)
138
- stw r3,0(r30)
139
- bf 28,L(done_return_value)
140
- stw r4,4(r30)
180
+ /* m64 structure returns can occupy the same set of registers as
181
+ would be used to pass such a structure as arg0 - so take care
182
+ not to step on any possibly hot regs. */
141
183
 
142
- /* Fall through. */
184
+ /* Get the flags.. */
185
+ mtcrf 0x03,r31 ; we need c6 & cr7 now.
186
+ ; FLAG_RETURNS_NOTHING also covers struct ret-by-ref.
187
+ bt 30,L(done_return_value) ; FLAG_RETURNS_NOTHING
188
+ bf 27,L(scalar_return_value) ; not FLAG_RETURNS_STRUCT
189
+
190
+ /* OK, so we have a struct. */
191
+ #if defined(__ppc64__)
192
+ bt 31,L(maybe_return_128) ; FLAG_RETURNS_128BITS, special case
143
193
 
144
- L(done_return_value):
145
- /* Restore the registers we used and return. */
146
- lwz r9,8(r28)
147
- lwz r31,-4(r28)
148
- mtlr r9
149
- lwz r30,-8(r28)
150
- lwz r29,-12(r28)
151
- lwz r28,-16(r28)
152
- lwz r1,0(r1)
153
- blr
194
+ /* OK, we have to map the return back to a mem struct.
195
+ We are about to trample the parents param area, so recover the
196
+ return type. r29 is free, since the call is done. */
197
+ lg r29,(LINKAGE_SIZE + 6 * GPR_BYTES)(r28)
198
+
199
+ sg r3, (LINKAGE_SIZE )(r28)
200
+ sg r4, (LINKAGE_SIZE + GPR_BYTES)(r28)
201
+ sg r5, (LINKAGE_SIZE + 2 * GPR_BYTES)(r28)
202
+ sg r6, (LINKAGE_SIZE + 3 * GPR_BYTES)(r28)
203
+ nop
204
+ sg r7, (LINKAGE_SIZE + 4 * GPR_BYTES)(r28)
205
+ sg r8, (LINKAGE_SIZE + 5 * GPR_BYTES)(r28)
206
+ sg r9, (LINKAGE_SIZE + 6 * GPR_BYTES)(r28)
207
+ sg r10,(LINKAGE_SIZE + 7 * GPR_BYTES)(r28)
208
+ /* OK, so do the block move - we trust that memcpy will not trample
209
+ the fprs... */
210
+ mr r3,r30 ; dest
211
+ addi r4,r28,LINKAGE_SIZE ; source
212
+ /* The size is a size_t, should be long. */
213
+ lg r5,0(r29)
214
+ /* Figure out small structs */
215
+ cmpi 0,r5,4
216
+ bgt L3 ; 1, 2 and 4 bytes have special rules.
217
+ cmpi 0,r5,3
218
+ beq L3 ; not 3
219
+ addi r4,r4,8
220
+ subf r4,r5,r4
221
+ L3:
222
+ bl _memcpy
223
+
224
+ /* ... do we need the FP registers? - recover the flags.. */
225
+ mtcrf 0x03,r31 ; we need c6 & cr7 now.
226
+ bf 29,L(done_return_value) /* No floats in the struct. */
227
+ stfd f1, -SAVE_REGS_SIZE-(13*FPR_SIZE)(r28)
228
+ stfd f2, -SAVE_REGS_SIZE-(12*FPR_SIZE)(r28)
229
+ stfd f3, -SAVE_REGS_SIZE-(11*FPR_SIZE)(r28)
230
+ stfd f4, -SAVE_REGS_SIZE-(10*FPR_SIZE)(r28)
231
+ nop
232
+ stfd f5, -SAVE_REGS_SIZE-( 9*FPR_SIZE)(r28)
233
+ stfd f6, -SAVE_REGS_SIZE-( 8*FPR_SIZE)(r28)
234
+ stfd f7, -SAVE_REGS_SIZE-( 7*FPR_SIZE)(r28)
235
+ stfd f8, -SAVE_REGS_SIZE-( 6*FPR_SIZE)(r28)
236
+ nop
237
+ stfd f9, -SAVE_REGS_SIZE-( 5*FPR_SIZE)(r28)
238
+ stfd f10,-SAVE_REGS_SIZE-( 4*FPR_SIZE)(r28)
239
+ stfd f11,-SAVE_REGS_SIZE-( 3*FPR_SIZE)(r28)
240
+ stfd f12,-SAVE_REGS_SIZE-( 2*FPR_SIZE)(r28)
241
+ nop
242
+ stfd f13,-SAVE_REGS_SIZE-( 1*FPR_SIZE)(r28)
243
+
244
+ mr r3,r29 ; ffi_type *
245
+ mr r4,r30 ; dest
246
+ addi r5,r28,-SAVE_REGS_SIZE-(13*FPR_SIZE) ; fprs
247
+ xor r6,r6,r6
248
+ sg r6,(LINKAGE_SIZE + 7 * GPR_BYTES)(r28)
249
+ addi r6,r28,(LINKAGE_SIZE + 7 * GPR_BYTES) ; point to a zeroed counter.
250
+ bl _darwin64_struct_floats_to_mem
251
+
252
+ b L(done_return_value)
253
+ #else
254
+ stw r3,0(r30) ; m32 the only struct return in reg is 4 bytes.
255
+ #endif
256
+ b L(done_return_value)
154
257
 
155
258
  L(fp_return_value):
156
259
  /* Do we have long double to store? */
157
- bf 31,L(fd_return_value)
260
+ bf 31,L(fd_return_value) ; FLAG_RETURNS_128BITS
158
261
  stfd f1,0(r30)
159
- stfd f2,8(r30)
262
+ stfd f2,FPR_SIZE(r30)
160
263
  b L(done_return_value)
161
264
 
162
265
  L(fd_return_value):
@@ -170,21 +273,57 @@ L(float_return_value):
170
273
  stfs f1,0(r30)
171
274
  b L(done_return_value)
172
275
 
276
+ L(scalar_return_value):
277
+ bt 29,L(fp_return_value) ; FLAG_RETURNS_FP
278
+ ; ffi_arg is defined as unsigned long.
279
+ sg r3,0(r30) ; Save the reg.
280
+ bf 28,L(done_return_value) ; not FLAG_RETURNS_64BITS
281
+
282
+ #if defined(__ppc64__)
283
+ L(maybe_return_128):
284
+ std r3,0(r30)
285
+ bf 31,L(done_return_value) ; not FLAG_RETURNS_128BITS
286
+ std r4,8(r30)
287
+ #else
288
+ stw r4,4(r30)
289
+ #endif
290
+
291
+ /* Fall through. */
292
+ /* We want this at the end to simplify eh epilog computation. */
293
+
294
+ L(done_return_value):
295
+ /* Restore the registers we used and return. */
296
+ lg r29,SAVED_LR_OFFSET(r28)
297
+ ; epilog
298
+ lg r31,-(1 * GPR_BYTES)(r28)
299
+ mtlr r29
300
+ lg r30,-(2 * GPR_BYTES)(r28)
301
+ lg r29,-(3 * GPR_BYTES)(r28)
302
+ lg r28,-(4 * GPR_BYTES)(r28)
303
+ lg r1,0(r1)
304
+ blr
173
305
  LFE1:
306
+ .align 1
174
307
  /* END(_ffi_call_DARWIN) */
175
308
 
176
309
  /* Provide a null definition of _ffi_call_AIX. */
177
- .text
178
- .align 2
179
- .globl _ffi_call_AIX
180
- .text
310
+ .text
311
+ .globl _ffi_call_AIX
181
312
  .align 2
182
313
  _ffi_call_AIX:
183
314
  blr
184
315
  /* END(_ffi_call_AIX) */
185
316
 
186
- .data
187
- .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms
317
+ /* EH stuff. */
318
+
319
+ #define EH_DATA_ALIGN_FACT MODE_CHOICE(0x7c,0x78)
320
+
321
+ .static_data
322
+ .align LOG2_GPR_BYTES
323
+ LLFB0$non_lazy_ptr:
324
+ .g_long Lstartcode
325
+
326
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
188
327
  EH_frame1:
189
328
  .set L$set$0,LECIE1-LSCIE1
190
329
  .long L$set$0 ; Length of Common Information Entry
@@ -193,16 +332,17 @@ LSCIE1:
193
332
  .byte 0x1 ; CIE Version
194
333
  .ascii "zR\0" ; CIE Augmentation
195
334
  .byte 0x1 ; uleb128 0x1; CIE Code Alignment Factor
196
- .byte 0x7c ; sleb128 -4; CIE Data Alignment Factor
335
+ .byte EH_DATA_ALIGN_FACT ; sleb128 -4; CIE Data Alignment Factor
197
336
  .byte 0x41 ; CIE RA Column
198
337
  .byte 0x1 ; uleb128 0x1; Augmentation size
199
- .byte 0x90 ; FDE Encoding (indirect pcrel)
338
+ .byte 0x10 ; FDE Encoding (indirect pcrel)
200
339
  .byte 0xc ; DW_CFA_def_cfa
201
340
  .byte 0x1 ; uleb128 0x1
202
341
  .byte 0x0 ; uleb128 0x0
203
342
  .align LOG2_GPR_BYTES
204
343
  LECIE1:
205
- .globl _ffi_call_DARWIN.eh
344
+
345
+ .globl _ffi_call_DARWIN.eh
206
346
  _ffi_call_DARWIN.eh:
207
347
  LSFDE1:
208
348
  .set L$set$1,LEFDE1-LASFDE1
@@ -210,11 +350,11 @@ LSFDE1:
210
350
  LASFDE1:
211
351
  .long LASFDE1-EH_frame1 ; FDE CIE offset
212
352
  .g_long LLFB0$non_lazy_ptr-. ; FDE initial location
213
- .set L$set$3,LFE1-LFB0
353
+ .set L$set$3,LFE1-Lstartcode
214
354
  .g_long L$set$3 ; FDE address range
215
355
  .byte 0x0 ; uleb128 0x0; Augmentation size
216
356
  .byte 0x4 ; DW_CFA_advance_loc4
217
- .set L$set$4,LCFI0-LFB1
357
+ .set L$set$4,LCFI0-Lstartcode
218
358
  .long L$set$4
219
359
  .byte 0xd ; DW_CFA_def_cfa_register
220
360
  .byte 0x08 ; uleb128 0x08
@@ -239,7 +379,5 @@ LASFDE1:
239
379
  .byte 0x1c ; uleb128 0x1c
240
380
  .align LOG2_GPR_BYTES
241
381
  LEFDE1:
242
- .data
243
- .align LOG2_GPR_BYTES
244
- LLFB0$non_lazy_ptr:
245
- .g_long LFB0
382
+ .align 1
383
+