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,115 @@
1
+ /*
2
+
3
+ Package: dyncall
4
+ Library: dyncallback
5
+ File: dyncallback/dyncall_callback_x86.S
6
+ Description: Callback Thunk entry for x86
7
+ License:
8
+
9
+ Copyright (c) 2011 Daniel Adler <dadler@uni-goettingen.de>
10
+
11
+ Permission to use, copy, modify, and distribute this software for any
12
+ purpose with or without fee is hereby granted, provided that the above
13
+ copyright notice and this permission notice appear in all copies.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
16
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
18
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
+
23
+ */
24
+
25
+ #include "../portasm/portasm-x86.S"
26
+ BEGIN_ASM
27
+ DCThunk_size = 16
28
+ DCArgs_size = 20
29
+ DCValue_size = 8
30
+
31
+ CTX_thunk = 0
32
+ CTX_phandler = 16
33
+ CTX_pargsvt = 20
34
+ CTX_stack_cleanup = 24
35
+ CTX_userdata = 28
36
+
37
+ frame_arg0 = 8
38
+ frame_ret = 4
39
+ frame_parent = 0
40
+ frame_CTX = -4
41
+ frame_DCArgs = -24
42
+ frame_DCValue = -32
43
+
44
+ #define ASCII_L 76
45
+ #define ASCII_l 108
46
+ #define ASCII_d 100
47
+ #define ASCII_f 102
48
+ #define ASCII_i 105
49
+ #define ASCII_v 118
50
+
51
+ GLOBAL(dcCallbackThunkEntry)
52
+ BEGIN_PROC(dcCallbackThunkEntry)
53
+ PUSH(EBP)
54
+ MOVL(ESP,EBP)
55
+ /* local variable frame_CTX) */
56
+ PUSH(EAX) /* EAX = CTX* */
57
+ /* initialize DCArgs */
58
+ PUSH(LIT(0)) /* fast_count */
59
+ PUSH(EDX) /* fast_data[1] */
60
+ PUSH(ECX) /* fast_data[0] */
61
+ LEA(DWORD(EBP,frame_arg0),ECX) /* compute arg stack address */
62
+ PUSH(ECX) /* stack-ptr */
63
+ PUSH(DWORD(EAX,CTX_pargsvt)) /* vtbl-ptr */
64
+ MOVL(ESP,ECX) /* ECX = DCArgs* */
65
+ /* initialize DCvalue */
66
+ PUSH(LIT(0))
67
+ PUSH(LIT(0))
68
+
69
+ MOVL(ESP,EDX) /* EDX = DCValue* */
70
+ ANDL(LIT(-16),ESP) /* align stack to 16 bytes. */
71
+ /* call handler(context) */
72
+ PUSH(DWORD(EAX,CTX_userdata)) /* userdata */
73
+ PUSH(EDX) /* DCValue* */
74
+ PUSH(ECX) /* DCargs* */
75
+ PUSH(EAX) /* DCCallback* */
76
+ CALL_DWORD(EAX,CTX_phandler)
77
+ /* cleanup stack */
78
+ MOVL(EBP,ESP) /* reset esp to frame */
79
+ POP(ECX) /* skip parent frame */
80
+ POP(ECX) /* pop return address */
81
+ MOVL(DWORD(EBP,frame_CTX),EDX)
82
+ ADD(DWORD(EDX,CTX_stack_cleanup),ESP) /* cleanup stack */
83
+ PUSH(ECX) /* push back return address */
84
+ LEA(DWORD(EBP,frame_DCValue), EDX)
85
+ MOVL(DWORD(EBP,0), EBP) /* EBP = parent frame */
86
+ /* handle return value */
87
+ CMP(LIT(ASCII_v),AL)
88
+ JE(LOCAL(return_void))
89
+ CMP(LIT(ASCII_d),AL)
90
+ JE(LOCAL(return_f64))
91
+ CMP(LIT(ASCII_f),AL)
92
+ JE(LOCAL(return_f32))
93
+ CMP(LIT(ASCII_l),AL)
94
+ JE(LOCAL(return_i64))
95
+ CMP(LIT(ASCII_L),AL)
96
+ JE(LOCAL(return_i64))
97
+
98
+ /* All int cases <= 32 bits (+ pointer & string cases) fall in the 32 bits int case*/
99
+ LOCAL(return_i32):
100
+ MOVL(DWORD(EDX,0),EAX)
101
+ RET()
102
+ LOCAL(return_i64):
103
+ MOVL(DWORD(EDX,0),EAX)
104
+ MOVL(DWORD(EDX,4),EDX)
105
+ RET()
106
+ LOCAL(return_f32):
107
+ FLDS(DWORD(EDX,0))
108
+ RET()
109
+ LOCAL(return_f64):
110
+ FLDL(QWORD(EDX,0))
111
+ LOCAL(return_void):
112
+ RET()
113
+ END_PROC(dcCallbackThunkEntry)
114
+ END_ASM
115
+
@@ -0,0 +1,281 @@
1
+ /*
2
+
3
+ Package: dyncall
4
+ Library: dyncallback
5
+ File: dyncallback/dyncall_callback_x86.c
6
+ Description: Callback - Implementation for x86
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
+ #include "dyncall_callback_x86.h"
28
+ #include "dyncall_args_x86.h"
29
+
30
+ #include "dyncall_alloc_wx.h"
31
+ #include "dyncall_signature.h"
32
+
33
+ /*
34
+ * assembly thunk entry for callbacks
35
+ */
36
+
37
+ extern void dcCallbackThunkEntry();
38
+
39
+ /* compute stacksize for callee cleanup calling conventions:
40
+ *
41
+ * stdcall,fastcall_ms,fastcall_gnu
42
+ */
43
+
44
+ static int dcbCleanupSize_x86_cdecl(const char* signature)
45
+ {
46
+ return 0;
47
+ }
48
+
49
+ static int dcbCleanupSize_x86_std(const char* signature)
50
+ {
51
+ const char* ptr = signature;
52
+ int size = 0;
53
+ char ch;
54
+ while( (ch = *ptr++) != DC_SIGCHAR_ENDARG ) {
55
+ switch(ch) {
56
+ case DC_SIGCHAR_BOOL:
57
+ case DC_SIGCHAR_CHAR:
58
+ case DC_SIGCHAR_SHORT:
59
+ case DC_SIGCHAR_INT:
60
+ case DC_SIGCHAR_LONG:
61
+ case DC_SIGCHAR_POINTER:
62
+ case DC_SIGCHAR_UCHAR:
63
+ case DC_SIGCHAR_USHORT:
64
+ case DC_SIGCHAR_UINT:
65
+ case DC_SIGCHAR_ULONG:
66
+ case DC_SIGCHAR_STRING:
67
+ case DC_SIGCHAR_FLOAT:
68
+ size += 4;
69
+ break;
70
+ case DC_SIGCHAR_DOUBLE:
71
+ case DC_SIGCHAR_LONGLONG:
72
+ case DC_SIGCHAR_ULONGLONG:
73
+ size += 8;
74
+ break;
75
+ }
76
+ }
77
+ return size;
78
+ }
79
+
80
+ static int dcbCleanupSize_x86_this_ms(const char* signature)
81
+ {
82
+ const char* ptr = signature;
83
+ int size = 0;
84
+ char ch;
85
+ while( (ch = *ptr++) != DC_SIGCHAR_ENDARG )
86
+ {
87
+ switch(ch)
88
+ {
89
+ case DC_SIGCHAR_BOOL:
90
+ case DC_SIGCHAR_CHAR:
91
+ case DC_SIGCHAR_SHORT:
92
+ case DC_SIGCHAR_INT:
93
+ case DC_SIGCHAR_LONG:
94
+ case DC_SIGCHAR_POINTER:
95
+ case DC_SIGCHAR_UCHAR:
96
+ case DC_SIGCHAR_USHORT:
97
+ case DC_SIGCHAR_UINT:
98
+ case DC_SIGCHAR_ULONG:
99
+ case DC_SIGCHAR_STRING:
100
+ case DC_SIGCHAR_FLOAT:
101
+ size += 4;
102
+ break;
103
+ case DC_SIGCHAR_DOUBLE:
104
+ case DC_SIGCHAR_LONGLONG:
105
+ case DC_SIGCHAR_ULONGLONG:
106
+ size += 8;
107
+ break;
108
+ }
109
+ }
110
+ return size;
111
+ }
112
+
113
+ static int dcbCleanupSize_x86_fast_ms(const char* signature)
114
+ {
115
+ const char* ptr = signature;
116
+ int size = 0;
117
+ int regs = 0;
118
+ char ch;
119
+ while( (ch = *ptr++) != DC_SIGCHAR_ENDARG )
120
+ {
121
+ switch(ch)
122
+ {
123
+ case DC_SIGCHAR_BOOL:
124
+ case DC_SIGCHAR_CHAR:
125
+ case DC_SIGCHAR_SHORT:
126
+ case DC_SIGCHAR_INT:
127
+ case DC_SIGCHAR_LONG:
128
+ case DC_SIGCHAR_POINTER:
129
+ case DC_SIGCHAR_UCHAR:
130
+ case DC_SIGCHAR_USHORT:
131
+ case DC_SIGCHAR_UINT:
132
+ case DC_SIGCHAR_ULONG:
133
+ case DC_SIGCHAR_STRING:
134
+ if (regs < 2) regs++;
135
+ else size += 4;
136
+ break;
137
+ case DC_SIGCHAR_FLOAT:
138
+ size += 4;
139
+ break;
140
+ case DC_SIGCHAR_DOUBLE:
141
+ size += 8;
142
+ break;
143
+ case DC_SIGCHAR_LONGLONG:
144
+ case DC_SIGCHAR_ULONGLONG:
145
+ size += 8;
146
+ break;
147
+ }
148
+ }
149
+ return size;
150
+ }
151
+
152
+ static int dcbCleanupSize_x86_fast_gnu(const char* signature)
153
+ {
154
+ const char* ptr = signature;
155
+ char ch;
156
+ int size = 0;
157
+ int regs = 0;
158
+ while( (ch = *ptr++) != DC_SIGCHAR_ENDARG ) {
159
+ switch(ch) {
160
+ case DC_SIGCHAR_FLOAT:
161
+ size += 4;
162
+ break;
163
+ case DC_SIGCHAR_DOUBLE:
164
+ size += 8;
165
+ break;
166
+ case DC_SIGCHAR_LONGLONG:
167
+ case DC_SIGCHAR_ULONGLONG:
168
+ regs = 2;
169
+ size += 8;
170
+ break;
171
+ default:
172
+ if (regs < 2) regs++;
173
+ else size += 4;
174
+ break;
175
+ }
176
+ }
177
+ return size;
178
+ }
179
+
180
+ void dcbInitCallback(DCCallback* pcb, const char* signature, DCCallbackHandler* handler, void* userdata)
181
+ {
182
+ const char* ptr;
183
+ char ch;
184
+ int mode;
185
+ pcb->handler = handler;
186
+ pcb->userdata = userdata;
187
+
188
+ ptr = signature;
189
+ ch = *ptr;
190
+
191
+ /* x86 hints: */
192
+
193
+ mode = DC_CALL_C_X86_CDECL;
194
+
195
+ if(ch == DC_SIGCHAR_CC_PREFIX)
196
+ {
197
+ ptr++;
198
+ ch = *ptr++;
199
+ switch(ch) {
200
+ case DC_SIGCHAR_CC_STDCALL: mode = DC_CALL_C_X86_WIN32_STD; break;
201
+ case DC_SIGCHAR_CC_THISCALL_MS: mode = DC_CALL_C_X86_WIN32_THIS_MS; break;
202
+ case DC_SIGCHAR_CC_FASTCALL_GNU: mode = DC_CALL_C_X86_WIN32_FAST_GNU; break;
203
+ case DC_SIGCHAR_CC_FASTCALL_MS: mode = DC_CALL_C_X86_WIN32_FAST_MS; break;
204
+ }
205
+ }
206
+
207
+ /* x86 configuration: */
208
+
209
+ switch(mode) {
210
+ case DC_CALL_C_X86_CDECL:
211
+ pcb->args_vt = &dcArgsVT_default;
212
+ pcb->stack_cleanup = dcbCleanupSize_x86_cdecl(ptr);
213
+ break;
214
+ case DC_CALL_C_X86_WIN32_STD:
215
+ pcb->args_vt = &dcArgsVT_default;
216
+ pcb->stack_cleanup = dcbCleanupSize_x86_std(ptr);
217
+ break;
218
+ case DC_CALL_C_X86_WIN32_THIS_MS:
219
+ pcb->args_vt = &dcArgsVT_this_ms;
220
+ pcb->stack_cleanup = dcbCleanupSize_x86_this_ms(ptr);
221
+ break;
222
+ case DC_CALL_C_X86_WIN32_FAST_MS:
223
+ pcb->args_vt = &dcArgsVT_fast_ms;
224
+ pcb->stack_cleanup = dcbCleanupSize_x86_fast_ms(ptr);
225
+ break;
226
+ case DC_CALL_C_X86_WIN32_FAST_GNU:
227
+ pcb->args_vt = &dcArgsVT_fast_gnu;
228
+ pcb->stack_cleanup = dcbCleanupSize_x86_fast_gnu(ptr);
229
+ break;
230
+ }
231
+
232
+ #if defined(DC_PLAN9)
233
+ /* HACK for Plan9 - 'reuse' pcb->stack_cleanup as a flag
234
+ to indicate if return value is 64bit. The field is not
235
+ used anyways as the caller is responsible to clean up
236
+ the stack in Plan9. If set to '1' the callback kernel
237
+ takes into account an extra stack-parameter (pointer
238
+ to 64bit return value).
239
+ I thought of introducing a new field, but for one single
240
+ x86 calling convention out of many, it seemed overkill
241
+ to change the struct for everybody else. Maybe renaming
242
+ would be a good idea, though. ~ Tassilo
243
+ */
244
+ while(*ptr) {
245
+ if(*ptr++ == DC_SIGCHAR_ENDARG) {
246
+ pcb->stack_cleanup = (*ptr == DC_SIGCHAR_LONGLONG) || (*ptr == DC_SIGCHAR_ULONGLONG);
247
+ break;
248
+ }
249
+ }
250
+ #endif
251
+ }
252
+
253
+ /*
254
+ * callback constructor
255
+ */
256
+
257
+ DCCallback* dcbNewCallback(const char* signature, DCCallbackHandler* handler, void* userdata)
258
+ {
259
+ int err;
260
+ DCCallback* pcb;
261
+ err = dcAllocWX(sizeof(DCCallback), (void**) &pcb);
262
+ if (err != 0) return 0;
263
+
264
+ dcbInitThunk(&pcb->thunk, dcCallbackThunkEntry);
265
+ dcbInitCallback(pcb, signature, handler, userdata);
266
+ return pcb;
267
+ }
268
+
269
+ /*
270
+ * free
271
+ */
272
+
273
+ void dcbFreeCallback(DCCallback* pcb)
274
+ {
275
+ dcFreeWX(pcb, sizeof(DCCallback));
276
+ }
277
+
278
+ void* dcbGetUserData(DCCallback* pcb)
279
+ {
280
+ return pcb->userdata;
281
+ }
@@ -0,0 +1,49 @@
1
+ /*
2
+
3
+ Package: dyncall
4
+ Library: dyncallback
5
+ File: dyncallback/dyncall_callback_x86.h
6
+ Description: Callback - Header for x86
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
+ #ifndef DYNCALL_CALLBACK_X86_H_
28
+ #define DYNCALL_CALLBACK_X86_H_
29
+
30
+ #include "dyncall_callback.h"
31
+
32
+ #include "dyncall_thunk.h"
33
+ #include "dyncall_args_x86.h"
34
+
35
+ struct DCCallback
36
+ {
37
+ DCThunk thunk; /* offset 0, size 16 */
38
+ DCCallbackHandler* handler; /* offset 16 */
39
+ DCArgsVT* args_vt; /* offset 20 */
40
+ size_t stack_cleanup; /* offset 24 */
41
+ void* userdata; /* offset 28 */
42
+ };
43
+
44
+ int dcCleanupSize_x86_cdecl (const char* args_signature);
45
+ int dcCleanupSize_x86_std (const char* args_signature);
46
+ int dcCleanupSize_x86_fast_ms (const char* args_signature);
47
+ int dcCleanupSize_x86_fast_gnu(const char* args_signature);
48
+
49
+ #endif /* DYNCALL_CALLBACK_X86_H_ */
@@ -0,0 +1,100 @@
1
+ /*
2
+
3
+ Package: dyncall
4
+ Library: dyncall
5
+ File: dyncall/dyncall_callback_x86_8a.s
6
+ Description: x86 abi callback kernel implementation for Plan9's 8a
7
+ License:
8
+
9
+ Copyright (c) 2013 Tassilo Philipp <tphilipp@potion-studios.com>
10
+
11
+ Permission to use, copy, modify, and distribute this software for any
12
+ purpose with or without fee is hereby granted, provided that the above
13
+ copyright notice and this permission notice appear in all copies.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
16
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
18
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
+
23
+ */
24
+
25
+
26
+ TEXT dcCallbackThunkEntry(SB), $0
27
+
28
+ /* input:
29
+ AX -> thunk
30
+ AX+16 -> cb handler
31
+ AX+20 -> dcargsvt
32
+ AX+24 -> stack cleanup <-- not used for stack cleaning as caller cleans up,
33
+ AX+28 -> userdata however reused as flag to indicate 64bit return value)
34
+ */
35
+
36
+ /* prolog */
37
+ MOVL SP, BP
38
+
39
+ /* copy of DCargs passed to cb handler */
40
+ PUSHL $0 /* fast_count (unused on plan9, but using shared x86 dcargs struct) */
41
+ SUBL $8, SP /* skip fast_data[] ( " ) */
42
+ LEAL 8(BP), CX /* ptr to args on stack, depending if return val is 64bit ... */
43
+ CMPL 24(AX), $1
44
+ JEQ is_ll_ret
45
+ LEAL 4(BP), CX /* ... or not */
46
+ is_ll_ret:
47
+ PUSHL CX
48
+ PUSHL 20(AX) /* args vtable ptr */
49
+ MOVL SP, CX /* DCArgs-ptr (data pushed above) */
50
+
51
+ /* space for return value (long long) */
52
+ PUSHL $0
53
+ PUSHL $0
54
+ MOVL SP, DX /* retval ptr */
55
+
56
+ /* call the handler */
57
+ PUSHL 28(AX) /* userdata for handler */
58
+ PUSHL DX /* results */
59
+ PUSHL CX /* args */
60
+ PUSHL AX /* callback obj */
61
+ MOVL 16(AX), AX
62
+ CALL AX
63
+
64
+ /* copy retval from ptr on stack to AX or stack space if 64bit */
65
+ MOVL 8(SP), BX /* ptr to retval */
66
+ CMPL AX, $0x6c /* 'l' @@@ compares return from handler, might be different from sig - design currently in discussion */
67
+ JEQ ll_ret;
68
+ CMPL AX, $0x4c /* 'L' @@@ compares return from handler, might be different from sig - design currently in discussion */
69
+ JEQ ll_ret;
70
+ CMPL AX, $0x66 /* 'f' @@@ compares return from handler, might be different from sig - design currently in discussion */
71
+ JEQ f_ret;
72
+ CMPL AX, $0x64 /* 'd' @@@ compares return from handler, might be different from sig - design currently in discussion */
73
+ JEQ d_ret;
74
+ JMP other_ret
75
+
76
+ ll_ret:
77
+ MOVL 48(SP), DX /* ptr to ret address space; 48 = stack size + caller's ret address */
78
+ MOVL (BX), CX
79
+ MOVL CX, (DX)
80
+ MOVL 4(BX), CX
81
+ MOVL CX, 4(DX)
82
+ JMP cont_ret
83
+
84
+ f_ret:
85
+ FMOVF (BX), F0
86
+ JMP cont_ret
87
+
88
+ d_ret:
89
+ FMOVD (BX), F0
90
+ JMP cont_ret
91
+
92
+ other_ret:
93
+ MOVL (BX), AX /* 32bit non-fp are returned in AX */
94
+
95
+ /* epilog */
96
+ cont_ret:
97
+ ADDL $44, SP /* Cleanup stack */
98
+ POPL CX /* hack to emulate RET without getting overly strict */
99
+ JMP CX /* 'unbalanced PUSH/POP' warning/error from 8l */
100
+