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,7 +1,8 @@
1
1
  /* -----------------------------------------------------------------------
2
- ffi64.c - Copyright (c) 2002, 2007 Bo Thorsen <bo@suse.de>
3
- Copyright (c) 2008 Red Hat, Inc.
4
-
2
+ ffi64.c - Copyright (c) 20011 Anthony Green
3
+ Copyright (c) 2008, 2010 Red Hat, Inc.
4
+ Copyright (c) 2002, 2007 Bo Thorsen <bo@suse.de>
5
+
5
6
  x86-64 Foreign Function Interface
6
7
 
7
8
  Permission is hereby granted, free of charge, to any person obtaining
@@ -50,9 +51,10 @@ extern void ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags,
50
51
  gcc/config/i386/i386.c. Do *not* change one without the other. */
51
52
 
52
53
  /* Register class used for passing given 64bit part of the argument.
53
- These represent classes as documented by the PS ABI, with the exception
54
- of SSESF, SSEDF classes, that are basically SSE class, just gcc will
55
- use SF or DFmode move instead of DImode to avoid reformating penalties.
54
+ These represent classes as documented by the PS ABI, with the
55
+ exception of SSESF, SSEDF classes, that are basically SSE class,
56
+ just gcc will use SF or DFmode move instead of DImode to avoid
57
+ reformatting penalties.
56
58
 
57
59
  Similary we play games with INTEGERSI_CLASS to use cheaper SImode moves
58
60
  whenever possible (upper half does contain padding). */
@@ -377,7 +379,7 @@ ffi_prep_cif_machdep (ffi_cif *cif)
377
379
  if (align < 8)
378
380
  align = 8;
379
381
 
380
- bytes = ALIGN(bytes, align);
382
+ bytes = ALIGN (bytes, align);
381
383
  bytes += cif->arg_types[i]->size;
382
384
  }
383
385
  else
@@ -389,7 +391,7 @@ ffi_prep_cif_machdep (ffi_cif *cif)
389
391
  if (ssecount)
390
392
  flags |= 1 << 11;
391
393
  cif->flags = flags;
392
- cif->bytes = bytes;
394
+ cif->bytes = ALIGN (bytes, 8);
393
395
 
394
396
  return FFI_OK;
395
397
  }
