rbdc 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (266) hide show
  1. data/bindings/ruby/rbdc/extconf.rb +57 -0
  2. data/bindings/ruby/rbdc/rbdc.c +304 -0
  3. data/dyncall/AUTHORS +4 -0
  4. data/dyncall/BUGS +3 -0
  5. data/dyncall/CMakeLists.txt +79 -0
  6. data/dyncall/ChangeLog +165 -0
  7. data/dyncall/LICENSE +15 -0
  8. data/dyncall/Makefile.M +15 -0
  9. data/dyncall/Makefile.embedded +71 -0
  10. data/dyncall/Makefile.generic +36 -0
  11. data/dyncall/Nmakefile +45 -0
  12. data/dyncall/README +92 -0
  13. data/dyncall/ToDo +114 -0
  14. data/dyncall/autovar/LICENSE.txt +15 -0
  15. data/dyncall/autovar/README.txt +69 -0
  16. data/dyncall/autovar/autovar_ABI.h +44 -0
  17. data/dyncall/autovar/autovar_ARCH.h +56 -0
  18. data/dyncall/autovar/autovar_CC.h +46 -0
  19. data/dyncall/autovar/autovar_OS.h +78 -0
  20. data/dyncall/autovar/autovar_OSFAMILY.h +39 -0
  21. data/dyncall/buildsys/cmake/Modules/FindDynCall.cmake +43 -0
  22. data/dyncall/buildsys/cmake/Modules/FindDynCallback.cmake +43 -0
  23. data/dyncall/buildsys/cmake/Modules/FindDynLoad.cmake +45 -0
  24. data/dyncall/buildsys/cmake/Modules/UseLATEX.cmake +811 -0
  25. data/dyncall/buildsys/dynmake/Makefile.base.M +82 -0
  26. data/dyncall/buildsys/dynmake/dynmake.bat +2 -0
  27. data/dyncall/buildsys/dynmake/dynmake.sh +4 -0
  28. data/dyncall/buildsys/lua/Makefile +10 -0
  29. data/dyncall/buildsys/lua/README.txt +4 -0
  30. data/dyncall/buildsys/lua/bootstrap.sh +34 -0
  31. data/dyncall/buildsys/lua/cleanup.sh +6 -0
  32. data/dyncall/buildsys/lua/mkfile +34 -0
  33. data/dyncall/buildsys/lua/setenv.sh +4 -0
  34. data/dyncall/buildsys/mk/app.mk +30 -0
  35. data/dyncall/buildsys/mk/dirs.mk +27 -0
  36. data/dyncall/buildsys/mk/epilog.mk +30 -0
  37. data/dyncall/buildsys/mk/lib.mk +23 -0
  38. data/dyncall/buildsys/mk/pcc.mk +60 -0
  39. data/dyncall/buildsys/mk/prolog.mk +35 -0
  40. data/dyncall/buildsys/nmake/common.nmake +61 -0
  41. data/dyncall/buildsys/nmake/epilog.nmake +28 -0
  42. data/dyncall/buildsys/nmake/prolog.nmake +76 -0
  43. data/dyncall/buildsys/nmake/tool_gcc.nmake +82 -0
  44. data/dyncall/buildsys/nmake/tool_msvc.nmake +67 -0
  45. data/dyncall/buildsys/scripts/batch-build-linux.sh +11 -0
  46. data/dyncall/buildsys/scripts/batch-build-minix.sh +11 -0
  47. data/dyncall/buildsys/scripts/batch-build-psp.sh +11 -0
  48. data/dyncall/buildsys/scripts/conf-nds.bat +41 -0
  49. data/dyncall/buildsys/scripts/setenv-cross-ios.sh +8 -0
  50. data/dyncall/buildsys/scripts/setenv-sdk-ios.sh +22 -0
  51. data/dyncall/buildsys/vs2005/dyncall/dyncall.vcproj +245 -0
  52. data/dyncall/buildsys/vs2005/test_plain/test_plain.vcproj +202 -0
  53. data/dyncall/buildsys/vs2005/vs2005.sln +29 -0
  54. data/dyncall/configure +152 -0
  55. data/dyncall/configure.bat +157 -0
  56. data/dyncall/configure.rc +234 -0
  57. data/dyncall/dynMakefile +4 -0
  58. data/dyncall/dyncall/CMakeLists.txt +53 -0
  59. data/dyncall/dyncall/DynCallConfig.cmake +3 -0
  60. data/dyncall/dyncall/Makefile.M +10 -0
  61. data/dyncall/dyncall/Makefile.embedded +20 -0
  62. data/dyncall/dyncall/Makefile.generic +16 -0
  63. data/dyncall/dyncall/Nmakefile +62 -0
  64. data/dyncall/dyncall/README-Developer.txt +45 -0
  65. data/dyncall/dyncall/README.txt +65 -0
  66. data/dyncall/dyncall/TODO +9 -0
  67. data/dyncall/dyncall/dynMakefile +4 -0
  68. data/dyncall/dyncall/dyncall.3 +189 -0
  69. data/dyncall/dyncall/dyncall.h +135 -0
  70. data/dyncall/dyncall/dyncall_alloc.h +40 -0
  71. data/dyncall/dyncall/dyncall_api.c +167 -0
  72. data/dyncall/dyncall/dyncall_call.S +72 -0
  73. data/dyncall/dyncall/dyncall_call_arm32_arm.S +80 -0
  74. data/dyncall/dyncall/dyncall_call_arm32_arm.h +61 -0
  75. data/dyncall/dyncall/dyncall_call_arm32_arm_armhf.S +96 -0
  76. data/dyncall/dyncall/dyncall_call_arm32_arm_armhf.h +44 -0
  77. data/dyncall/dyncall/dyncall_call_arm32_thumb.h +65 -0
  78. data/dyncall/dyncall/dyncall_call_arm32_thumb_apple.s +80 -0
  79. data/dyncall/dyncall/dyncall_call_arm32_thumb_armhf.S +121 -0
  80. data/dyncall/dyncall/dyncall_call_arm32_thumb_gas.s +101 -0
  81. data/dyncall/dyncall/dyncall_call_mips.h +50 -0
  82. data/dyncall/dyncall/dyncall_call_mips_eabi.h +61 -0
  83. data/dyncall/dyncall/dyncall_call_mips_eabi_gas.s +115 -0
  84. data/dyncall/dyncall/dyncall_call_mips_gas.S +36 -0
  85. data/dyncall/dyncall/dyncall_call_mips_n32.h +67 -0
  86. data/dyncall/dyncall/dyncall_call_mips_n32_gas.s +192 -0
  87. data/dyncall/dyncall/dyncall_call_mips_n64.h +67 -0
  88. data/dyncall/dyncall/dyncall_call_mips_n64_gas.s +192 -0
  89. data/dyncall/dyncall/dyncall_call_mips_o32.h +70 -0
  90. data/dyncall/dyncall/dyncall_call_mips_o32_gas.s +109 -0
  91. data/dyncall/dyncall/dyncall_call_ppc32.S +266 -0
  92. data/dyncall/dyncall/dyncall_call_ppc32.h +62 -0
  93. data/dyncall/dyncall/dyncall_call_sparc.S +192 -0
  94. data/dyncall/dyncall/dyncall_call_sparc.h +42 -0
  95. data/dyncall/dyncall/dyncall_call_sparc64.S +361 -0
  96. data/dyncall/dyncall/dyncall_call_sparc64.h +42 -0
  97. data/dyncall/dyncall/dyncall_call_sparc_v9.S +220 -0
  98. data/dyncall/dyncall/dyncall_call_sparc_v9.h +42 -0
  99. data/dyncall/dyncall/dyncall_call_x64-att.S +146 -0
  100. data/dyncall/dyncall/dyncall_call_x64.S +149 -0
  101. data/dyncall/dyncall/dyncall_call_x64.h +63 -0
  102. data/dyncall/dyncall/dyncall_call_x64_generic_masm.asm +70 -0
  103. data/dyncall/dyncall/dyncall_call_x86.S +238 -0
  104. data/dyncall/dyncall/dyncall_call_x86.h +70 -0
  105. data/dyncall/dyncall/dyncall_call_x86_8a.s +127 -0
  106. data/dyncall/dyncall/dyncall_call_x86_generic_masm.asm +136 -0
  107. data/dyncall/dyncall/dyncall_call_x86_nasm.asm +234 -0
  108. data/dyncall/dyncall/dyncall_callf.c +112 -0
  109. data/dyncall/dyncall/dyncall_callf.h +52 -0
  110. data/dyncall/dyncall/dyncall_callvm.c +68 -0
  111. data/dyncall/dyncall/dyncall_callvm.h +88 -0
  112. data/dyncall/dyncall/dyncall_callvm_arm32_arm.c +250 -0
  113. data/dyncall/dyncall/dyncall_callvm_arm32_arm.h +59 -0
  114. data/dyncall/dyncall/dyncall_callvm_arm32_arm_armhf.c +204 -0
  115. data/dyncall/dyncall/dyncall_callvm_arm32_arm_armhf.h +63 -0
  116. data/dyncall/dyncall/dyncall_callvm_arm32_thumb.c +271 -0
  117. data/dyncall/dyncall/dyncall_callvm_arm32_thumb.h +59 -0
  118. data/dyncall/dyncall/dyncall_callvm_base.c +33 -0
  119. data/dyncall/dyncall/dyncall_callvm_mips.c +40 -0
  120. data/dyncall/dyncall/dyncall_callvm_mips.h +37 -0
  121. data/dyncall/dyncall/dyncall_callvm_mips_eabi.c +181 -0
  122. data/dyncall/dyncall/dyncall_callvm_mips_eabi.h +61 -0
  123. data/dyncall/dyncall/dyncall_callvm_mips_n32.c +268 -0
  124. data/dyncall/dyncall/dyncall_callvm_mips_n64.c +268 -0
  125. data/dyncall/dyncall/dyncall_callvm_mips_n64.h +53 -0
  126. data/dyncall/dyncall/dyncall_callvm_mips_o32.c +235 -0
  127. data/dyncall/dyncall/dyncall_callvm_mips_o32.h +45 -0
  128. data/dyncall/dyncall/dyncall_callvm_ppc32.c +372 -0
  129. data/dyncall/dyncall/dyncall_callvm_ppc32.h +61 -0
  130. data/dyncall/dyncall/dyncall_callvm_sparc.c +155 -0
  131. data/dyncall/dyncall/dyncall_callvm_sparc.h +44 -0
  132. data/dyncall/dyncall/dyncall_callvm_sparc64.c +239 -0
  133. data/dyncall/dyncall/dyncall_callvm_sparc64.h +47 -0
  134. data/dyncall/dyncall/dyncall_callvm_sparc_v9.c +182 -0
  135. data/dyncall/dyncall/dyncall_callvm_sparc_v9.h +45 -0
  136. data/dyncall/dyncall/dyncall_callvm_x64.c +228 -0
  137. data/dyncall/dyncall/dyncall_callvm_x64.h +111 -0
  138. data/dyncall/dyncall/dyncall_callvm_x86.c +667 -0
  139. data/dyncall/dyncall/dyncall_callvm_x86.h +75 -0
  140. data/dyncall/dyncall/dyncall_config.h +46 -0
  141. data/dyncall/dyncall/dyncall_macros.h +248 -0
  142. data/dyncall/dyncall/dyncall_signature.h +71 -0
  143. data/dyncall/dyncall/dyncall_struct.c +255 -0
  144. data/dyncall/dyncall/dyncall_struct.h +69 -0
  145. data/dyncall/dyncall/dyncall_types.h +74 -0
  146. data/dyncall/dyncall/dyncall_utils.h +38 -0
  147. data/dyncall/dyncall/dyncall_value.h +73 -0
  148. data/dyncall/dyncall/dyncall_vector.c +52 -0
  149. data/dyncall/dyncall/dyncall_vector.h +56 -0
  150. data/dyncall/dyncall/gen-masm.sh +7 -0
  151. data/dyncall/dyncall/mkfile +29 -0
  152. data/dyncall/dyncallback/CMakeLists.txt +55 -0
  153. data/dyncall/dyncallback/DynCallbackConfig.cmake +2 -0
  154. data/dyncall/dyncallback/Makefile.M +10 -0
  155. data/dyncall/dyncallback/Makefile.embedded +15 -0
  156. data/dyncall/dyncallback/Makefile.generic +20 -0
  157. data/dyncall/dyncallback/Nmakefile +71 -0
  158. data/dyncall/dyncallback/README.txt +9 -0
  159. data/dyncall/dyncallback/TODO +4 -0
  160. data/dyncall/dyncallback/dynMakefile +4 -0
  161. data/dyncall/dyncallback/dyncall_alloc_wx.c +35 -0
  162. data/dyncall/dyncallback/dyncall_alloc_wx.h +46 -0
  163. data/dyncall/dyncallback/dyncall_alloc_wx_malloc.c +40 -0
  164. data/dyncall/dyncallback/dyncall_alloc_wx_mmap.c +42 -0
  165. data/dyncall/dyncallback/dyncall_alloc_wx_win32.c +42 -0
  166. data/dyncall/dyncallback/dyncall_args.c +45 -0
  167. data/dyncall/dyncallback/dyncall_args.h +65 -0
  168. data/dyncall/dyncallback/dyncall_args_arm32_arm.c +112 -0
  169. data/dyncall/dyncallback/dyncall_args_arm32_arm.h +40 -0
  170. data/dyncall/dyncallback/dyncall_args_arm32_thumb.c +29 -0
  171. data/dyncall/dyncallback/dyncall_args_arm32_thumb.h +32 -0
  172. data/dyncall/dyncallback/dyncall_args_mips.c +81 -0
  173. data/dyncall/dyncallback/dyncall_args_mips.h +41 -0
  174. data/dyncall/dyncallback/dyncall_args_ppc32.c +88 -0
  175. data/dyncall/dyncallback/dyncall_args_ppc32.h +41 -0
  176. data/dyncall/dyncallback/dyncall_args_sparc32.c +41 -0
  177. data/dyncall/dyncallback/dyncall_args_sparc32.h +37 -0
  178. data/dyncall/dyncallback/dyncall_args_sparc64.c +41 -0
  179. data/dyncall/dyncallback/dyncall_args_sparc64.h +37 -0
  180. data/dyncall/dyncallback/dyncall_args_x64.c +73 -0
  181. data/dyncall/dyncallback/dyncall_args_x64.h +44 -0
  182. data/dyncall/dyncallback/dyncall_args_x86.c +121 -0
  183. data/dyncall/dyncallback/dyncall_args_x86.h +58 -0
  184. data/dyncall/dyncallback/dyncall_callback.c +45 -0
  185. data/dyncall/dyncallback/dyncall_callback.h +51 -0
  186. data/dyncall/dyncallback/dyncall_callback_arch.S +71 -0
  187. data/dyncall/dyncallback/dyncall_callback_arm32_arm.c +63 -0
  188. data/dyncall/dyncallback/dyncall_callback_arm32_arm.h +45 -0
  189. data/dyncall/dyncallback/dyncall_callback_arm32_arm_apple.s +73 -0
  190. data/dyncall/dyncallback/dyncall_callback_arm32_arm_gas.s +73 -0
  191. data/dyncall/dyncallback/dyncall_callback_arm32_thumb.c +29 -0
  192. data/dyncall/dyncallback/dyncall_callback_arm32_thumb.h +33 -0
  193. data/dyncall/dyncallback/dyncall_callback_arm32_thumb_apple.s +32 -0
  194. data/dyncall/dyncallback/dyncall_callback_arm32_thumb_gas.s +32 -0
  195. data/dyncall/dyncallback/dyncall_callback_mips.c +61 -0
  196. data/dyncall/dyncallback/dyncall_callback_mips.h +42 -0
  197. data/dyncall/dyncallback/dyncall_callback_ppc32.S +33 -0
  198. data/dyncall/dyncallback/dyncall_callback_ppc32.c +60 -0
  199. data/dyncall/dyncallback/dyncall_callback_ppc32.h +43 -0
  200. data/dyncall/dyncallback/dyncall_callback_ppc32_apple.s +180 -0
  201. data/dyncall/dyncallback/dyncall_callback_sparc32.c +57 -0
  202. data/dyncall/dyncallback/dyncall_callback_sparc32.h +43 -0
  203. data/dyncall/dyncallback/dyncall_callback_sparc32.s +30 -0
  204. data/dyncall/dyncallback/dyncall_callback_sparc64.c +57 -0
  205. data/dyncall/dyncallback/dyncall_callback_sparc64.s +30 -0
  206. data/dyncall/dyncallback/dyncall_callback_x64.S +187 -0
  207. data/dyncall/dyncallback/dyncall_callback_x64.c +69 -0
  208. data/dyncall/dyncallback/dyncall_callback_x64.h +44 -0
  209. data/dyncall/dyncallback/dyncall_callback_x64_apple.s +122 -0
  210. data/dyncall/dyncallback/dyncall_callback_x64_gas.s +119 -0
  211. data/dyncall/dyncallback/dyncall_callback_x64_gas_w64.s +102 -0
  212. data/dyncall/dyncallback/dyncall_callback_x64_masm.asm +89 -0
  213. data/dyncall/dyncallback/dyncall_callback_x86.S +115 -0
  214. data/dyncall/dyncallback/dyncall_callback_x86.c +281 -0
  215. data/dyncall/dyncallback/dyncall_callback_x86.h +49 -0
  216. data/dyncall/dyncallback/dyncall_callback_x86_8a.s +100 -0
  217. data/dyncall/dyncallback/dyncall_callback_x86_masm.asm +74 -0
  218. data/dyncall/dyncallback/dyncall_thunk.c +47 -0
  219. data/dyncall/dyncallback/dyncall_thunk.h +84 -0
  220. data/dyncall/dyncallback/dyncall_thunk_arm32_arm.c +45 -0
  221. data/dyncall/dyncallback/dyncall_thunk_arm32_arm.h +40 -0
  222. data/dyncall/dyncallback/dyncall_thunk_arm32_thumb.c +29 -0
  223. data/dyncall/dyncallback/dyncall_thunk_arm32_thumb.h +35 -0
  224. data/dyncall/dyncallback/dyncall_thunk_mips.c +52 -0
  225. data/dyncall/dyncallback/dyncall_thunk_mips.h +37 -0
  226. data/dyncall/dyncallback/dyncall_thunk_ppc32.c +51 -0
  227. data/dyncall/dyncallback/dyncall_thunk_ppc32.h +40 -0
  228. data/dyncall/dyncallback/dyncall_thunk_sparc32.c +32 -0
  229. data/dyncall/dyncallback/dyncall_thunk_sparc32.h +36 -0
  230. data/dyncall/dyncallback/dyncall_thunk_sparc64.c +32 -0
  231. data/dyncall/dyncallback/dyncall_thunk_sparc64.h +36 -0
  232. data/dyncall/dyncallback/dyncall_thunk_x64.c +48 -0
  233. data/dyncall/dyncallback/dyncall_thunk_x64.h +39 -0
  234. data/dyncall/dyncallback/dyncall_thunk_x86.c +44 -0
  235. data/dyncall/dyncallback/dyncall_thunk_x86.h +39 -0
  236. data/dyncall/dyncallback/dyncallback.3 +134 -0
  237. data/dyncall/dyncallback/gen-masm.sh +8 -0
  238. data/dyncall/dyncallback/mkfile +29 -0
  239. data/dyncall/dynload/CMakeLists.txt +25 -0
  240. data/dyncall/dynload/DynLoadConfig.cmake +3 -0
  241. data/dyncall/dynload/Makefile.M +10 -0
  242. data/dyncall/dynload/Makefile.embedded +22 -0
  243. data/dyncall/dynload/Makefile.generic +18 -0
  244. data/dyncall/dynload/Nmakefile +57 -0
  245. data/dyncall/dynload/README.txt +113 -0
  246. data/dyncall/dynload/TODO +20 -0
  247. data/dyncall/dynload/dynMakefile +4 -0
  248. data/dyncall/dynload/dynload.3 +64 -0
  249. data/dyncall/dynload/dynload.c +38 -0
  250. data/dyncall/dynload/dynload.h +65 -0
  251. data/dyncall/dynload/dynload_alloc.h +40 -0
  252. data/dyncall/dynload/dynload_darwin.c +89 -0
  253. data/dyncall/dynload/dynload_syms.c +38 -0
  254. data/dyncall/dynload/dynload_syms_elf.c +214 -0
  255. data/dyncall/dynload/dynload_syms_mach-o.c +167 -0
  256. data/dyncall/dynload/dynload_syms_pe.c +109 -0
  257. data/dyncall/dynload/dynload_unix.c +57 -0
  258. data/dyncall/dynload/dynload_windows.c +59 -0
  259. data/dyncall/mkfile +36 -0
  260. data/dyncall/portasm/README.txt +42 -0
  261. data/dyncall/portasm/gen-masm.sh +3 -0
  262. data/dyncall/portasm/portasm-arm.S +36 -0
  263. data/dyncall/portasm/portasm-ppc.S +98 -0
  264. data/dyncall/portasm/portasm-x64-att.S +155 -0
  265. data/dyncall/portasm/portasm-x86.S +127 -0
  266. metadata +311 -0
