rbdc 0.9.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/dyncall/BUGS +1 -1
  3. data/dyncall/CMakeLists.txt +19 -7
  4. data/dyncall/ChangeLog +61 -20
  5. data/dyncall/LICENSE +1 -1
  6. data/dyncall/Makefile.generic +2 -0
  7. data/dyncall/ToDo +97 -29
  8. data/dyncall/autovar/README.txt +1 -0
  9. data/dyncall/autovar/autovar_ABI.h +4 -2
  10. data/dyncall/autovar/autovar_ARCH.h +9 -5
  11. data/dyncall/autovar/autovar_CC.h +3 -1
  12. data/dyncall/autovar/autovar_OS.h +2 -2
  13. data/dyncall/autovar/autovar_OSFAMILY.h +1 -1
  14. data/dyncall/configure +94 -38
  15. data/dyncall/dyncall/dyncall.3 +8 -4
  16. data/dyncall/dyncall/dyncall.h +1 -1
  17. data/dyncall/dyncall/dyncall_alloc.h +1 -1
  18. data/dyncall/dyncall/dyncall_api.c +3 -1
  19. data/dyncall/dyncall/dyncall_call.S +13 -5
  20. data/dyncall/dyncall/dyncall_call_arm32_arm.S +1 -2
  21. data/dyncall/dyncall/dyncall_call_arm32_arm.h +1 -1
  22. data/dyncall/dyncall/dyncall_call_arm32_arm_armhf.S +24 -26
  23. data/dyncall/dyncall/dyncall_call_arm32_arm_armhf.h +1 -1
  24. data/dyncall/dyncall/dyncall_call_arm32_thumb.h +1 -1
  25. data/dyncall/dyncall/dyncall_call_arm32_thumb_armhf.S +1 -1
  26. data/dyncall/dyncall/dyncall_call_arm32_thumb_gas.s +3 -7
  27. data/dyncall/dyncall/dyncall_call_arm64.S +2 -2
  28. data/dyncall/dyncall/dyncall_call_arm64.h +2 -2
  29. data/dyncall/dyncall/dyncall_call_mips.h +1 -1
  30. data/dyncall/dyncall/dyncall_call_mips_eabi.h +1 -1
  31. data/dyncall/dyncall/dyncall_call_mips_eabi_gas.s +16 -16
  32. data/dyncall/dyncall/dyncall_call_mips_gas.S +2 -2
  33. data/dyncall/dyncall/dyncall_call_mips_n32.h +5 -4
  34. data/dyncall/dyncall/dyncall_call_mips_n32_gas.s +4 -4
  35. data/dyncall/dyncall/dyncall_call_mips_n64.h +3 -3
  36. data/dyncall/dyncall/dyncall_call_mips_n64_gas.s +2 -2
  37. data/dyncall/dyncall/dyncall_call_mips_o32.h +4 -3
  38. data/dyncall/dyncall/dyncall_call_mips_o32_gas.s +1 -3
  39. data/dyncall/dyncall/dyncall_call_ppc32.S +1 -1
  40. data/dyncall/dyncall/dyncall_call_ppc32.h +1 -1
  41. data/dyncall/dyncall/dyncall_call_sparc.h +1 -1
  42. data/dyncall/dyncall/{dyncall_call_sparc.S → dyncall_call_sparc.s} +39 -44
  43. data/dyncall/dyncall/dyncall_call_sparc64.h +5 -5
  44. data/dyncall/dyncall/dyncall_call_sparc64.s +177 -0
  45. data/dyncall/dyncall/dyncall_call_x64.S +83 -86
  46. data/dyncall/dyncall/dyncall_call_x64.h +1 -1
  47. data/dyncall/dyncall/dyncall_call_x86.S +9 -9
  48. data/dyncall/dyncall/dyncall_call_x86.h +1 -1
  49. data/dyncall/dyncall/dyncall_call_x86_nasm.asm +5 -5
  50. data/dyncall/dyncall/dyncall_callf.c +18 -18
  51. data/dyncall/dyncall/dyncall_callf.h +1 -1
  52. data/dyncall/dyncall/dyncall_callvm.c +3 -3
  53. data/dyncall/dyncall/dyncall_callvm.h +1 -1
  54. data/dyncall/dyncall/dyncall_callvm_arm32_arm.c +25 -40
  55. data/dyncall/dyncall/dyncall_callvm_arm32_arm.h +1 -5
  56. data/dyncall/dyncall/dyncall_callvm_arm32_arm_armhf.c +25 -33
  57. data/dyncall/dyncall/dyncall_callvm_arm32_arm_armhf.h +1 -5
  58. data/dyncall/dyncall/dyncall_callvm_arm32_thumb.c +24 -36
  59. data/dyncall/dyncall/dyncall_callvm_arm32_thumb.h +1 -5
  60. data/dyncall/dyncall/dyncall_callvm_arm64.c +23 -27
  61. data/dyncall/dyncall/dyncall_callvm_arm64.h +2 -6
  62. data/dyncall/dyncall/dyncall_callvm_arm64_apple.c +23 -30
  63. data/dyncall/dyncall/dyncall_callvm_base.c +1 -1
  64. data/dyncall/dyncall/dyncall_callvm_mips.c +1 -1
  65. data/dyncall/dyncall/dyncall_callvm_mips.h +1 -1
  66. data/dyncall/dyncall/dyncall_callvm_mips_eabi.c +30 -27
  67. data/dyncall/dyncall/dyncall_callvm_mips_eabi.h +1 -5
  68. data/dyncall/dyncall/dyncall_callvm_mips_n32.c +24 -30
  69. data/dyncall/dyncall/{dyncall_call_sparc_v9.h → dyncall_callvm_mips_n32.h} +18 -8
  70. data/dyncall/dyncall/dyncall_callvm_mips_n64.c +23 -30
  71. data/dyncall/dyncall/dyncall_callvm_mips_n64.h +4 -6
  72. data/dyncall/dyncall/dyncall_callvm_mips_o32.c +31 -29
  73. data/dyncall/dyncall/dyncall_callvm_mips_o32.h +1 -3
  74. data/dyncall/dyncall/dyncall_callvm_ppc32.c +22 -20
  75. data/dyncall/dyncall/dyncall_callvm_ppc32.h +1 -3
  76. data/dyncall/dyncall/dyncall_callvm_ppc64.c +54 -15
  77. data/dyncall/dyncall/dyncall_callvm_ppc64.h +0 -2
  78. data/dyncall/dyncall/dyncall_callvm_sparc.c +34 -26
  79. data/dyncall/dyncall/dyncall_callvm_sparc.h +1 -3
  80. data/dyncall/dyncall/dyncall_callvm_sparc64.c +94 -150
  81. data/dyncall/dyncall/dyncall_callvm_sparc64.h +11 -17
  82. data/dyncall/dyncall/dyncall_callvm_x64.c +37 -36
  83. data/dyncall/dyncall/dyncall_callvm_x64.h +1 -4
  84. data/dyncall/dyncall/dyncall_callvm_x86.c +22 -63
  85. data/dyncall/dyncall/dyncall_callvm_x86.h +1 -17
  86. data/dyncall/dyncall/dyncall_config.h +1 -1
  87. data/dyncall/dyncall/dyncall_macros.h +28 -19
  88. data/dyncall/dyncall/dyncall_signature.h +1 -1
  89. data/dyncall/dyncall/dyncall_types.h +17 -18
  90. data/dyncall/dyncall/dyncall_utils.h +1 -1
  91. data/dyncall/dyncall/dyncall_value.h +28 -21
  92. data/dyncall/dyncall/dyncall_vector.c +1 -1
  93. data/dyncall/dyncall/dyncall_vector.h +1 -1
  94. data/dyncall/dyncall/gen-masm.sh +2 -2
  95. data/dyncall/dyncallback/CMakeLists.txt +1 -2
  96. data/dyncall/dyncallback/Makefile.generic +1 -1
  97. data/dyncall/dyncallback/dyncall_alloc_wx.c +1 -1
  98. data/dyncall/dyncallback/dyncall_alloc_wx.h +4 -3
  99. data/dyncall/dyncallback/dyncall_alloc_wx_malloc.c +8 -2
  100. data/dyncall/dyncallback/dyncall_alloc_wx_mmap.c +67 -4
  101. data/dyncall/dyncallback/dyncall_alloc_wx_win32.c +7 -2
  102. data/dyncall/dyncallback/dyncall_args.c +19 -15
  103. data/dyncall/dyncallback/dyncall_args.h +1 -1
  104. data/dyncall/dyncallback/{dyncall_args_arm32_arm.c → dyncall_args_arm32.c} +4 -4
  105. data/dyncall/dyncallback/{dyncall_args_arm32_arm.h → dyncall_args_arm32.h} +6 -6
  106. data/dyncall/dyncallback/dyncall_args_arm64.c +2 -2
  107. data/dyncall/dyncallback/dyncall_args_arm64_apple.c +2 -2
  108. data/dyncall/dyncallback/dyncall_args_mips.c +26 -21
  109. data/dyncall/dyncallback/dyncall_args_mips.h +18 -6
  110. data/dyncall/dyncallback/dyncall_args_mips64.c +81 -0
  111. data/dyncall/dyncallback/dyncall_args_mips_o32.c +104 -0
  112. data/dyncall/dyncallback/dyncall_args_ppc32.c +2 -2
  113. data/dyncall/dyncallback/dyncall_args_ppc32.h +1 -1
  114. data/dyncall/dyncallback/dyncall_args_ppc32_sysv.c +1 -1
  115. data/dyncall/dyncallback/dyncall_args_ppc64.c +24 -3
  116. data/dyncall/dyncallback/dyncall_args_sparc32.c +41 -15
  117. data/dyncall/dyncallback/dyncall_args_sparc32.h +2 -2
  118. data/dyncall/dyncallback/dyncall_args_sparc64.c +28 -15
  119. data/dyncall/dyncallback/dyncall_args_sparc64.h +7 -3
  120. data/dyncall/dyncallback/dyncall_args_x64.c +1 -1
  121. data/dyncall/dyncallback/dyncall_args_x64.h +1 -1
  122. data/dyncall/dyncallback/dyncall_args_x86.c +1 -1
  123. data/dyncall/dyncallback/dyncall_args_x86.h +1 -1
  124. data/dyncall/dyncallback/dyncall_callback.c +10 -12
  125. data/dyncall/dyncallback/dyncall_callback.h +2 -4
  126. data/dyncall/dyncallback/dyncall_callback_arch.S +12 -2
  127. data/dyncall/dyncallback/{dyncall_callback_arm32_arm.c → dyncall_callback_arm32.c} +25 -10
  128. data/dyncall/dyncallback/dyncall_callback_arm32_arm_apple.s +7 -7
  129. data/dyncall/dyncallback/dyncall_callback_arm32_arm_gas.S +9 -9
  130. data/dyncall/dyncallback/dyncall_callback_arm32_thumb_apple.S +1 -1
  131. data/dyncall/dyncallback/dyncall_callback_arm32_thumb_gas.S +1 -1
  132. data/dyncall/dyncallback/dyncall_callback_arm64.S +2 -2
  133. data/dyncall/dyncallback/dyncall_callback_arm64.c +20 -14
  134. data/dyncall/dyncallback/dyncall_callback_mips.c +26 -9
  135. data/dyncall/dyncallback/dyncall_callback_mips_eabi_gas.s +99 -0
  136. data/dyncall/dyncallback/{dyncall_args_arm32_thumb.h → dyncall_callback_mips_gas.S} +14 -9
  137. data/dyncall/dyncallback/{dyncall_callback_arm32_thumb.c → dyncall_callback_mips_n32_gas.s} +12 -7
  138. data/dyncall/dyncallback/dyncall_callback_mips_n64_gas.s +98 -0
  139. data/dyncall/dyncallback/dyncall_callback_mips_o32_gas.s +100 -0
  140. data/dyncall/dyncallback/dyncall_callback_ppc32.S +54 -54
  141. data/dyncall/dyncallback/dyncall_callback_ppc32.c +23 -5
  142. data/dyncall/dyncallback/dyncall_callback_ppc32_apple.s +92 -117
  143. data/dyncall/dyncallback/dyncall_callback_ppc64.S +2 -2
  144. data/dyncall/dyncallback/dyncall_callback_ppc64.c +23 -5
  145. data/dyncall/dyncallback/dyncall_callback_sparc32.c +25 -7
  146. data/dyncall/dyncallback/dyncall_callback_sparc32.s +55 -4
  147. data/dyncall/dyncallback/dyncall_callback_sparc64.c +25 -7
  148. data/dyncall/dyncallback/dyncall_callback_sparc64.s +89 -5
  149. data/dyncall/dyncallback/dyncall_callback_x64.S +8 -8
  150. data/dyncall/dyncallback/dyncall_callback_x64.c +19 -6
  151. data/dyncall/dyncallback/dyncall_callback_x86.S +29 -25
  152. data/dyncall/dyncallback/dyncall_callback_x86.c +24 -11
  153. data/dyncall/dyncallback/dyncall_thunk.c +6 -6
  154. data/dyncall/dyncallback/dyncall_thunk.h +9 -7
  155. data/dyncall/dyncallback/{dyncall_thunk_arm32_arm.c → dyncall_thunk_arm32.c} +5 -3
  156. data/dyncall/dyncallback/{dyncall_thunk_arm32_arm.h → dyncall_thunk_arm32.h} +7 -7
  157. data/dyncall/dyncallback/dyncall_thunk_arm64.c +2 -2
  158. data/dyncall/dyncallback/dyncall_thunk_arm64.h +8 -13
  159. data/dyncall/dyncallback/dyncall_thunk_mips.c +16 -20
  160. data/dyncall/dyncallback/dyncall_thunk_mips.h +4 -2
  161. data/dyncall/dyncallback/dyncall_thunk_mips64.c +103 -0
  162. data/dyncall/dyncallback/{dyncall_callback_arm32_thumb.h → dyncall_thunk_mips64.h} +15 -8
  163. data/dyncall/dyncallback/dyncall_thunk_ppc32.c +4 -4
  164. data/dyncall/dyncallback/dyncall_thunk_ppc32.h +1 -1
  165. data/dyncall/dyncallback/dyncall_thunk_ppc32_sysv.c +9 -9
  166. data/dyncall/dyncallback/dyncall_thunk_ppc64.c +2 -2
  167. data/dyncall/dyncallback/dyncall_thunk_sparc32.c +19 -2
  168. data/dyncall/dyncallback/dyncall_thunk_sparc32.h +5 -4
  169. data/dyncall/dyncallback/dyncall_thunk_sparc64.c +42 -2
  170. data/dyncall/dyncallback/dyncall_thunk_sparc64.h +5 -5
  171. data/dyncall/dyncallback/dyncall_thunk_x64.c +1 -1
  172. data/dyncall/dyncallback/dyncall_thunk_x64.h +2 -2
  173. data/dyncall/dyncallback/dyncall_thunk_x86.c +1 -1
  174. data/dyncall/dyncallback/dyncall_thunk_x86.h +2 -2
  175. data/dyncall/dyncallback/dyncallback.3 +16 -11
  176. data/dyncall/dynload/dynload.3 +63 -8
  177. data/dyncall/dynload/dynload.c +2 -8
  178. data/dyncall/dynload/dynload.h +9 -5
  179. data/dyncall/dynload/dynload_alloc.h +1 -1
  180. data/dyncall/dynload/dynload_syms.c +1 -3
  181. data/dyncall/dynload/dynload_syms_elf.c +19 -11
  182. data/dyncall/dynload/dynload_syms_mach-o.c +151 -75
  183. data/dyncall/dynload/dynload_syms_pe.c +24 -24
  184. data/dyncall/dynload/dynload_unix.c +156 -13
  185. data/dyncall/dynload/dynload_windows.c +15 -11
  186. data/dyncall/portasm/portasm-arm.S +1 -1
  187. data/dyncall/portasm/portasm-ppc.S +1 -1
  188. data/dyncall/portasm/{portasm-x64-att.S → portasm-x64.S} +7 -4
  189. data/dyncall/portasm/portasm-x86.S +4 -2
  190. data/{dyncall-bindings/ruby/rbdc/extconf.rb → extconf.rb} +4 -4
  191. data/{dyncall-bindings/ruby/rbdc/rbdc.c → rbdc.c} +5 -5
  192. metadata +24 -48
  193. data/dyncall/Makefile.M +0 -15
  194. data/dyncall/buildsys/dynmake/Makefile.base.M +0 -82
  195. data/dyncall/buildsys/dynmake/dynmake.bat +0 -2
  196. data/dyncall/buildsys/dynmake/dynmake.sh +0 -4
  197. data/dyncall/dynMakefile +0 -4
  198. data/dyncall/dyncall/Makefile.M +0 -10
  199. data/dyncall/dyncall/TODO +0 -9
  200. data/dyncall/dyncall/dynMakefile +0 -4
  201. data/dyncall/dyncall/dyncall_call_sparc64.S +0 -362
  202. data/dyncall/dyncall/dyncall_call_sparc_v9.S +0 -222
  203. data/dyncall/dyncall/dyncall_call_x64-att.S +0 -147
  204. data/dyncall/dyncall/dyncall_callvm_sparc_v9.c +0 -182
  205. data/dyncall/dyncall/dyncall_callvm_sparc_v9.h +0 -46
  206. data/dyncall/dyncallback/Makefile.M +0 -10
  207. data/dyncall/dyncallback/README.txt +0 -9
  208. data/dyncall/dyncallback/TODO +0 -4
  209. data/dyncall/dyncallback/dynMakefile +0 -4
  210. data/dyncall/dyncallback/dyncall_args_arm32_thumb.c +0 -30
  211. data/dyncall/dyncallback/dyncall_callback_arm32_arm.h +0 -46
  212. data/dyncall/dyncallback/dyncall_callback_mips.h +0 -43
  213. data/dyncall/dyncallback/dyncall_callback_ppc32.h +0 -43
  214. data/dyncall/dyncallback/dyncall_callback_ppc64.h +0 -56
  215. data/dyncall/dyncallback/dyncall_callback_sparc32.h +0 -44
  216. data/dyncall/dyncallback/dyncall_callback_x64.h +0 -45
  217. data/dyncall/dyncallback/dyncall_callback_x86.h +0 -50
  218. data/dyncall/dyncallback/dyncall_thunk_arm32_thumb.c +0 -30
  219. data/dyncall/dyncallback/dyncall_thunk_arm32_thumb.h +0 -36
  220. data/dyncall/dynload/Makefile.M +0 -10
  221. data/dyncall/dynload/TODO +0 -20
  222. data/dyncall/dynload/dynMakefile +0 -4
  223. data/dyncall/dynload/dynload_darwin.c +0 -90