@@ -497,6 +499,13 @@ ffi_prep_closure_loc (ffi_closure* closure,
497
499
  {
498
500
  volatile unsigned short *tramp;
499
501
 
502
+ /* Sanity check on the cif ABI. */
503
+ {
504
+ int abi = cif->abi;
505
+ if (UNLIKELY (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI)))
506
+ return FFI_BAD_ABI;
507
+ }
508
+
500
509
  tramp = (volatile unsigned short *) &closure->tramp[0];
501
510
 
502
511
  tramp[0] = 0xbb49; /* mov <code>, %r11 */
@@ -1,5 +1,5 @@
1
1
  /* -----------------------------------------------------------------*-C-*-
2
- ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc.
2
+ ffitarget.h - Copyright (c) 1996-2003, 2010 Red Hat, Inc.
3
3
  Copyright (C) 2008 Free Software Foundation, Inc.
4
4
 
5
5
  Target configuration macros for x86 and x86-64.
@@ -31,6 +31,9 @@
31
31
 
32
32
  /* ---- System specific configurations ----------------------------------- */
33
33
 
34
+ /* For code common to all platforms on x86 and x86_64. */
35
+ #define X86_ANY
36
+
34
37
  #if defined (X86_64) && defined (__i386__)
35
38
  #undef X86_64
36
39
  #define X86
@@ -38,7 +41,7 @@
38
41
 
39
42
  #ifdef X86_WIN64
40
43
  #define FFI_SIZEOF_ARG 8
41
- #define USE_BUILTIN_FFS 0 // not yet implemented in mingw-64
44
+ #define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */
42
45
  #endif
43
46
 
44
47
  /* ---- Generic type definitions ----------------------------------------- */
@@ -64,28 +67,26 @@ typedef enum ffi_abi {
64
67
  #ifdef X86_WIN32
65
68
  FFI_SYSV,
66
69
  FFI_STDCALL,
70
+ FFI_LAST_ABI,
67
71
  /* TODO: Add fastcall support for the sake of completeness */
68
- FFI_DEFAULT_ABI = FFI_SYSV,
69
- #endif
72
+ FFI_DEFAULT_ABI = FFI_SYSV
70
73
 
71
- #ifdef X86_WIN64
74
+ #elif defined(X86_WIN64)
72
75
  FFI_WIN64,
73
- FFI_DEFAULT_ABI = FFI_WIN64,
74
- #else
76
+ FFI_LAST_ABI,
77
+ FFI_DEFAULT_ABI = FFI_WIN64
75
78
 
79
+ #else
76
80
  /* ---- Intel x86 and AMD x86-64 - */
77
- #if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__))
78
81
  FFI_SYSV,
79
82
  FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */
80
- #ifdef __i386__
81
- FFI_DEFAULT_ABI = FFI_SYSV,
83
+ FFI_LAST_ABI,
84
+ #if defined(__i386__) || defined(__i386)
85
+ FFI_DEFAULT_ABI = FFI_SYSV
82
86
  #else
83
- FFI_DEFAULT_ABI = FFI_UNIX64,
87
+ FFI_DEFAULT_ABI = FFI_UNIX64
84
88
  #endif
85
89
  #endif
86
- #endif /* X86_WIN64 */
87
-
88
- FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
89
90
  } ffi_abi;
90
91
  #endif
91
92
 
@@ -1,5 +1,5 @@
1
1
  /* -----------------------------------------------------------------------
2
- sysv.S - Copyright (c) 1996, 1998, 2001-2003, 2005, 2008 Red Hat, Inc.
2
+ sysv.S - Copyright (c) 1996, 1998, 2001-2003, 2005, 2008, 2010 Red Hat, Inc.
3
3
 
4
4
  X86 Foreign Function Interface
5
5
 
@@ -48,6 +48,9 @@ ffi_call_SYSV:
48
48
  movl 16(%ebp),%ecx
49
49
  subl %ecx,%esp
50
50
 
51
+ /* Align the stack pointer to 16-bytes */
52
+ andl $0xfffffff0, %esp
53
+
51
54
  movl %esp,%eax
52
55
 
53
56
  /* Place all of the ffi_prep_args in position */
@@ -325,23 +328,52 @@ ffi_closure_raw_SYSV:
325
328
  .size ffi_closure_raw_SYSV, .-ffi_closure_raw_SYSV
326
329
  #endif
327
330
 
331
+ #if defined __PIC__
332
+ # if defined __sun__ && defined __svr4__
333
+ /* 32-bit Solaris 2/x86 uses datarel encoding for PIC. GNU ld before 2.22
334
+ doesn't correctly sort .eh_frame_hdr with mixed encodings, so match this. */
335
+ # define FDE_ENCODING 0x30 /* datarel */
336
+ # define FDE_ENCODE(X) X@GOTOFF
337
+ # else
338
+ # define FDE_ENCODING 0x1b /* pcrel sdata4 */
339
+ # if defined HAVE_AS_X86_PCREL
340
+ # define FDE_ENCODE(X) X-.
341
+ # else
342
+ # define FDE_ENCODE(X) X@rel
343
+ # endif
344
+ # endif
345
+ #else
346
+ # define FDE_ENCODING 0 /* absolute */
347
+ # define FDE_ENCODE(X) X
348
+ #endif
349
+
328
350
  .section .eh_frame,EH_FRAME_FLAGS,@progbits
329
351
  .Lframe1:
330
352
  .long .LECIE1-.LSCIE1 /* Length of Common Information Entry */
331
353
  .LSCIE1:
332
354
  .long 0x0 /* CIE Identifier Tag */
333
355
  .byte 0x1 /* CIE Version */
356
+ #ifdef HAVE_AS_ASCII_PSEUDO_OP
334
357
  #ifdef __PIC__
335
358
  .ascii "zR\0" /* CIE Augmentation */
336
359
  #else
337
360
  .ascii "\0" /* CIE Augmentation */
361
+ #endif
362
+ #elif defined HAVE_AS_STRING_PSEUDO_OP
363
+ #ifdef __PIC__
364
+ .string "zR" /* CIE Augmentation */
365
+ #else
366
+ .string "" /* CIE Augmentation */
367
+ #endif
368
+ #else
369
+ #error missing .ascii/.string
338
370
  #endif
339
371
  .byte 0x1 /* .uleb128 0x1; CIE Code Alignment Factor */
340
372
  .byte 0x7c /* .sleb128 -4; CIE Data Alignment Factor */
341
373
  .byte 0x8 /* CIE RA Column */
342
374
  #ifdef __PIC__
343
375
  .byte 0x1 /* .uleb128 0x1; Augmentation size */
344
- .byte 0x1b /* FDE Encoding (pcrel sdata4) */
376
+ .byte FDE_ENCODING
345
377
  #endif
346
378
  .byte 0xc /* DW_CFA_def_cfa */
347
379
  .byte 0x4 /* .uleb128 0x4 */
@@ -354,14 +386,8 @@ ffi_closure_raw_SYSV:
354
386
  .long .LEFDE1-.LASFDE1 /* FDE Length */
355
387
  .LASFDE1:
356
388
  .long .LASFDE1-.Lframe1 /* FDE CIE offset */
357
- #if defined __PIC__ && defined HAVE_AS_X86_PCREL
358
- .long .LFB1-. /* FDE initial location */
359
- #elif defined __PIC__
360
- .long .LFB1@rel
361
- #else
362
- .long .LFB1
363
- #endif
364
- .long .LFE1-.LFB1 /* FDE address range */
389
+ .long FDE_ENCODE(.LFB1) /* FDE initial location */
390
+ .long .LFE1-.LFB1 /* FDE address range */
365
391
  #ifdef __PIC__
366
392
  .byte 0x0 /* .uleb128 0x0; Augmentation size */
367
393
  #endif
@@ -381,14 +407,8 @@ ffi_closure_raw_SYSV:
381
407
  .long .LEFDE2-.LASFDE2 /* FDE Length */
382
408
  .LASFDE2:
383
409
  .long .LASFDE2-.Lframe1 /* FDE CIE offset */
384
- #if defined __PIC__ && defined HAVE_AS_X86_PCREL
385
- .long .LFB2-. /* FDE initial location */
386
- #elif defined __PIC__
387
- .long .LFB2@rel
388
- #else
389
- .long .LFB2
390
- #endif
391
- .long .LFE2-.LFB2 /* FDE address range */
410
+ .long FDE_ENCODE(.LFB2) /* FDE initial location */
411
+ .long .LFE2-.LFB2 /* FDE address range */
392
412
  #ifdef __PIC__
393
413
  .byte 0x0 /* .uleb128 0x0; Augmentation size */
394
414
  #endif
@@ -417,14 +437,8 @@ ffi_closure_raw_SYSV:
417
437
  .long .LEFDE3-.LASFDE3 /* FDE Length */
418
438
  .LASFDE3:
419
439
  .long .LASFDE3-.Lframe1 /* FDE CIE offset */
420
- #if defined __PIC__ && defined HAVE_AS_X86_PCREL
421
- .long .LFB3-. /* FDE initial location */
422
- #elif defined __PIC__
423
- .long .LFB3@rel
424
- #else
425
- .long .LFB3
426
- #endif
427
- .long .LFE3-.LFB3 /* FDE address range */
440
+ .long FDE_ENCODE(.LFB3) /* FDE initial location */
441
+ .long .LFE3-.LFB3 /* FDE address range */
428
442
  #ifdef __PIC__
429
443
  .byte 0x0 /* .uleb128 0x0; Augmentation size */
430
444
  #endif
@@ -324,7 +324,11 @@ ffi_closure_unix64:
324
324
  .LUW9:
325
325
  .size ffi_closure_unix64,.-ffi_closure_unix64
326
326
 
327
+ #ifdef HAVE_AS_X86_64_UNWIND_SECTION_TYPE
328
+ .section .eh_frame,"a",@unwind
329
+ #else
327
330
  .section .eh_frame,"a",@progbits
331
+ #endif
328
332
  .Lframe1:
329
333
  .long .LECIE1-.LSCIE1 /* CIE Length */
330
334
  .LSCIE1:
@@ -2,6 +2,7 @@
2
2
  win32.S - Copyright (c) 1996, 1998, 2001, 2002, 2009 Red Hat, Inc.
3
3
  Copyright (c) 2001 John Beniton
4
4
  Copyright (c) 2002 Ranjit Mathew
5
+ Copyright (c) 2009 Daniel Witte
5
6
 
6
7
 
7
8
  X86 Foreign Function Interface
@@ -31,14 +32,373 @@
31
32
  #define LIBFFI_ASM
32
33
  #include <fficonfig.h>
33
34
  #include <ffi.h>
34
-
35
+
36
+ #ifdef _MSC_VER
37
+
38
+ .386
39
+ .MODEL FLAT, C
40
+
41
+ EXTRN ffi_closure_SYSV_inner:NEAR
42
+
43
+ _TEXT SEGMENT
44
+
45
+ ffi_call_win32 PROC NEAR,
46
+ ffi_prep_args : NEAR PTR DWORD,
47
+ ecif : NEAR PTR DWORD,
48
+ cif_bytes : DWORD,
49
+ cif_flags : DWORD,
50
+ rvalue : NEAR PTR DWORD,
51
+ fn : NEAR PTR DWORD
52
+
53
+ ;; Make room for all of the new args.
54
+ mov ecx, cif_bytes
55
+ sub esp, ecx
56
+
57
+ mov eax, esp
58
+
59
+ ;; Place all of the ffi_prep_args in position
60
+ push ecif
61
+ push eax
62
+ call ffi_prep_args
63
+
64
+ ;; Return stack to previous state and call the function
65
+ add esp, 8
66
+
67
+ call fn
68
+
69
+ ;; cdecl: we restore esp in the epilogue, so there's no need to
70
+ ;; remove the space we pushed for the args.
71
+ ;; stdcall: the callee has already cleaned the stack.
72
+
73
+ ;; Load ecx with the return type code
74
+ mov ecx, cif_flags
75
+
76
+ ;; If the return value pointer is NULL, assume no return value.
77
+ cmp rvalue, 0
78
+ jne ca_jumptable
79
+
80
+ ;; Even if there is no space for the return value, we are
81
+ ;; obliged to handle floating-point values.
82
+ cmp ecx, FFI_TYPE_FLOAT
83
+ jne ca_epilogue
84
+ fstp st(0)
85
+
86
+ jmp ca_epilogue
87
+
88
+ ca_jumptable:
89
+ jmp [ca_jumpdata + 4 * ecx]
90
+ ca_jumpdata:
91
+ ;; Do not insert anything here between label and jump table.
92
+ dd offset ca_epilogue ;; FFI_TYPE_VOID
93
+ dd offset ca_retint ;; FFI_TYPE_INT
94
+ dd offset ca_retfloat ;; FFI_TYPE_FLOAT
95
+ dd offset ca_retdouble ;; FFI_TYPE_DOUBLE
96
+ dd offset ca_retlongdouble ;; FFI_TYPE_LONGDOUBLE
97
+ dd offset ca_retint8 ;; FFI_TYPE_UINT8
98
+ dd offset ca_retint8 ;; FFI_TYPE_SINT8
99
+ dd offset ca_retint16 ;; FFI_TYPE_UINT16
100
+ dd offset ca_retint16 ;; FFI_TYPE_SINT16
101
+ dd offset ca_retint ;; FFI_TYPE_UINT32
102
+ dd offset ca_retint ;; FFI_TYPE_SINT32
103
+ dd offset ca_retint64 ;; FFI_TYPE_UINT64
104
+ dd offset ca_retint64 ;; FFI_TYPE_SINT64
105
+ dd offset ca_epilogue ;; FFI_TYPE_STRUCT
106
+ dd offset ca_retint ;; FFI_TYPE_POINTER
107
+ dd offset ca_retint8 ;; FFI_TYPE_SMALL_STRUCT_1B
108
+ dd offset ca_retint16 ;; FFI_TYPE_SMALL_STRUCT_2B
109
+ dd offset ca_retint ;; FFI_TYPE_SMALL_STRUCT_4B
110
+
111
+ ca_retint8:
112
+ ;; Load %ecx with the pointer to storage for the return value
113
+ mov ecx, rvalue
114
+ mov [ecx + 0], al
115
+ jmp ca_epilogue
116
+
117
+ ca_retint16:
118
+ ;; Load %ecx with the pointer to storage for the return value
119
+ mov ecx, rvalue
120
+ mov [ecx + 0], ax
121
+ jmp ca_epilogue
122
+
123
+ ca_retint:
124
+ ;; Load %ecx with the pointer to storage for the return value
125
+ mov ecx, rvalue
126
+ mov [ecx + 0], eax
127
+ jmp ca_epilogue
128
+
129
+ ca_retint64:
130
+ ;; Load %ecx with the pointer to storage for the return value
131
+ mov ecx, rvalue
132
+ mov [ecx + 0], eax
133
+ mov [ecx + 4], edx
134
+ jmp ca_epilogue
135
+
136
+ ca_retfloat:
137
+ ;; Load %ecx with the pointer to storage for the return value
138
+ mov ecx, rvalue
139
+ fstp DWORD PTR [ecx]
140
+ jmp ca_epilogue
141
+
142
+ ca_retdouble:
143
+ ;; Load %ecx with the pointer to storage for the return value
144
+ mov ecx, rvalue
145
+ fstp QWORD PTR [ecx]
146
+ jmp ca_epilogue
147
+
148
+ ca_retlongdouble:
149
+ ;; Load %ecx with the pointer to storage for the return value
150
+ mov ecx, rvalue
151
+ fstp TBYTE PTR [ecx]
152
+ jmp ca_epilogue
153
+
154
+ ca_epilogue:
155
+ ;; Epilogue code is autogenerated.
156
+ ret
157
+ ffi_call_win32 ENDP
158
+
159
+ ffi_closure_SYSV PROC NEAR FORCEFRAME
160
+ ;; the ffi_closure ctx is passed in eax by the trampoline.
161
+
162
+ sub esp, 40
163
+ lea edx, [ebp - 24]
164
+ mov [ebp - 12], edx ;; resp
165
+ lea edx, [ebp + 8]
166
+ mov [esp + 8], edx ;; args
167
+ lea edx, [ebp - 12]
168
+ mov [esp + 4], edx ;; &resp
169
+ mov [esp], eax ;; closure
170
+ call ffi_closure_SYSV_inner
171
+ mov ecx, [ebp - 12]
172
+
173
+ cs_jumptable:
174
+ jmp [cs_jumpdata + 4 * eax]
175
+ cs_jumpdata:
176
+ ;; Do not insert anything here between the label and jump table.
177
+ dd offset cs_epilogue ;; FFI_TYPE_VOID
178
+ dd offset cs_retint ;; FFI_TYPE_INT
179
+ dd offset cs_retfloat ;; FFI_TYPE_FLOAT
180
+ dd offset cs_retdouble ;; FFI_TYPE_DOUBLE
181
+ dd offset cs_retlongdouble ;; FFI_TYPE_LONGDOUBLE
182
+ dd offset cs_retint8 ;; FFI_TYPE_UINT8
183
+ dd offset cs_retint8 ;; FFI_TYPE_SINT8
184
+ dd offset cs_retint16 ;; FFI_TYPE_UINT16
185
+ dd offset cs_retint16 ;; FFI_TYPE_SINT16
186
+ dd offset cs_retint ;; FFI_TYPE_UINT32
187
+ dd offset cs_retint ;; FFI_TYPE_SINT32
188
+ dd offset cs_retint64 ;; FFI_TYPE_UINT64
189
+ dd offset cs_retint64 ;; FFI_TYPE_SINT64
190
+ dd offset cs_retstruct ;; FFI_TYPE_STRUCT
191
+ dd offset cs_retint ;; FFI_TYPE_POINTER
192
+ dd offset cs_retint8 ;; FFI_TYPE_SMALL_STRUCT_1B
193
+ dd offset cs_retint16 ;; FFI_TYPE_SMALL_STRUCT_2B
194
+ dd offset cs_retint ;; FFI_TYPE_SMALL_STRUCT_4B
195
+
196
+ cs_retint8:
197
+ mov al, [ecx]
198
+ jmp cs_epilogue
199
+
200
+ cs_retint16:
201
+ mov ax, [ecx]
202
+ jmp cs_epilogue
203
+
204
+ cs_retint:
205
+ mov eax, [ecx]
206
+ jmp cs_epilogue
207
+
208
+ cs_retint64:
209
+ mov eax, [ecx + 0]
210
+ mov edx, [ecx + 4]
211
+ jmp cs_epilogue
212
+
213
+ cs_retfloat:
214
+ fld DWORD PTR [ecx]
215
+ jmp cs_epilogue
216
+
217
+ cs_retdouble:
218
+ fld QWORD PTR [ecx]
219
+ jmp cs_epilogue
220
+
221
+ cs_retlongdouble:
222
+ fld TBYTE PTR [ecx]
223
+ jmp cs_epilogue
224
+
225
+ cs_retstruct:
226
+ ;; Caller expects us to pop struct return value pointer hidden arg.
227
+ ;; Epilogue code is autogenerated.
228
+ ret 4
229
+
230
+ cs_epilogue:
231
+ ;; Epilogue code is autogenerated.
232
+ ret
233
+ ffi_closure_SYSV ENDP
234
+
235
+ #if !FFI_NO_RAW_API
236
+
237
+ #define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) AND NOT 3)
238
+ #define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
239
+ #define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
240
+ #define CIF_FLAGS_OFFSET 20
241
+
242
+ ffi_closure_raw_SYSV PROC NEAR USES esi
243
+ ;; the ffi_closure ctx is passed in eax by the trampoline.
244
+
245
+ sub esp, 40
246
+ mov esi, [eax + RAW_CLOSURE_CIF_OFFSET] ;; closure->cif
247
+ mov edx, [eax + RAW_CLOSURE_USER_DATA_OFFSET] ;; closure->user_data
248
+ mov [esp + 12], edx ;; user_data
249
+ lea edx, [ebp + 8]
250
+ mov [esp + 8], edx ;; raw_args
251
+ lea edx, [ebp - 24]
252
+ mov [esp + 4], edx ;; &res
253
+ mov [esp], esi ;; cif
254
+ call DWORD PTR [eax + RAW_CLOSURE_FUN_OFFSET] ;; closure->fun
255
+ mov eax, [esi + CIF_FLAGS_OFFSET] ;; cif->flags
256
+ lea ecx, [ebp - 24]
257
+
258
+ cr_jumptable:
259
+ jmp [cr_jumpdata + 4 * eax]
260
+ cr_jumpdata:
261
+ ;; Do not insert anything here between the label and jump table.
262
+ dd offset cr_epilogue ;; FFI_TYPE_VOID
263
+ dd offset cr_retint ;; FFI_TYPE_INT
264
+ dd offset cr_retfloat ;; FFI_TYPE_FLOAT
265
+ dd offset cr_retdouble ;; FFI_TYPE_DOUBLE
266
+ dd offset cr_retlongdouble ;; FFI_TYPE_LONGDOUBLE
267
+ dd offset cr_retint8 ;; FFI_TYPE_UINT8
268
+ dd offset cr_retint8 ;; FFI_TYPE_SINT8
269
+ dd offset cr_retint16 ;; FFI_TYPE_UINT16
270
+ dd offset cr_retint16 ;; FFI_TYPE_SINT16
271
+ dd offset cr_retint ;; FFI_TYPE_UINT32
272
+ dd offset cr_retint ;; FFI_TYPE_SINT32
273
+ dd offset cr_retint64 ;; FFI_TYPE_UINT64
274
+ dd offset cr_retint64 ;; FFI_TYPE_SINT64
275
+ dd offset cr_epilogue ;; FFI_TYPE_STRUCT
276
+ dd offset cr_retint ;; FFI_TYPE_POINTER
277
+ dd offset cr_retint8 ;; FFI_TYPE_SMALL_STRUCT_1B
278
+ dd offset cr_retint16 ;; FFI_TYPE_SMALL_STRUCT_2B
279
+ dd offset cr_retint ;; FFI_TYPE_SMALL_STRUCT_4B
280
+
281
+ cr_retint8:
282
+ mov al, [ecx]
283
+ jmp cr_epilogue
284
+
285
+ cr_retint16:
286
+ mov ax, [ecx]
287
+ jmp cr_epilogue
288
+
289
+ cr_retint:
290
+ mov eax, [ecx]
291
+ jmp cr_epilogue
292
+
293
+ cr_retint64:
294
+ mov eax, [ecx + 0]
295
+ mov edx, [ecx + 4]
296
+ jmp cr_epilogue
297
+
298
+ cr_retfloat:
299
+ fld DWORD PTR [ecx]
300
+ jmp cr_epilogue
301
+
302
+ cr_retdouble:
303
+ fld QWORD PTR [ecx]
304
+ jmp cr_epilogue
305
+
306
+ cr_retlongdouble:
307
+ fld TBYTE PTR [ecx]
308
+ jmp cr_epilogue
309
+
310
+ cr_epilogue:
311
+ ;; Epilogue code is autogenerated.
312
+ ret
313
+ ffi_closure_raw_SYSV ENDP
314
+
315
+ #endif /* !FFI_NO_RAW_API */
316
+
317
+ ffi_closure_STDCALL PROC NEAR FORCEFRAME
318
+ ;; the ffi_closure ctx is passed in eax by the trampoline.
319
+
320
+ sub esp, 40
321
+ lea edx, [ebp - 24]
322
+ mov [ebp - 12], edx ;; resp
323
+ lea edx, [ebp + 12] ;; account for stub return address on stack
324
+ mov [esp + 8], edx ;; args
325
+ lea edx, [ebp - 12]
326
+ mov [esp + 4], edx ;; &resp
327
+ mov [esp], eax ;; closure
328
+ call ffi_closure_SYSV_inner
329
+ mov ecx, [ebp - 12]
330
+
331
+ cd_jumptable:
332
+ jmp [cd_jumpdata + 4 * eax]
333
+ cd_jumpdata:
334
+ ;; Do not insert anything here between the label and jump table.
335
+ dd offset cd_epilogue ;; FFI_TYPE_VOID
336
+ dd offset cd_retint ;; FFI_TYPE_INT
337
+ dd offset cd_retfloat ;; FFI_TYPE_FLOAT
338
+ dd offset cd_retdouble ;; FFI_TYPE_DOUBLE
339
+ dd offset cd_retlongdouble ;; FFI_TYPE_LONGDOUBLE
340
+ dd offset cd_retint8 ;; FFI_TYPE_UINT8
341
+ dd offset cd_retint8 ;; FFI_TYPE_SINT8
342
+ dd offset cd_retint16 ;; FFI_TYPE_UINT16
343
+ dd offset cd_retint16 ;; FFI_TYPE_SINT16
344
+ dd offset cd_retint ;; FFI_TYPE_UINT32
345
+ dd offset cd_retint ;; FFI_TYPE_SINT32
346
+ dd offset cd_retint64 ;; FFI_TYPE_UINT64
347
+ dd offset cd_retint64 ;; FFI_TYPE_SINT64
348
+ dd offset cd_epilogue ;; FFI_TYPE_STRUCT
349
+ dd offset cd_retint ;; FFI_TYPE_POINTER
350
+ dd offset cd_retint8 ;; FFI_TYPE_SMALL_STRUCT_1B
351
+ dd offset cd_retint16 ;; FFI_TYPE_SMALL_STRUCT_2B
352
+ dd offset cd_retint ;; FFI_TYPE_SMALL_STRUCT_4B
353
+
354
+ cd_retint8:
355
+ mov al, [ecx]
356
+ jmp cd_epilogue
357
+
358
+ cd_retint16:
359
+ mov ax, [ecx]
360
+ jmp cd_epilogue
361
+
362
+ cd_retint:
363
+ mov eax, [ecx]
364
+ jmp cd_epilogue
365
+
366
+ cd_retint64:
367
+ mov eax, [ecx + 0]
368
+ mov edx, [ecx + 4]
369
+ jmp cd_epilogue
370
+
371
+ cd_retfloat:
372
+ fld DWORD PTR [ecx]
373
+ jmp cd_epilogue
374
+
375
+ cd_retdouble:
376
+ fld QWORD PTR [ecx]
377
+ jmp cd_epilogue
378
+
379
+ cd_retlongdouble:
380
+ fld TBYTE PTR [ecx]
381
+ jmp cd_epilogue
382
+
383
+ cd_epilogue:
384
+ ;; Epilogue code is autogenerated.
385
+ ret
386
+ ffi_closure_STDCALL ENDP
387
+
388
+ _TEXT ENDS
389
+ END
390
+
391
+ #else
392
+
35
393
  .text
36
394
 
37
395
  # This assumes we are using gas.
38
396
  .balign 16
39
- .globl _ffi_call_SYSV
40
- .def _ffi_call_SYSV; .scl 2; .type 32; .endef
41
- _ffi_call_SYSV:
397
+ .globl _ffi_call_win32
398
+ #ifndef __OS2__
399
+ .def _ffi_call_win32; .scl 2; .type 32; .endef
400
+ #endif
401
+ _ffi_call_win32:
42
402
  .LFB1:
43
403
  pushl %ebp
44
404
  .LCFI0:
@@ -61,8 +421,10 @@ _ffi_call_SYSV:
61
421
  # FIXME: Align the stack to a 128-bit boundary to avoid
62
422
  # potential performance hits.
63
423
 
64
- call *28(%ebp)
424
+ call *28(%ebp)
65
425
 
426
+ # stdcall functions pop arguments off the stack themselves
427
+
66
428
  # Load %ecx with the return type code
67
429
  movl 20(%ebp),%ecx
68
430
 
@@ -181,166 +543,15 @@ _ffi_call_SYSV:
181
543
  movl %ebp,%esp
182
544
  popl %ebp
183
545
  ret
184
- .ffi_call_SYSV_end:
546
+ .ffi_call_win32_end:
185
547
  .LFE1:
186
548
 
187
- # This assumes we are using gas.
188
- .balign 16
189
- .globl _ffi_call_STDCALL
190
- .def _ffi_call_STDCALL; .scl 2; .type 32; .endef
191
- _ffi_call_STDCALL:
192
- .LFB2:
193
- pushl %ebp
194
- .LCFI2:
195
- movl %esp,%ebp
196
- .LCFI3:
197
- # Make room for all of the new args.
198
- movl 16(%ebp),%ecx
199
- subl %ecx,%esp
200
-
201
- movl %esp,%eax
202
-
203
- # Place all of the ffi_prep_args in position
204
- pushl 12(%ebp)
205
- pushl %eax
206
- call *8(%ebp)
207
-
208
- # Return stack to previous state and call the function
209
- addl $8,%esp
210
-
211
- # FIXME: Align the stack to a 128-bit boundary to avoid
212
- # potential performance hits.
213
-
214
- call *28(%ebp)
215
-
216
- # stdcall functions pop arguments off the stack themselves
217
-
218
- # Load %ecx with the return type code
219
- movl 20(%ebp),%ecx
220
-
221
- # If the return value pointer is NULL, assume no return value.
222
- cmpl $0,24(%ebp)
223
- jne 0f
224
-
225
- # Even if there is no space for the return value, we are
226
- # obliged to handle floating-point values.
227
- cmpl $FFI_TYPE_FLOAT,%ecx
228
- jne .Lsc_noretval
229
- fstp %st(0)
230
-
231
- jmp .Lsc_epilogue
232
-
233
- 0:
234
- call 1f
235
- # Do not insert anything here between the call and the jump table.
236
- .Lsc_store_table:
237
- .long .Lsc_noretval /* FFI_TYPE_VOID */
238
- .long .Lsc_retint /* FFI_TYPE_INT */
239
- .long .Lsc_retfloat /* FFI_TYPE_FLOAT */
240
- .long .Lsc_retdouble /* FFI_TYPE_DOUBLE */
241
- .long .Lsc_retlongdouble /* FFI_TYPE_LONGDOUBLE */
242
- .long .Lsc_retuint8 /* FFI_TYPE_UINT8 */
243
- .long .Lsc_retsint8 /* FFI_TYPE_SINT8 */
244
- .long .Lsc_retuint16 /* FFI_TYPE_UINT16 */
245
- .long .Lsc_retsint16 /* FFI_TYPE_SINT16 */
246
- .long .Lsc_retint /* FFI_TYPE_UINT32 */
247
- .long .Lsc_retint /* FFI_TYPE_SINT32 */
248
- .long .Lsc_retint64 /* FFI_TYPE_UINT64 */
249
- .long .Lsc_retint64 /* FFI_TYPE_SINT64 */
250
- .long .Lsc_retstruct /* FFI_TYPE_STRUCT */
251
- .long .Lsc_retint /* FFI_TYPE_POINTER */
252
- .long .Lsc_retstruct1b /* FFI_TYPE_SMALL_STRUCT_1B */
253
- .long .Lsc_retstruct2b /* FFI_TYPE_SMALL_STRUCT_2B */
254
- .long .Lsc_retstruct4b /* FFI_TYPE_SMALL_STRUCT_4B */
255
-
256
- 1:
257
- add %ecx, %ecx
258
- add %ecx, %ecx
259
- add (%esp),%ecx
260
- add $4, %esp
261
- jmp *(%ecx)
262
-
263
- /* Sign/zero extend as appropriate. */
264
- .Lsc_retsint8:
265
- movsbl %al, %eax
266
- jmp .Lsc_retint
267
-
268
- .Lsc_retsint16:
269
- movswl %ax, %eax
270
- jmp .Lsc_retint
271
-
272
- .Lsc_retuint8:
273
- movzbl %al, %eax
274
- jmp .Lsc_retint
275
-
276
- .Lsc_retuint16:
277
- movzwl %ax, %eax
278
- jmp .Lsc_retint
279
-
280
- .Lsc_retint:
281
- # Load %ecx with the pointer to storage for the return value
282
- movl 24(%ebp),%ecx
283
- movl %eax,0(%ecx)
284
- jmp .Lsc_epilogue
285
-
286
- .Lsc_retfloat:
287
- # Load %ecx with the pointer to storage for the return value
288
- movl 24(%ebp),%ecx
289
- fstps (%ecx)
290
- jmp .Lsc_epilogue
291
-
292
- .Lsc_retdouble:
293
- # Load %ecx with the pointer to storage for the return value
294
- movl 24(%ebp),%ecx
295
- fstpl (%ecx)
296
- jmp .Lsc_epilogue
297
-
298
- .Lsc_retlongdouble:
299
- # Load %ecx with the pointer to storage for the return value
300
- movl 24(%ebp),%ecx
301
- fstpt (%ecx)
302
- jmp .Lsc_epilogue
303
-
304
- .Lsc_retint64:
305
- # Load %ecx with the pointer to storage for the return value
306
- movl 24(%ebp),%ecx
307
- movl %eax,0(%ecx)
308
- movl %edx,4(%ecx)
309
- jmp .Lsc_epilogue
310
-
311
- .Lsc_retstruct1b:
312
- # Load %ecx with the pointer to storage for the return value
313
- movl 24(%ebp),%ecx
314
- movb %al,0(%ecx)
315
- jmp .Lsc_epilogue
316
-
317
- .Lsc_retstruct2b:
318
- # Load %ecx with the pointer to storage for the return value
319
- movl 24(%ebp),%ecx
320
- movw %ax,0(%ecx)
321
- jmp .Lsc_epilogue
322
-
323
- .Lsc_retstruct4b:
324
- # Load %ecx with the pointer to storage for the return value
325
- movl 24(%ebp),%ecx
326
- movl %eax,0(%ecx)
327
- jmp .Lsc_epilogue
328
-
329
- .Lsc_retstruct:
330
- # Nothing to do!
331
-
332
- .Lsc_noretval:
333
- .Lsc_epilogue:
334
- movl %ebp,%esp
335
- popl %ebp
336
- ret
337
- .ffi_call_STDCALL_end:
338
- .LFE2:
339
-
340
549
  # This assumes we are using gas.
341
550
  .balign 16
342
551
  .globl _ffi_closure_SYSV
552
+ #ifndef __OS2__
343
553
  .def _ffi_closure_SYSV; .scl 2; .type 32; .endef
554
+ #endif
344
555
  _ffi_closure_SYSV:
345
556
  .LFB3:
346
557
  pushl %ebp
@@ -461,7 +672,9 @@ _ffi_closure_SYSV:
461
672
  # This assumes we are using gas.
462
673
  .balign 16
463
674
  .globl _ffi_closure_raw_SYSV
675
+ #ifndef __OS2__
464
676
  .def _ffi_closure_raw_SYSV; .scl 2; .type 32; .endef
677
+ #endif
465
678
  _ffi_closure_raw_SYSV:
466
679
  .LFB4:
467
680
  pushl %ebp
@@ -577,7 +790,9 @@ _ffi_closure_raw_SYSV:
577
790
  # This assumes we are using gas.
578
791
  .balign 16
579
792
  .globl _ffi_closure_STDCALL
793
+ #ifndef __OS2__
580
794
  .def _ffi_closure_STDCALL; .scl 2; .type 32; .endef
795
+ #endif
581
796
  _ffi_closure_STDCALL:
582
797
  .LFB5:
583
798
  pushl %ebp
@@ -683,7 +898,9 @@ _ffi_closure_STDCALL:
683
898
  .ffi_closure_STDCALL_end:
684
899
  .LFE5:
685
900
 
901
+ #ifndef __OS2__
686
902
  .section .eh_frame,"w"
903
+ #endif
687
904
  .Lframe1:
688
905
  .LSCIE1:
689
906
  .long .LECIE1-.LASCIE1 /* Length of Common Information Entry */
@@ -742,38 +959,6 @@ _ffi_closure_STDCALL:
742
959
  .LEFDE1:
743
960
 
744
961
 
745
- .LSFDE2:
746
- .long .LEFDE2-.LASFDE2 /* FDE Length */
747
- .LASFDE2:
748
- .long .LASFDE2-.Lframe1 /* FDE CIE offset */
749
- #if defined __PIC__ && defined HAVE_AS_X86_PCREL
750
- .long .LFB2-. /* FDE initial location */
751
- #else
752
- .long .LFB2
753
- #endif
754
- .long .LFE2-.LFB2 /* FDE address range */
755
- #ifdef __PIC__
756
- .byte 0x0 /* .uleb128 0x0; Augmentation size */
757
- #endif
758
- /* DW_CFA_xxx CFI instructions go here. */
759
-
760
- .byte 0x4 /* DW_CFA_advance_loc4 */
761
- .long .LCFI2-.LFB2
762
- .byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
763
- .byte 0x8 /* .uleb128 0x8 */
764
- .byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
765
- .byte 0x2 /* .uleb128 0x2 */
766
-
767
- .byte 0x4 /* DW_CFA_advance_loc4 */
768
- .long .LCFI3-.LCFI2
769
- .byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
770
- .byte 0x5 /* .uleb128 0x5 */
771
-
772
- /* End of DW_CFA_xxx CFI instructions. */
773
- .align 4
774
- .LEFDE2:
775
-
776
-
777
962
  .LSFDE3:
778
963
  .long .LEFDE3-.LASFDE3 /* FDE Length */
779
964
  .LASFDE3:
@@ -875,3 +1060,6 @@ _ffi_closure_STDCALL:
875
1060
  /* End of DW_CFA_xxx CFI instructions. */
876
1061
  .align 4
877
1062
  .LEFDE5:
1063
+
1064
+ #endif /* !_MSC_VER */
1065
+