@@ -0,0 +1,70 @@
1
+ /*
2
+
3
+ Package: dyncall
4
+ Library: dyncall
5
+ File: dyncall/dyncall_call_x86.h
6
+ Description: heap memory management interface (header only)
7
+ License:
8
+
9
+ Copyright (c) 2007-2011 Daniel Adler <dadler@uni-goettingen.de>,
10
+ Tassilo Philipp <tphilipp@potion-studios.com>
11
+
12
+ Permission to use, copy, modify, and distribute this software for any
13
+ purpose with or without fee is hereby granted, provided that the above
14
+ copyright notice and this permission notice appear in all copies.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
17
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
18
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
19
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
21
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
22
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23
+
24
+ */
25
+
26
+
27
+ /*
28
+
29
+ dyncall 32bit Intel x86 family interface
30
+
31
+ REVISION
32
+ 2007/12/10 initial
33
+
34
+ */
35
+
36
+
37
+ #ifndef DYNCALL_CALL_X86_H
38
+ #define DYNCALL_CALL_X86_H
39
+
40
+
41
+ #include "dyncall_types.h"
42
+
43
+ #ifdef __cplusplus
44
+ extern "C" {
45
+ #endif
46
+
47
+ /*
48
+ ** x86 calling convention calls
49
+ **
50
+ ** - hybrid return-type call (bool ... pointer)
51
+ **
52
+ */
53
+
54
+ #if defined(DC__OS_Plan9) /* No support for other cconvs on Plan9 and vice-versa. */
55
+ void dcCall_x86_plan9 (DCpointer target, DCpointer stackdata, DCsize size);
56
+ #else
57
+ void dcCall_x86_cdecl (DCpointer target, DCpointer stackdata, DCsize size);
58
+ void dcCall_x86_win32_std (DCpointer target, DCpointer stackdata, DCsize size);
59
+ void dcCall_x86_win32_fast (DCpointer target, DCpointer stackdata, DCsize size);
60
+ void dcCall_x86_win32_msthis (DCpointer target, DCpointer stackdata, DCsize size);
61
+ void dcCall_x86_sys_int80h_linux (DCpointer target, DCpointer stackdata, DCsize size);
62
+ void dcCall_x86_sys_int80h_bsd (DCpointer target, DCpointer stackdata, DCsize size);
63
+ #endif
64
+
65
+ #ifdef __cplusplus
66
+ }
67
+ #endif
68
+
69
+
70
+ #endif /* DYNCALL_CALL_X86_H */
@@ -0,0 +1,127 @@
1
+ /*
2
+
3
+ Package: dyncall
4
+ Library: dyncall
5
+ File: dyncall/dyncall_call_x86_8a.s
6
+ Description: All x86 abi call kernel implementations in Plan9's assembler
7
+ License:
8
+
9
+ Copyright (c) 2007-2011 Daniel Adler <dadler@uni-goettingen.de>,
10
+ Tassilo Philipp <tphilipp@potion-studios.com>
11
+
12
+ Permission to use, copy, modify, and distribute this software for any
13
+ purpose with or without fee is hereby granted, provided that the above
14
+ copyright notice and this permission notice appear in all copies.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
17
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
18
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
19
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
21
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
22
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23
+
24
+ */
25
+
26
+
27
+
28
+ /* 64 bit integer return value calls require caller to create space for return
29
+ value, and pass a pointer to it as 1st argument. This main function handles
30
+ all cases (32 and 64 bit integers, as well as floats and doubles), however,
31
+ it has to be called through the 2 corresponding functions at the end of
32
+ this file.
33
+ In order to keep things simple, we basically put the pointer to the
34
+ return value in EDX and call the other assembler code, above. If EDX
35
+ is not null, then the code below will push it to the stack as first
36
+ argument.
37
+ */
38
+
39
+ call_main:
40
+
41
+ /* Since all registers except SP are scratch, and we have a variable
42
+ argument size depending on the function to call, we have to find
43
+ a way to store and restore SP.
44
+ The idea is to replace the return address with a custom one on the
45
+ stack, and to put some logic there, jumping back to the real
46
+ return address. This allows us, to put the SP somewhere next to
47
+ the fake return address on the stack, so that we can get it back
48
+ with a fixed offset (relative to the program counter, in our case).
49
+
50
+ The only real issue with this approach would be a non-executable
51
+ stack. However, Plan9 doesn't support w^x at the time of writing.
52
+ */
53
+
54
+ /* On the stack at this point:
55
+ RETADDR 0(SP)
56
+ FUNPTR 4(SP)
57
+ ARGS 8(SP)
58
+ SIZE 12(SP)
59
+ */
60
+
61
+ MOVL SP, BP /* base pointer for convenience */
62
+ PUSHL SP /* save stack pointer */
63
+
64
+ MOVL 8(BP), SI /* SI = pointer on args */
65
+ MOVL 12(BP), CX /* CX = size of args */
66
+
67
+ SUBL $16, SP /* Make some room for our SP-refetch logic */
68
+ MOVL SP, BX /* Copy address to new, executable stack space to BX */
69
+
70
+ /* This part fills our executable stack space with instructions. We
71
+ need to get the program counter, first, with a little hack. */
72
+ MOVL $0x000003e8, 0(SP) /* Copy 'call (cur ip+8)' */
73
+ MOVL $0x00000000, 4(SP) /* '00' for call address, rest is garbage */
74
+ MOVL $0x5a909090, 8(SP) /* 'nop, nop, nop, pop edx' to get eip+5 in edx */
75
+ MOVL $0xc30b628b,12(SP) /* Restore stack ptr and return: 'mov [edx+11] to esp, ret' */
76
+
77
+ SUBL CX, SP /* allocate 'size' bytes on stack for args */
78
+ MOVL SP, DI /* DI = stack args */
79
+
80
+ SHRL $2, SP /* Align stack. */
81
+ SHLL $2, SP /* " " */
82
+
83
+ /* I didn't figure out how to use MOVSB with the 8a syntax. The following
84
+ can probably be written in a better way. */
85
+ JMP copy_loop_cmp
86
+ copy_loop:
87
+ MOVL 0(SI), AX /* Copy args. */
88
+ MOVL AX, 0(DI)
89
+ SUBL $4, CX
90
+ ADDL $4, SI
91
+ ADDL $4, DI
92
+ copy_loop_cmp:
93
+ CMPL CX, $0
94
+ JGT copy_loop
95
+
96
+ /* Check if we need to push a pointer to long long that might be used as
97
+ container for 64-bit return values. */
98
+ CMPL DX, $0
99
+ JEQ call_ffi
100
+ PUSHL DX
101
+
102
+ /* Now we try to fake a call, meaning setting up our fake return address,
103
+ and then jumping to the FFI call. This should call the function, but
104
+ the return will jump into our stack space we reserved above. */
105
+ call_ffi:
106
+ PUSHL BX
107
+ MOVL 4(BP), BX
108
+ JMP BX
109
+
110
+ /* Note that there is no return here, b/c the return is in the asm code
111
+ above, that has been generated on the fly. */
112
+
113
+
114
+ /* Main call for 32 bit integer return values and floating point arguments.
115
+ See call_main for explanation. */
116
+ TEXT dcCall_x86_plan9(SB), $0
117
+
118
+ MOVL $0, DX
119
+ JMP call_main
120
+
121
+
122
+ /* Call for 64 bit integer return values.
123
+ See call_main for explanation. */
124
+ TEXT dcCall_x86_plan9_ll(SB), $0
125
+
126
+ MOVL 16(SP), DX /* Copy pointer to variable for return value. */
127
+ JMP call_main
@@ -0,0 +1,136 @@
1
+ ; auto-generated by gen-masm.sh
2
+ .386
3
+ .MODEL FLAT
4
+ .CODE
5
+
6
+ _dcCall_x86_cdecl PROC
7
+ OPTION PROLOGUE:NONE, EPILOGUE:NONE
8
+ push EBP
9
+ mov EBP,ESP
10
+ push ESI
11
+ push EDI
12
+ mov ESI,dword ptr [EBP+12]
13
+ mov ECX,dword ptr [EBP+16]
14
+ add ECX,15
15
+ and ECX,-16
16
+ mov dword ptr [EBP+16],ECX
17
+ sub ESP,ECX
18
+ mov EDI,ESP
19
+ rep movsb
20
+ call dword ptr [EBP+8]
21
+ add ESP,dword ptr [EBP+16]
22
+ pop EDI
23
+ pop ESI
24
+ mov ESP,EBP
25
+ pop EBP
26
+ ret
27
+ _dcCall_x86_cdecl ENDP
28
+ _dcCall_x86_win32_msthis PROC
29
+ OPTION PROLOGUE:NONE, EPILOGUE:NONE
30
+ push EBP
31
+ mov EBP,ESP
32
+ push ESI
33
+ push EDI
34
+ mov ESI,dword ptr [EBP+12]
35
+ mov ECX,dword ptr [EBP+16]
36
+ mov EAX,dword ptr [ESI+0]
37
+ add ESI,4
38
+ sub ECX,4
39
+ sub ESP,ECX
40
+ mov EDI,ESP
41
+ rep movsb
42
+ mov ECX,EAX
43
+ call dword ptr [EBP+8]
44
+ pop EDI
45
+ pop ESI
46
+ mov ESP,EBP
47
+ pop EBP
48
+ ret
49
+ _dcCall_x86_win32_msthis ENDP
50
+ _dcCall_x86_win32_std PROC
51
+ OPTION PROLOGUE:NONE, EPILOGUE:NONE
52
+ push EBP
53
+ mov EBP,ESP
54
+ push ESI
55
+ push EDI
56
+ mov ESI,dword ptr [EBP+12]
57
+ mov ECX,dword ptr [EBP+16]
58
+ sub ESP,ECX
59
+ mov EDI,ESP
60
+ rep movsb
61
+ call dword ptr [EBP+8]
62
+ pop EDI
63
+ pop ESI
64
+ mov ESP,EBP
65
+ pop EBP
66
+ ret
67
+ _dcCall_x86_win32_std ENDP
68
+ _dcCall_x86_win32_fast PROC
69
+ OPTION PROLOGUE:NONE, EPILOGUE:NONE
70
+ push EBP
71
+ mov EBP,ESP
72
+ push ESI
73
+ push EDI
74
+ mov ESI,dword ptr [EBP+12]
75
+ mov ECX,dword ptr [EBP+16]
76
+ mov EAX,dword ptr [ESI+0]
77
+ mov EDX,dword ptr [ESI+4]
78
+ add ESI,8
79
+ sub ECX,8
80
+ mov dword ptr [EBP+16],ECX
81
+ sub ESP,ECX
82
+ mov EDI,ESP
83
+ rep movsb
84
+ mov ECX,EAX
85
+ call dword ptr [EBP+8]
86
+ pop EDI
87
+ pop ESI
88
+ mov ESP,EBP
89
+ pop EBP
90
+ ret
91
+ _dcCall_x86_win32_fast ENDP
92
+ _dcCall_x86_sys_int80h_linux PROC
93
+ OPTION PROLOGUE:NONE, EPILOGUE:NONE
94
+ push EBP
95
+ mov EBP,ESP
96
+ push EBX
97
+ push ESI
98
+ push EDI
99
+ mov EAX,dword ptr [EBP+12]
100
+ mov EBX,dword ptr [EAX+0]
101
+ mov ECX,dword ptr [EAX+4]
102
+ mov EDX,dword ptr [EAX+8]
103
+ mov ESI,dword ptr [EAX+12]
104
+ mov EDI,dword ptr [EAX+16]
105
+ mov EAX,dword ptr [EBP+8]
106
+ int 80h
107
+ pop EDI
108
+ pop ESI
109
+ pop EBX
110
+ mov ESP,EBP
111
+ pop EBP
112
+ ret
113
+ _dcCall_x86_sys_int80h_linux ENDP
114
+ _dcCall_x86_sys_int80h_bsd PROC
115
+ OPTION PROLOGUE:NONE, EPILOGUE:NONE
116
+ push EBP
117
+ mov EBP,ESP
118
+ push ESI
119
+ push EDI
120
+ mov ESI,dword ptr [EBP+12]
121
+ mov ECX,dword ptr [EBP+16]
122
+ sub ESP,ECX
123
+ mov EDI,ESP
124
+ rep movsb
125
+ mov EAX,dword ptr [EBP+8]
126
+ call _do_int
127
+ pop EDI
128
+ pop ESI
129
+ mov ESP,EBP
130
+ pop EBP
131
+ ret
132
+ _do_int:
133
+ int 80h
134
+ ret
135
+ _dcCall_x86_sys_int80h_bsd ENDP
136
+ END
@@ -0,0 +1,234 @@
1
+ ;//////////////////////////////////////////////////////////////////////////////
2
+ ;
3
+ ; Copyright (c) 2007,2009 Daniel Adler <dadler@uni-goettingen.de>,
4
+ ; Tassilo Philipp <tphilipp@potion-studios.com>
5
+ ;
6
+ ; Permission to use, copy, modify, and distribute this software for any
7
+ ; purpose with or without fee is hereby granted, provided that the above
8
+ ; copyright notice and this permission notice appear in all copies.
9
+ ;
10
+ ; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
+ ; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
+ ; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
+ ; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
+ ; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
+ ; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
+ ; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
+ ;
18
+ ;//////////////////////////////////////////////////////////////////////////////
19
+
20
+ ;///////////////////////////////////////////////////////////////////////
21
+ ;
22
+ ; dyncall_call_x86_nasm.nasm
23
+ ;
24
+ ; X86 Calls for nasm assembler
25
+ ;
26
+ ;///////////////////////////////////////////////////////////////////////
27
+
28
+
29
+ BITS 32
30
+ section .text
31
+
32
+ ;///////////////////////////////////////////////////////////////////////
33
+ ; CSYM macro
34
+ ;///////////////////////////////////////////////////////////////////////
35
+
36
+ %ifdef BUILD_OS_windows
37
+
38
+ %macro EXPORT_C 1
39
+ global _%1
40
+ _%1:
41
+ %endmacro
42
+
43
+ %else
44
+
45
+ %macro EXPORT_C 1
46
+ global %1
47
+ %1:
48
+ %endmacro
49
+
50
+ %endif
51
+
52
+ ; -----------------------------------------------------------------------------
53
+ ; Calling Convention x86 standard C
54
+ ; - all arguments are on the stack
55
+ ; - caller cleans up stack
56
+ ;
57
+ ; C proto
58
+ ; dcCallC(DCptr funptr, DCptr args, DCsize size)
59
+ ; -----------------------------------------------------------------------------
60
+
61
+ EXPORT_C dcCall_x86_cdecl
62
+
63
+ push ebp ; prolog
64
+ mov ebp, esp
65
+
66
+ ; arguments:
67
+ ;
68
+ ; funptr ebp+8
69
+ ; args ebp+12
70
+ ; size ebp+16
71
+ ; result ebp+20
72
+
73
+ push esi ; save esi, edi
74
+ push edi
75
+
76
+ mov esi, [ebp+12] ; esi = pointer on args
77
+ mov ecx, [ebp+16] ; ecx = size
78
+
79
+ sub esp, ecx ; cdecl call: allocate 'size' bytes on stack
80
+ mov edi, esp ; edi = stack args
81
+
82
+ rep movsb ; copy arguments
83
+
84
+ call [ebp+8] ; call function
85
+
86
+ add esp, [ebp+16] ; cdecl call: cleanup stack
87
+
88
+ pop edi ; restore edi, esi
89
+ pop esi
90
+
91
+ mov esp, ebp ; epilog
92
+ pop ebp
93
+
94
+ ret
95
+
96
+ ; -----------------------------------------------------------------------------
97
+ ; Calling Convention x86 microsoft thiscall
98
+ ; - thispointer is in ECX, rest is on the stack
99
+ ; - callee cleans up stack
100
+ ;
101
+ ; C proto
102
+ ; dcCallThisMS(DCptr funptr, DCptr args, DCsize size)
103
+ ; -----------------------------------------------------------------------------
104
+ EXPORT_C dcCall_x86_win32_msthis
105
+
106
+ push ebp ; prolog
107
+ mov ebp, esp
108
+
109
+ ; arguments:
110
+ ;
111
+ ; funptr ebp+8
112
+ ; args ebp+12
113
+ ; size ebp+16
114
+
115
+ push esi ; save esi, edi
116
+ push edi
117
+
118
+ mov esi, [ebp+12] ; esi = pointer on args
119
+ mov ecx, [ebp+16] ; ecx = size
120
+
121
+ mov eax, [esi] ; eax = this pointer
122
+ add esi, 4 ; increment args pointer by thisptr
123
+ sub ecx, 4 ; decrement size by sizeof(thisptr)
124
+
125
+ sub esp, ecx ; allocate argument-block on stack
126
+ mov edi, esp ; edi = stack args
127
+
128
+ rep movsb ; copy arguments
129
+
130
+ mov ecx, eax ; ecx = this pointer
131
+
132
+ call [ebp+8] ; call function (thiscall: cleanup by callee)
133
+
134
+ pop edi ; restore edi, esi
135
+ pop esi
136
+
137
+ mov esp, ebp ; epilog
138
+ pop ebp
139
+
140
+ ret
141
+
142
+ ; -----------------------------------------------------------------------------
143
+ ; Calling Convention x86 win32 stdcall
144
+ ; - all arguments are passed by stack
145
+ ; - callee cleans up stack
146
+ ;
147
+ ; C proto
148
+ ; dcCallStd(DCptr funptr, DCptr args, DCsize size)
149
+ ; -----------------------------------------------------------------------------
150
+ EXPORT_C dcCall_x86_win32_std
151
+
152
+ push ebp ; prolog
153
+ mov ebp, esp
154
+
155
+ ; arguments:
156
+ ;
157
+ ; funptr ebp+8
158
+ ; args ebp+12
159
+ ; size ebp+16
160
+
161
+ push esi ; save esi, edi
162
+ push edi
163
+
164
+ mov esi, [ebp+12] ; esi = pointer on args
165
+ mov ecx, [ebp+16] ; ecx = size
166
+
167
+ sub esp, ecx ; stdcall: allocate 'size'-8 bytes on stack
168
+ mov edi, esp ; edi = stack args
169
+
170
+ rep movsb ; copy arguments
171
+
172
+ call [ebp+8] ; call function (stdcall: cleanup by callee)
173
+
174
+ pop edi ; restore edi, esi
175
+ pop esi
176
+
177
+ mov esp, ebp ; epilog
178
+ pop ebp
179
+
180
+ ret
181
+
182
+ ; -----------------------------------------------------------------------------
183
+ ; Calling Convention x86 win32 fastcall
184
+ ; - first two integer (up to 32bits) are passed in ECX and EDX
185
+ ; - others are passed on the stack
186
+ ; - callee cleans up stack
187
+ ;
188
+ ; C proto
189
+ ; dcCallFast(DCptr funptr, DCptr args, DCsize size)
190
+ ; -----------------------------------------------------------------------------
191
+ EXPORT_C dcCall_x86_win32_fast
192
+
193
+ push ebp ; prolog
194
+ mov ebp, esp
195
+
196
+ ; arguments:
197
+ ;
198
+ ; funptr ebp+8
199
+ ; args ebp+12
200
+ ; size ebp+16
201
+
202
+ push esi ; save esi, edi
203
+ push edi
204
+
205
+ mov esi, [ebp+12] ; esi = pointer on args
206
+ mov ecx, [ebp+16] ; ecx = size
207
+ mov eax, [esi] ; eax = first argument
208
+ mov edx, [esi+4] ; edx = second argument
209
+ add esi, 8 ; increment source pointer
210
+ sub ecx, 8 ; decrement size by 8
211
+
212
+ sub esp, ecx ; fastcall: allocate 'size'-8 bytes on stack
213
+ mov edi, esp ; edi = stack args
214
+
215
+ rep movsb ; copy arguments
216
+
217
+ mov ecx, eax ; ecx = first argument
218
+
219
+ call [ebp+8] ; call function (fastcall: cleanup by callee)
220
+
221
+ pop edi ; restore edi, esi
222
+ pop esi
223
+
224
+ mov esp, ebp ; epilog
225
+ pop ebp
226
+
227
+ ret
228
+
229
+ ; Stack markings for ELF/GNU to specify no executable stack */
230
+
231
+ %ifidn __OUTPUT_FORMAT__,elf
232
+ section .note.GNU-stack noalloc noexec nowrite progbits
233
+ %endif
234
+