@@ -6,7 +6,7 @@
6
6
  Description: Callback - Implementation Header for ppc32
7
7
  License:
8
8
 
9
- Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
9
+ Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
10
10
  Tassilo Philipp <tphilipp@potion-studios.com>
11
11
 
12
12
  Permission to use, copy, modify, and distribute this software for any
@@ -25,7 +25,20 @@
25
25
 
26
26
 
27
27
  #include "dyncall_callback.h"
28
- #include "dyncall_callback_ppc32.h"
28
+ #include "dyncall_alloc_wx.h"
29
+ #include "dyncall_thunk.h"
30
+
31
+ /* Callback symbol. */
32
+ extern void dcCallbackThunkEntry();
33
+
34
+ struct DCCallback
35
+ {
36
+ DCThunk thunk; /* offset 0 size 24 */
37
+ DCCallbackHandler* handler; /* offset 24 size 4 */
38
+ size_t stack_cleanup; /* offset 28 size 4 */
39
+ void* userdata; /* offset 32 size 4 */
40
+ }; /* total size 36 */
41
+
29
42
 
30
43
  void dcbInitCallback(DCCallback* pcb, const char* signature, DCCallbackHandler* handler, void* userdata)
31
44
  {
@@ -36,17 +49,22 @@ void dcbInitCallback(DCCallback* pcb, const char* signature, DCCallbackHandler*
36
49
  pcb->userdata = userdata;
37
50
  }
38
51
 
39
- extern void dcCallbackThunkEntry();
40
-
41
52
  DCCallback* dcbNewCallback(const char* signature, DCCallbackHandler* handler, void* userdata)
42
53
  {
43
54
  DCCallback* pcb;
44
55
  int err = dcAllocWX(sizeof(DCCallback), (void**) &pcb);
45
- if (err != 0) return 0;
56
+ if(err)
57
+ return NULL;
46
58
 
47
59
  dcbInitThunk(&pcb->thunk, dcCallbackThunkEntry);
48
60
  dcbInitCallback(pcb, signature, handler, userdata);
49
61
 
62
+ err = dcInitExecWX(pcb, sizeof(DCCallback));
63
+ if(err) {
64
+ dcFreeWX(pcb, sizeof(DCCallback));
65
+ return NULL;
66
+ }
67
+
50
68
  return pcb;
51
69
  }
52
70
 
@@ -23,99 +23,90 @@
23
23
 
24
24
  */
25
25
 
26
- .machine ppc
27
- .text
28
- .align 2
26
+ .machine ppc
27
+ .text
28
+ .align 2
29
29
 
30
30
  /* Callback Thunk Entry code for PowerPC 32-bit Darwin/Apple Mac OS X. */
31
31
 
32
32
 
33
33
  /* Stack Frame Layout:
34
-
35
- 204 DCValue ( )
36
- 56 DCArgs (32+104+4+8 = 148)
37
- 24 Parameter area ( 4*8 = 32 )
38
- 0 Linkage area ( 24 )
39
34
 
35
+ 204 DCValue ()
36
+ 56 DCArgs (32+104+4+8 = 148)
37
+ 24 Parameter area (4*8 = 32)
38
+ 0 Linkage area (24)
40
39
 
41
40
  */
42
41
 
43
42
  /* Constants. */
44
- INT_REGS = 8
45
- FLOAT_REGS = 13
46
- SIZEOF_INT = 4
47
- SIZEOF_DOUBLE = 8
43
+ INT_REGS = 8
44
+ FLOAT_REGS = 13
45
+ SIZEOF_INT = 4
46
+ SIZEOF_DOUBLE = 8
47
+
48
48
 
49
-
50
49
  /* Linkage area. */
51
- LINK_SP = 0
52
- LINK_CR = 4
53
- LINK_LR = 8
54
- LINK_OFFSET = 0
55
- LINK_SIZE = 24
50
+ LINK_SP = 0
51
+ LINK_CR = 4
52
+ LINK_LR = 8
53
+ LINK_OFFSET = 0
54
+ LINK_SIZE = 24
56
55
  /* Parameter area. */
57
- PAR_OFFSET = LINK_SIZE
58
- PAR_SIZE = 32
56
+ PAR_OFFSET = LINK_SIZE
57
+ PAR_SIZE = 32
59
58
  /* local struct DCArgs */
60
- ARGS_OFFSET = (PAR_OFFSET+PAR_SIZE)
61
- ARGS_SIZE = (SIZEOF_INT*INT_REGS)+(SIZEOF_DOUBLE*FLOAT_REGS) /* = 136 */
59
+ ARGS_OFFSET = (PAR_OFFSET+PAR_SIZE)
60
+ ARGS_SIZE = (SIZEOF_INT*INT_REGS)+(SIZEOF_DOUBLE*FLOAT_REGS) /* = 136 */
62
61
  /* local struct DCValue */
63
- RESULT_OFFSET = (ARGS_OFFSET+ARGS_SIZE)
64
- RESULT_SIZE = 16
62
+ RESULT_OFFSET = (ARGS_OFFSET+ARGS_SIZE)
63
+ RESULT_SIZE = 16
65
64
  /* additional locals (reg 30/31) */
66
- LOCALS_OFFSET = (RESULT_OFFSET+RESULT_SIZE)
67
- LOCALS_SIZE = 2*SIZEOF_INT
65
+ LOCALS_OFFSET = (RESULT_OFFSET+RESULT_SIZE)
66
+ LOCALS_SIZE = 2*SIZEOF_INT
68
67
  /* total */
69
- FRAME_SIZE = ( (LOCALS_OFFSET+LOCALS_SIZE)+15 & (-16) )
68
+ FRAME_SIZE = ((LOCALS_OFFSET+LOCALS_SIZE)+15 & (-16))
70
69
 
71
70
  /* struct DCCallback */
72
- DCB_THUNK = 0
73
- DCB_HANDLER = 24
74
- DCB_STACKCLEAN = 28
75
- DCB_USERDATA = 32
71
+ DCB_THUNK = 0
72
+ DCB_HANDLER = 24
73
+ DCB_STACKCLEAN = 28
74
+ DCB_USERDATA = 32
76
75
 
77
76
  /* struct DCArgs */
78
- DCA_IARRAY = 0
79
- DCA_FARRAY = SIZEOF_INT*INT_REGS
80
- DCA_SP = DCA_FARRAY + SIZEOF_DOUBLE*FLOAT_REGS
81
- DCA_ICOUNT = DCA_SP + 4
82
- DCA_FCOUNT = DCA_ICOUNT + 4
83
-
84
- /* struct DCValue */
85
- DCV_INT = 0
86
- DCV_FLOAT = 0
87
- DCV_DOUBLE = 0
88
- DCV_LONG_HI32 = 0
89
- DCV_LONG_LO32 = 4
90
- DCV_SIZE = 8
91
-
92
- iregfile = ARGS_OFFSET+DCA_IARRAY
93
- fregfile = ARGS_OFFSET+DCA_FARRAY
94
- save_sp = ARGS_OFFSET+DCA_SP
95
- icount = ARGS_OFFSET+DCA_ICOUNT
96
- fcount = ARGS_OFFSET+DCA_FCOUNT
97
- .globl _dcCallbackThunkEntry
98
-
99
- /*
100
- Thunk entry:
101
- R2 = DCCallback*
102
- */
77
+ DCA_IARRAY = 0
78
+ DCA_FARRAY = SIZEOF_INT*INT_REGS
79
+ DCA_SP = DCA_FARRAY + SIZEOF_DOUBLE*FLOAT_REGS
80
+ DCA_ICOUNT = DCA_SP + 4
81
+ DCA_FCOUNT = DCA_ICOUNT + 4
82
+
83
+ iregfile = ARGS_OFFSET+DCA_IARRAY
84
+ fregfile = ARGS_OFFSET+DCA_FARRAY
85
+ save_sp = ARGS_OFFSET+DCA_SP
86
+ icount = ARGS_OFFSET+DCA_ICOUNT
87
+ fcount = ARGS_OFFSET+DCA_FCOUNT
88
+
89
+ .globl _dcCallbackThunkEntry
90
+
91
+ /*
92
+ Thunk entry:
93
+ r2 = DCCallback*
94
+ */
103
95
  _dcCallbackThunkEntry:
104
96
 
105
- mflr r0
106
- stw r0, 8(r1) /* store return address */
107
- /* stmw r30, -8(r1) */ /* store preserved registers (r30/r31) */
108
- addi r12, r1, PAR_OFFSET /* temporary r12 = parameter area on callers stack frame */
109
- stwu r1, -FRAME_SIZE(r1) /* save callers stack pointer and make new stack frame. */
110
- stw r3, iregfile+0*4(r1) /* spill 8 integer parameter registers */
111
- stw r4, iregfile+1*4(r1)
112
- stw r5, iregfile+2*4(r1)
113
- stw r6, iregfile+3*4(r1)
114
- stw r7, iregfile+4*4(r1)
115
- stw r8, iregfile+5*4(r1)
116
- stw r9, iregfile+6*4(r1)
117
- stw r10,iregfile+7*4(r1)
118
- stfd f1, fregfile+ 0*8(r1) /* spill 13 float parameter registers */
97
+ mflr r0
98
+ stw r0, 8(r1) /* store return address */
99
+ addi r12,r1, PAR_OFFSET /* temporary r12 = parameter area on callers stack frame */
100
+ stwu r1, -FRAME_SIZE(r1) /* save callers stack pointer and make new stack frame. */
101
+ stw r3, iregfile+ 0*4(r1) /* spill 8 integer parameter registers */
102
+ stw r4, iregfile+ 1*4(r1)
103
+ stw r5, iregfile+ 2*4(r1)
104
+ stw r6, iregfile+ 3*4(r1)
105
+ stw r7, iregfile+ 4*4(r1)
106
+ stw r8, iregfile+ 5*4(r1)
107
+ stw r9, iregfile+ 6*4(r1)
108
+ stw r10,iregfile+ 7*4(r1)
109
+ stfd f1, fregfile+ 0*8(r1) /* spill 13 float parameter registers */
119
110
  stfd f2, fregfile+ 1*8(r1)
120
111
  stfd f3, fregfile+ 2*8(r1)
121
112
  stfd f4, fregfile+ 3*8(r1)
@@ -128,54 +119,38 @@ _dcCallbackThunkEntry:
128
119
  stfd f11,fregfile+10*8(r1)
129
120
  stfd f12,fregfile+11*8(r1)
130
121
  stfd f13,fregfile+12*8(r1)
131
- /* initialize struct DCCallback */
132
- stw r12,save_sp(r1) /* init stack pointer */
133
- xor r0, r0, r0 /* init register counters */
134
- stw r0, icount(r1)
135
- stw r0, fcount(r1)
136
- /* invoke callback handler */
137
- mr r3, r2 /* arg 1: DCCallback* pcb */
138
- addi r4, r1, ARGS_OFFSET /* arg 2: DCArgs* args */
139
- addi r5, r1, RESULT_OFFSET /* arg 3: DCValue* result */
140
- lwz r6, DCB_USERDATA(r2) /* arg 4: void* userdata */
141
-
142
- /* branch-and-link to DCCallback.handler */
143
- lwz r12, DCB_HANDLER(r2)
144
- mtctr r12
122
+ /* initialize struct DCCallback */
123
+ stw r12,save_sp(r1) /* init stack pointer */
124
+ xor r0, r0, r0 /* init register counters */
125
+ stw r0, icount(r1)
126
+ stw r0, fcount(r1)
127
+ /* invoke callback handler */
128
+ mr r3, r2 /* arg 1: DCCallback* pcb */
129
+ addi r4, r1, ARGS_OFFSET /* arg 2: DCArgs* args */
130
+ addi r5, r1, RESULT_OFFSET /* arg 3: DCValue* result */
131
+ lwz r6, DCB_USERDATA(r2) /* arg 4: void* userdata */
132
+
133
+ /* branch-and-link to DCCallback.handler */
134
+ lwz r12,DCB_HANDLER(r2)
135
+ mtctr r12
145
136
  bctrl
146
- addi r0, r1, RESULT_OFFSET /* r0 = DCValue* */
147
- /* switch on base result type */
148
- cmpi cr0, r3, 'B
149
- beq .i32
150
- cmpi cr0, r3, 'i
151
- beq .i32
152
- cmpi cr0, r3, 'l
153
- beq .i64
154
- cmpi cr0, r3, 'f
155
- beq .f32
156
- cmpi cr0, r3, 'd
157
- beq .f64
158
- cmpi cr0, r3, 'p
159
- beq .i32
160
- .void: /* ignore result (void call) */
161
- b .end
162
- .i32: /* result is integer <= 32-bit result */
163
- lwz r3, RESULT_OFFSET + DCV_INT(r1)
164
- b .end
165
- .f32: /* result is C float result */
166
- lfs f1, RESULT_OFFSET + DCV_FLOAT(r1)
167
- b .end
137
+ /* switch on base result type */
138
+ cmpi cr0, r3, 0x66 /* 'f */
139
+ beq .f32
140
+ cmpi cr0, r3, 0x64 /* 'd */
141
+ beq .f64
142
+ .i64:
143
+ lwz r3, RESULT_OFFSET (r1)
144
+ lwz r4, RESULT_OFFSET + 4 (r1)
145
+ .end:
146
+ lwz r1, 0(r1) /* restore stack pointer */
147
+ lwz r0, 8(r1) /* load link register with return address */
148
+ mtlr r0
149
+ blr /* branch back to link register */
150
+ .f32:
151
+ lfs f1, RESULT_OFFSET(r1)
152
+ b .end
168
153
  .f64:
169
- lfd f1, RESULT_OFFSET + DCV_FLOAT(r1)
170
- b .end
171
- .i64: /* result is C double result */
172
- lwz r3, RESULT_OFFSET + DCV_LONG_HI32(r1)
173
- lwz r4, RESULT_OFFSET + DCV_LONG_LO32(r1)
154
+ lfd f1, RESULT_OFFSET(r1)
174
155
  b .end
175
- .end:
176
- lwz r1, 0(r1) /* restore stack pointer */
177
- /* lmw r30, -8(r1) */ /* restore preserved registers */
178
- lwz r0, 8(r1) /* load link register with return address */
179
- mtlr r0
180
- blr /* branch back to link register */
181
156
 
@@ -147,9 +147,9 @@ Input:
147
147
  bctrl
148
148
 
149
149
  /* check result type */
150
- cmpi cr0, r3, 'f
150
+ cmpi cr0, r3, 0x66 /* 'f */
151
151
  beq .f32
152
- cmpi cr0, r3, 'd
152
+ cmpi cr0, r3, 0x64 /* 'd */
153
153
  beq .f64
154
154
  .i64:
155
155
  ld r3, SP_RESULT(r1)
@@ -6,7 +6,7 @@
6
6
  Description: Callback - Implementation Header for ppc64
7
7
  License:
8
8
 
9
- Copyright (c) 2014-2015 Masanori Mitsugi <mitsugi@linux.vnet.ibm.com>
9
+ Copyright (c) 2014-2016 Masanori Mitsugi <mitsugi@linux.vnet.ibm.com>
10
10
 
11
11
  Permission to use, copy, modify, and distribute this software for any
12
12
  purpose with or without fee is hereby granted, provided that the above
@@ -24,7 +24,20 @@
24
24
 
25
25
 
26
26
  #include "dyncall_callback.h"
27
- #include "dyncall_callback_ppc64.h"
27
+ #include "dyncall_alloc_wx.h"
28
+ #include "dyncall_thunk.h"
29
+
30
+ /* Callback symbol. */
31
+ extern void dcCallbackThunkEntry();
32
+
33
+ struct DCCallback /* ELF v1 | ELF v2 */
34
+ { /* ------------------+------------------ */
35
+ DCThunk thunk; /* offset 0 size 64 | offset 0 size 48 */
36
+ DCCallbackHandler* handler; /* offset 64 size 8 | offset 48 size 8 */
37
+ size_t stack_cleanup; /* offset 72 size 8 | offset 56 size 8 */
38
+ void* userdata; /* offset 80 size 8 | offset 64 size 8 */
39
+ };
40
+
28
41
 
29
42
  void dcbInitCallback(DCCallback* pcb, const char* signature, DCCallbackHandler* handler, void* userdata)
30
43
  {
@@ -35,17 +48,22 @@ void dcbInitCallback(DCCallback* pcb, const char* signature, DCCallbackHandler*
35
48
  pcb->userdata = userdata;
36
49
  }
37
50
 
38
- extern void dcCallbackThunkEntry();
39
-
40
51
  DCCallback* dcbNewCallback(const char* signature, DCCallbackHandler* handler, void* userdata)
41
52
  {
42
53
  DCCallback* pcb;
43
54
  int err = dcAllocWX(sizeof(DCCallback), (void**) &pcb);
44
- if (err != 0) return 0;
55
+ if(err)
56
+ return NULL;
45
57
 
46
58
  dcbInitThunk(&pcb->thunk, dcCallbackThunkEntry);
47
59
  dcbInitCallback(pcb, signature, handler, userdata);
48
60
 
61
+ err = dcInitExecWX(pcb, sizeof(DCCallback));
62
+ if(err) {
63
+ dcFreeWX(pcb, sizeof(DCCallback));
64
+ return NULL;
65
+ }
66
+
49
67
  return pcb;
50
68
  }
51
69
 
@@ -3,10 +3,10 @@
3
3
  Package: dyncall
4
4
  Library: dyncallback
5
5
  File: dyncallback/dyncall_callback_sparc32.c
6
- Description: Callback - Implementation for sparc32 (TODO: not implemented yet)
6
+ Description: Callback - Implementation for sparc32
7
7
  License:
8
8
 
9
- Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
9
+ Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
10
10
  Tassilo Philipp <tphilipp@potion-studios.com>
11
11
 
12
12
  Permission to use, copy, modify, and distribute this software for any
@@ -25,25 +25,42 @@
25
25
 
26
26
 
27
27
  #include "dyncall_callback.h"
28
- #include "dyncall_callback_sparc32.h"
29
-
30
28
  #include "dyncall_alloc_wx.h"
29
+ #include "dyncall_thunk.h"
30
+
31
+ /* Callback symbol. */
32
+ extern void dcCallbackThunkEntry();
33
+
34
+ struct DCCallback
35
+ {
36
+ DCThunk thunk; /* offset 0 size 24 */
37
+ DCCallbackHandler* handler; /* offset 24 size 4 */
38
+ void* userdata; /* offset 28 size 4 */
39
+ };
40
+
31
41
 
32
42
  void dcbInitCallback(DCCallback* pcb, const char* signature, DCCallbackHandler* handler, void* userdata)
33
43
  {
44
+ pcb->handler = handler;
45
+ pcb->userdata = userdata;
34
46
  }
35
47
 
36
- extern void dcCallbackThunkEntry();
37
-
38
48
  DCCallback* dcbNewCallback(const char* signature, DCCallbackHandler* handler, void* userdata)
39
49
  {
40
50
  DCCallback* pcb;
41
51
  int err = dcAllocWX(sizeof(DCCallback), (void**) &pcb);
42
- if (err != 0) return 0;
52
+ if(err)
53
+ return NULL;
43
54
 
44
55
  dcbInitThunk(&pcb->thunk, dcCallbackThunkEntry);
45
56
  dcbInitCallback(pcb, signature, handler, userdata);
46
57
 
58
+ err = dcInitExecWX(pcb, sizeof(DCCallback));
59
+ if(err) {
60
+ dcFreeWX(pcb, sizeof(DCCallback));
61
+ return NULL;
62
+ }
63
+
47
64
  return pcb;
48
65
  }
49
66
 
@@ -56,3 +73,4 @@ void* dcbGetUserData(DCCallback* pcb)
56
73
  {
57
74
  return pcb->userdata;
58
75
  }
76
+
@@ -3,10 +3,10 @@
3
3
  Package: dyncall
4
4
  Library: dyncallback
5
5
  File: dyncallback/dyncall_callback_sparc32.s
6
- Description: Callback Thunk - Implementation for Sparc 32-bit
6
+ Description: Callback - Implementation for Sparc 32-bit
7
7
  License:
8
8
 
9
- Copyright (c) 2007-2011 Daniel Adler <dadler@uni-goettingen.de>,
9
+ Copyright (c) 2007-2017 Daniel Adler <dadler@uni-goettingen.de>,
10
10
  Tassilo Philipp <tphilipp@potion-studios.com>
11
11
 
12
12
  Permission to use, copy, modify, and distribute this software for any
@@ -23,8 +23,59 @@
23
23
 
24
24
  */
25
25
 
26
+ /* input:
27
+ $i0 -> thunk
28
+ $i0+24 -> cb handler
29
+ $i0+28 -> userdata
30
+ */
31
+
32
+ .text
26
33
  .globl dcCallbackThunkEntry
34
+
35
+ /* Called by thunk - thunk stores pointer to DCCallback */
36
+ /* in %g1, and pointer to called function in %g2 */
27
37
  dcCallbackThunkEntry:
28
- jmpl %i7 + 8, %g0 /* Return from proc. */
29
- nop
38
+
39
+ /* Prolog. */
40
+ /* Frame size of 104b comes from needing storage space for the following: */
41
+ /* req_reg_save_area:64 + spill:24 + dcargs:4 + retval:8 + pad:4 */
42
+ /* Spill area could theoretically be only 16b, b/c cbHandler function has */
43
+ /* 4 arguments, but let's be conservative. */ /* cbHandler function might decide to spill (6x4b) @@@ testcode, or rely on 8byte return space in parent stack */
44
+ save %sp, -104, %sp
45
+
46
+ /* Spill register args as dcargs is based on that (in prev frame, after */
47
+ /* req_reg_save_area and struct_ret_ptr). */
48
+ add %fp, 68, %l0
49
+ st %i0, [ %l0 + 0 ] /* reg arg 0 */
50
+ st %i1, [ %l0 + 4 ] /* reg arg 1 */
51
+ st %i2, [ %l0 + 8 ] /* reg arg 2 */
52
+ st %i3, [ %l0 + 12 ] /* reg arg 3 */
53
+ st %i4, [ %l0 + 16 ] /* reg arg 4 */
54
+ st %i5, [ %l0 + 20 ] /* reg arg 5 */
55
+ st %l0, [ %sp + 88 ] /* init arg_ptr */
56
+
57
+ /* Zero retval store. */
58
+ st %g0, [ %sp + 96 ]
59
+ st %g0, [ %sp + 100 ]
60
+
61
+ /* Prepare callback handler call. */
62
+ mov %g1, %o0 /* Param 0 = DCCallback*, %g1 holds ptr to thunk */
63
+ add %sp, 88, %o1 /* Param 1 = DCArgs* (ptr to struct with args ptr) */
64
+ add %sp, 96, %o2 /* Param 2 = results ptr to 8b of local stack data */
65
+ ld [ %g1 + 28 ], %o3 /* Param 3 = userdata ptr */
66
+
67
+ ld [ %g1 + 24 ], %l0
68
+ call %l0
69
+ nop
70
+
71
+ /* Put retval in %i0/%i1 (to be in caller's %o0/%o1), and %f0/%f1. */
72
+ ld [ %sp + 96 ], %i0
73
+ ld [ %sp + 100 ], %i1
74
+ ld [ %sp + 96 ], %f0
75
+ ld [ %sp + 100 ], %f1
76
+
77
+ /* Epilog. */
78
+ restore /* unshift reg window */
79
+ retl /* Return from proc. -- jmpl %i7 + 8, %g0 */
80
+ nop
30
81