debase-ruby_core_source 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (191) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +1 -0
  4. data/Rakefile +2 -2
  5. data/lib/debase/ruby_core_source.rb +1 -0
  6. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/addr2line.h +21 -0
  7. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/ccan/build_assert/build_assert.h +40 -0
  8. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/ccan/check_type/check_type.h +63 -0
  9. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/ccan/container_of/container_of.h +142 -0
  10. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/ccan/list/list.h +635 -0
  11. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/ccan/str/str.h +16 -0
  12. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/constant.h +43 -0
  13. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/dln.h +51 -0
  14. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/eval_intern.h +275 -0
  15. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/gc.h +107 -0
  16. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/id.h +210 -0
  17. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/insns.inc +107 -0
  18. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/insns_info.inc +752 -0
  19. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/internal.h +1198 -0
  20. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/iseq.h +158 -0
  21. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/known_errors.inc +746 -0
  22. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/method.h +144 -0
  23. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/node.h +544 -0
  24. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/node_name.inc +212 -0
  25. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/opt_sc.inc +734 -0
  26. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/optinsn.inc +83 -0
  27. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/optunifs.inc +124 -0
  28. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/parse.h +184 -0
  29. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/probes_helper.h +67 -0
  30. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/regenc.h +237 -0
  31. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/regint.h +972 -0
  32. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/regparse.h +363 -0
  33. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/revision.h +1 -0
  34. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/ruby_atomic.h +170 -0
  35. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/siphash.h +48 -0
  36. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/symbol.h +88 -0
  37. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/thread_pthread.h +54 -0
  38. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/thread_win32.h +36 -0
  39. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/timev.h +42 -0
  40. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/transcode_data.h +123 -0
  41. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/version.h +52 -0
  42. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/vm.inc +3372 -0
  43. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/vm_core.h +1163 -0
  44. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/vm_debug.h +37 -0
  45. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/vm_exec.h +182 -0
  46. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/vm_insnhelper.h +233 -0
  47. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/vm_opts.h +56 -0
  48. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/vmtc.inc +105 -0
  49. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/addr2line.h +21 -0
  50. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/ccan/build_assert/build_assert.h +40 -0
  51. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/ccan/check_type/check_type.h +63 -0
  52. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/ccan/container_of/container_of.h +142 -0
  53. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/ccan/list/list.h +773 -0
  54. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/ccan/str/str.h +16 -0
  55. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/constant.h +50 -0
  56. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/dln.h +51 -0
  57. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/encindex.h +67 -0
  58. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/eval_intern.h +304 -0
  59. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/gc.h +114 -0
  60. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/id.h +211 -0
  61. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/id_table.h +30 -0
  62. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/insns.inc +110 -0
  63. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/insns_info.inc +776 -0
  64. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/internal.h +1408 -0
  65. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/iseq.h +249 -0
  66. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/known_errors.inc +746 -0
  67. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/method.h +213 -0
  68. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/node.h +520 -0
  69. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/node_name.inc +208 -0
  70. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/opt_sc.inc +758 -0
  71. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/optinsn.inc +83 -0
  72. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/optunifs.inc +127 -0
  73. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/parse.h +185 -0
  74. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/probes_helper.h +43 -0
  75. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/regenc.h +237 -0
  76. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/regint.h +987 -0
  77. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/regparse.h +367 -0
  78. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/revision.h +1 -0
  79. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/ruby_atomic.h +233 -0
  80. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/siphash.h +48 -0
  81. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/symbol.h +108 -0
  82. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/thread_pthread.h +54 -0
  83. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/thread_win32.h +36 -0
  84. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/timev.h +42 -0
  85. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/transcode_data.h +139 -0
  86. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/version.h +55 -0
  87. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/vm.inc +3414 -0
  88. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/vm_call_iseq_optimized.inc +212 -0
  89. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/vm_core.h +1240 -0
  90. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/vm_debug.h +37 -0
  91. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/vm_exec.h +182 -0
  92. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/vm_insnhelper.h +243 -0
  93. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/vm_opts.h +57 -0
  94. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/vmtc.inc +108 -0
  95. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/addr2line.h +21 -0
  96. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/ccan/build_assert/build_assert.h +40 -0
  97. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/ccan/check_type/check_type.h +63 -0
  98. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/ccan/container_of/container_of.h +142 -0
  99. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/ccan/list/list.h +773 -0
  100. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/ccan/str/str.h +16 -0
  101. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/constant.h +50 -0
  102. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/dln.h +51 -0
  103. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/encindex.h +67 -0
  104. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/eval_intern.h +315 -0
  105. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/gc.h +114 -0
  106. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/id.h +220 -0
  107. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/id_table.h +31 -0
  108. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/insns.inc +112 -0
  109. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/insns_info.inc +796 -0
  110. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/internal.h +1790 -0
  111. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/iseq.h +252 -0
  112. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/known_errors.inc +746 -0
  113. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/method.h +213 -0
  114. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/node.h +520 -0
  115. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/node_name.inc +208 -0
  116. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/opt_sc.inc +774 -0
  117. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/optinsn.inc +83 -0
  118. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/optunifs.inc +129 -0
  119. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/parse.h +185 -0
  120. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/probes_helper.h +43 -0
  121. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/regenc.h +254 -0
  122. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/regint.h +938 -0
  123. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/regparse.h +370 -0
  124. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/revision.h +1 -0
  125. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/ruby_assert.h +54 -0
  126. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/ruby_atomic.h +233 -0
  127. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/siphash.h +48 -0
  128. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/symbol.h +108 -0
  129. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/thread_pthread.h +54 -0
  130. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/thread_win32.h +36 -0
  131. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/timev.h +42 -0
  132. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/transcode_data.h +139 -0
  133. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/version.h +73 -0
  134. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/vm.inc +3415 -0
  135. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/vm_call_iseq_optimized.inc +212 -0
  136. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/vm_core.h +1646 -0
  137. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/vm_debug.h +37 -0
  138. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/vm_exec.h +182 -0
  139. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/vm_insnhelper.h +243 -0
  140. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/vm_opts.h +57 -0
  141. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/vmtc.inc +110 -0
  142. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/addr2line.h +21 -0
  143. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/ccan/build_assert/build_assert.h +40 -0
  144. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/ccan/check_type/check_type.h +63 -0
  145. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/ccan/container_of/container_of.h +142 -0
  146. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/ccan/list/list.h +773 -0
  147. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/ccan/str/str.h +16 -0
  148. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/constant.h +50 -0
  149. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/debug_counter.h +109 -0
  150. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/dln.h +51 -0
  151. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/encindex.h +67 -0
  152. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/eval_intern.h +334 -0
  153. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/gc.h +116 -0
  154. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/id.h +250 -0
  155. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/id_table.h +31 -0
  156. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/insns.inc +217 -0
  157. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/insns_info.inc +1570 -0
  158. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/internal.h +2035 -0
  159. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/iseq.h +307 -0
  160. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/known_errors.inc +746 -0
  161. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/method.h +218 -0
  162. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/node.h +540 -0
  163. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/node_name.inc +198 -0
  164. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/opt_sc.inc +1601 -0
  165. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/optinsn.inc +103 -0
  166. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/optunifs.inc +61 -0
  167. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/parse.h +206 -0
  168. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/probes_helper.h +43 -0
  169. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/regenc.h +254 -0
  170. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/regint.h +938 -0
  171. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/regparse.h +370 -0
  172. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/revision.h +1 -0
  173. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/ruby_assert.h +54 -0
  174. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/ruby_atomic.h +233 -0
  175. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/siphash.h +48 -0
  176. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/symbol.h +108 -0
  177. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/thread_pthread.h +54 -0
  178. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/thread_win32.h +36 -0
  179. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/timev.h +42 -0
  180. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/transcode_data.h +139 -0
  181. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/version.h +73 -0
  182. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/vm.inc +3667 -0
  183. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/vm_call_iseq_optimized.inc +213 -0
  184. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/vm_core.h +1768 -0
  185. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/vm_debug.h +37 -0
  186. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/vm_exec.h +192 -0
  187. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/vm_insnhelper.h +255 -0
  188. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/vm_opts.h +57 -0
  189. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/vmtc.inc +214 -0
  190. data/lib/debase/ruby_core_source/version.rb +1 -1
  191. metadata +186 -2
@@ -0,0 +1,1790 @@
1
+ /**********************************************************************
2
+
3
+ internal.h -
4
+
5
+ $Author$
6
+ created at: Tue May 17 11:42:20 JST 2011
7
+
8
+ Copyright (C) 2011 Yukihiro Matsumoto
9
+
10
+ **********************************************************************/
11
+
12
+ #ifndef RUBY_INTERNAL_H
13
+ #define RUBY_INTERNAL_H 1
14
+
15
+ #include "ruby.h"
16
+ #include "ruby/encoding.h"
17
+ #include "ruby/io.h"
18
+
19
+ #if defined(__cplusplus)
20
+ extern "C" {
21
+ #if 0
22
+ } /* satisfy cc-mode */
23
+ #endif
24
+ #endif
25
+
26
+ #define LIKELY(x) RB_LIKELY(x)
27
+ #define UNLIKELY(x) RB_UNLIKELY(x)
28
+
29
+ #ifndef MAYBE_UNUSED
30
+ # define MAYBE_UNUSED(x) x
31
+ #endif
32
+
33
+ #ifndef WARN_UNUSED_RESULT
34
+ # define WARN_UNUSED_RESULT(x) x
35
+ #endif
36
+
37
+ #ifdef HAVE_VALGRIND_MEMCHECK_H
38
+ # include <valgrind/memcheck.h>
39
+ # ifndef VALGRIND_MAKE_MEM_DEFINED
40
+ # define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE((p), (n))
41
+ # endif
42
+ # ifndef VALGRIND_MAKE_MEM_UNDEFINED
43
+ # define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE((p), (n))
44
+ # endif
45
+ #else
46
+ # define VALGRIND_MAKE_MEM_DEFINED(p, n) 0
47
+ # define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
48
+ #endif
49
+
50
+ #define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
51
+
52
+ #ifndef __has_feature
53
+ # define __has_feature(x) 0
54
+ #endif
55
+
56
+ #ifndef __has_extension
57
+ # define __has_extension __has_feature
58
+ #endif
59
+
60
+ #if GCC_VERSION_SINCE(4, 6, 0) || __has_extension(c_static_assert)
61
+ # define STATIC_ASSERT(name, expr) _Static_assert(expr, #name ": " #expr)
62
+ #else
63
+ # define STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[1 - 2*!(expr)]
64
+ #endif
65
+
66
+ #define SIGNED_INTEGER_TYPE_P(int_type) (0 > ((int_type)0)-1)
67
+ #define SIGNED_INTEGER_MAX(sint_type) \
68
+ (sint_type) \
69
+ ((((sint_type)1) << (sizeof(sint_type) * CHAR_BIT - 2)) | \
70
+ ((((sint_type)1) << (sizeof(sint_type) * CHAR_BIT - 2)) - 1))
71
+ #define SIGNED_INTEGER_MIN(sint_type) (-SIGNED_INTEGER_MAX(sint_type)-1)
72
+ #define UNSIGNED_INTEGER_MAX(uint_type) (~(uint_type)0)
73
+
74
+ #if SIGNEDNESS_OF_TIME_T < 0 /* signed */
75
+ # define TIMET_MAX SIGNED_INTEGER_MAX(time_t)
76
+ # define TIMET_MIN SIGNED_INTEGER_MIN(time_t)
77
+ #elif SIGNEDNESS_OF_TIME_T > 0 /* unsigned */
78
+ # define TIMET_MAX UNSIGNED_INTEGER_MAX(time_t)
79
+ # define TIMET_MIN ((time_t)0)
80
+ #endif
81
+ #define TIMET_MAX_PLUS_ONE (2*(double)(TIMET_MAX/2+1))
82
+
83
+ #define MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, min, max) ( \
84
+ (a) == 0 ? 0 : \
85
+ (a) == -1 ? (b) < -(max) : \
86
+ (a) > 0 ? \
87
+ ((b) > 0 ? (max) / (a) < (b) : (min) / (a) > (b)) : \
88
+ ((b) > 0 ? (min) / (a) < (b) : (max) / (a) > (b)))
89
+ #define MUL_OVERFLOW_FIXNUM_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXNUM_MIN, FIXNUM_MAX)
90
+ #define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LONG_MIN, LONG_MAX)
91
+ #define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, INT_MIN, INT_MAX)
92
+
93
+ #ifndef swap16
94
+ # ifdef HAVE_BUILTIN___BUILTIN_BSWAP16
95
+ # define swap16(x) __builtin_bswap16(x)
96
+ # endif
97
+ #endif
98
+
99
+ #ifndef swap16
100
+ # define swap16(x) ((uint16_t)((((x)&0xFF)<<8) | (((x)>>8)&0xFF)))
101
+ #endif
102
+
103
+ #ifndef swap32
104
+ # ifdef HAVE_BUILTIN___BUILTIN_BSWAP32
105
+ # define swap32(x) __builtin_bswap32(x)
106
+ # endif
107
+ #endif
108
+
109
+ #ifndef swap32
110
+ # define swap32(x) ((uint32_t)((((x)&0xFF)<<24) \
111
+ |(((x)>>24)&0xFF) \
112
+ |(((x)&0x0000FF00)<<8) \
113
+ |(((x)&0x00FF0000)>>8) ))
114
+ #endif
115
+
116
+ #ifndef swap64
117
+ # ifdef HAVE_BUILTIN___BUILTIN_BSWAP64
118
+ # define swap64(x) __builtin_bswap64(x)
119
+ # endif
120
+ #endif
121
+
122
+ #ifndef swap64
123
+ # ifdef HAVE_INT64_T
124
+ # define byte_in_64bit(n) ((uint64_t)0xff << (n))
125
+ # define swap64(x) ((uint64_t)((((x)&byte_in_64bit(0))<<56) \
126
+ |(((x)>>56)&0xFF) \
127
+ |(((x)&byte_in_64bit(8))<<40) \
128
+ |(((x)&byte_in_64bit(48))>>40) \
129
+ |(((x)&byte_in_64bit(16))<<24) \
130
+ |(((x)&byte_in_64bit(40))>>24) \
131
+ |(((x)&byte_in_64bit(24))<<8) \
132
+ |(((x)&byte_in_64bit(32))>>8)))
133
+ # endif
134
+ #endif
135
+
136
+ static inline unsigned int
137
+ nlz_int(unsigned int x)
138
+ {
139
+ #if defined(HAVE_BUILTIN___BUILTIN_CLZ)
140
+ if (x == 0) return SIZEOF_INT * CHAR_BIT;
141
+ return (unsigned int)__builtin_clz(x);
142
+ #else
143
+ unsigned int y;
144
+ # if 64 < SIZEOF_INT * CHAR_BIT
145
+ unsigned int n = 128;
146
+ # elif 32 < SIZEOF_INT * CHAR_BIT
147
+ unsigned int n = 64;
148
+ # else
149
+ unsigned int n = 32;
150
+ # endif
151
+ # if 64 < SIZEOF_INT * CHAR_BIT
152
+ y = x >> 64; if (y) {n -= 64; x = y;}
153
+ # endif
154
+ # if 32 < SIZEOF_INT * CHAR_BIT
155
+ y = x >> 32; if (y) {n -= 32; x = y;}
156
+ # endif
157
+ y = x >> 16; if (y) {n -= 16; x = y;}
158
+ y = x >> 8; if (y) {n -= 8; x = y;}
159
+ y = x >> 4; if (y) {n -= 4; x = y;}
160
+ y = x >> 2; if (y) {n -= 2; x = y;}
161
+ y = x >> 1; if (y) {return n - 2;}
162
+ return (unsigned int)(n - x);
163
+ #endif
164
+ }
165
+
166
+ static inline unsigned int
167
+ nlz_long(unsigned long x)
168
+ {
169
+ #if defined(HAVE_BUILTIN___BUILTIN_CLZL)
170
+ if (x == 0) return SIZEOF_LONG * CHAR_BIT;
171
+ return (unsigned int)__builtin_clzl(x);
172
+ #else
173
+ unsigned long y;
174
+ # if 64 < SIZEOF_LONG * CHAR_BIT
175
+ unsigned int n = 128;
176
+ # elif 32 < SIZEOF_LONG * CHAR_BIT
177
+ unsigned int n = 64;
178
+ # else
179
+ unsigned int n = 32;
180
+ # endif
181
+ # if 64 < SIZEOF_LONG * CHAR_BIT
182
+ y = x >> 64; if (y) {n -= 64; x = y;}
183
+ # endif
184
+ # if 32 < SIZEOF_LONG * CHAR_BIT
185
+ y = x >> 32; if (y) {n -= 32; x = y;}
186
+ # endif
187
+ y = x >> 16; if (y) {n -= 16; x = y;}
188
+ y = x >> 8; if (y) {n -= 8; x = y;}
189
+ y = x >> 4; if (y) {n -= 4; x = y;}
190
+ y = x >> 2; if (y) {n -= 2; x = y;}
191
+ y = x >> 1; if (y) {return n - 2;}
192
+ return (unsigned int)(n - x);
193
+ #endif
194
+ }
195
+
196
+ #ifdef HAVE_LONG_LONG
197
+ static inline unsigned int
198
+ nlz_long_long(unsigned LONG_LONG x)
199
+ {
200
+ #if defined(HAVE_BUILTIN___BUILTIN_CLZLL)
201
+ if (x == 0) return SIZEOF_LONG_LONG * CHAR_BIT;
202
+ return (unsigned int)__builtin_clzll(x);
203
+ #else
204
+ unsigned LONG_LONG y;
205
+ # if 64 < SIZEOF_LONG_LONG * CHAR_BIT
206
+ unsigned int n = 128;
207
+ # elif 32 < SIZEOF_LONG_LONG * CHAR_BIT
208
+ unsigned int n = 64;
209
+ # else
210
+ unsigned int n = 32;
211
+ # endif
212
+ # if 64 < SIZEOF_LONG_LONG * CHAR_BIT
213
+ y = x >> 64; if (y) {n -= 64; x = y;}
214
+ # endif
215
+ # if 32 < SIZEOF_LONG_LONG * CHAR_BIT
216
+ y = x >> 32; if (y) {n -= 32; x = y;}
217
+ # endif
218
+ y = x >> 16; if (y) {n -= 16; x = y;}
219
+ y = x >> 8; if (y) {n -= 8; x = y;}
220
+ y = x >> 4; if (y) {n -= 4; x = y;}
221
+ y = x >> 2; if (y) {n -= 2; x = y;}
222
+ y = x >> 1; if (y) {return n - 2;}
223
+ return (unsigned int)(n - x);
224
+ #endif
225
+ }
226
+ #endif
227
+
228
+ #ifdef HAVE_UINT128_T
229
+ static inline unsigned int
230
+ nlz_int128(uint128_t x)
231
+ {
232
+ uint128_t y;
233
+ unsigned int n = 128;
234
+ y = x >> 64; if (y) {n -= 64; x = y;}
235
+ y = x >> 32; if (y) {n -= 32; x = y;}
236
+ y = x >> 16; if (y) {n -= 16; x = y;}
237
+ y = x >> 8; if (y) {n -= 8; x = y;}
238
+ y = x >> 4; if (y) {n -= 4; x = y;}
239
+ y = x >> 2; if (y) {n -= 2; x = y;}
240
+ y = x >> 1; if (y) {return n - 2;}
241
+ return (unsigned int)(n - x);
242
+ }
243
+ #endif
244
+
245
+ static inline unsigned int
246
+ nlz_intptr(uintptr_t x)
247
+ {
248
+ #if SIZEOF_VOIDP == 8
249
+ return nlz_long_long(x);
250
+ #elif SIZEOF_VOIDP == 4
251
+ return nlz_int(x);
252
+ #endif
253
+ }
254
+
255
+ static inline unsigned int
256
+ rb_popcount32(uint32_t x)
257
+ {
258
+ #ifdef HAVE_BUILTIN___BUILTIN_POPCOUNT
259
+ return (unsigned int)__builtin_popcount(x);
260
+ #else
261
+ x = (x & 0x55555555) + (x >> 1 & 0x55555555);
262
+ x = (x & 0x33333333) + (x >> 2 & 0x33333333);
263
+ x = (x & 0x0f0f0f0f) + (x >> 4 & 0x0f0f0f0f);
264
+ x = (x & 0x001f001f) + (x >> 8 & 0x001f001f);
265
+ return (x & 0x0000003f) + (x >>16 & 0x0000003f);
266
+ #endif
267
+ }
268
+
269
+ static inline int
270
+ rb_popcount64(uint64_t x)
271
+ {
272
+ #ifdef HAVE_BUILTIN___BUILTIN_POPCOUNT
273
+ return __builtin_popcountll(x);
274
+ #else
275
+ x = (x & 0x5555555555555555) + (x >> 1 & 0x5555555555555555);
276
+ x = (x & 0x3333333333333333) + (x >> 2 & 0x3333333333333333);
277
+ x = (x & 0x0707070707070707) + (x >> 4 & 0x0707070707070707);
278
+ x = (x & 0x001f001f001f001f) + (x >> 8 & 0x001f001f001f001f);
279
+ x = (x & 0x0000003f0000003f) + (x >>16 & 0x0000003f0000003f);
280
+ return (x & 0x7f) + (x >>32 & 0x7f);
281
+ #endif
282
+ }
283
+
284
+ static inline int
285
+ rb_popcount_intptr(uintptr_t x)
286
+ {
287
+ #if SIZEOF_VOIDP == 8
288
+ return rb_popcount64(x);
289
+ #elif SIZEOF_VOIDP == 4
290
+ return rb_popcount32(x);
291
+ #endif
292
+ }
293
+
294
+ static inline int
295
+ ntz_int32(uint32_t x)
296
+ {
297
+ #ifdef HAVE_BUILTIN___BUILTIN_CTZ
298
+ return __builtin_ctz(x);
299
+ #else
300
+ return rb_popcount32((~x) & (x-1));
301
+ #endif
302
+ }
303
+
304
+ static inline int
305
+ ntz_int64(uint64_t x)
306
+ {
307
+ #ifdef HAVE_BUILTIN___BUILTIN_CTZLL
308
+ return __builtin_ctzll(x);
309
+ #else
310
+ return rb_popcount64((~x) & (x-1));
311
+ #endif
312
+ }
313
+
314
+ static inline int
315
+ ntz_intptr(uintptr_t x)
316
+ {
317
+ #if SIZEOF_VOIDP == 8
318
+ return ntz_int64(x);
319
+ #elif SIZEOF_VOIDP == 4
320
+ return ntz_int32(x);
321
+ #endif
322
+ }
323
+
324
+ #if HAVE_LONG_LONG && SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG
325
+ # define DLONG LONG_LONG
326
+ # define DL2NUM(x) LL2NUM(x)
327
+ #elif defined(HAVE_INT128_T)
328
+ # define DLONG int128_t
329
+ # define DL2NUM(x) (RB_FIXABLE(x) ? LONG2FIX(x) : rb_int128t2big(x))
330
+ VALUE rb_int128t2big(int128_t n);
331
+ #endif
332
+
333
+
334
+ /* arguments must be Fixnum */
335
+ static inline VALUE
336
+ rb_fix_mul_fix(VALUE x, VALUE y)
337
+ {
338
+ long lx = FIX2LONG(x);
339
+ long ly = FIX2LONG(y);
340
+ #ifdef DLONG
341
+ return DL2NUM((DLONG)lx * (DLONG)ly);
342
+ #else
343
+ if (MUL_OVERFLOW_FIXNUM_P(lx, ly)) {
344
+ return rb_big_mul(rb_int2big(lx), rb_int2big(ly));
345
+ }
346
+ else {
347
+ return LONG2FIX(lx * ly);
348
+ }
349
+ #endif
350
+ }
351
+
352
+ /*
353
+ * This behaves different from C99 for negative arguments.
354
+ * Note that div may overflow fixnum.
355
+ */
356
+ static inline void
357
+ rb_fix_divmod_fix(VALUE a, VALUE b, VALUE *divp, VALUE *modp)
358
+ {
359
+ /* assume / and % comply C99.
360
+ * ldiv(3) won't be inlined by GCC and clang.
361
+ * I expect / and % are compiled as single idiv.
362
+ */
363
+ long x = FIX2LONG(a);
364
+ long y = FIX2LONG(b);
365
+ long div, mod;
366
+ if (x == FIXNUM_MIN && y == -1) {
367
+ if (divp) *divp = LONG2NUM(-FIXNUM_MIN);
368
+ if (modp) *modp = LONG2FIX(0);
369
+ return;
370
+ }
371
+ div = x / y;
372
+ mod = x % y;
373
+ if (y > 0 ? mod < 0 : mod > 0) {
374
+ mod += y;
375
+ div -= 1;
376
+ }
377
+ if (divp) *divp = LONG2FIX(div);
378
+ if (modp) *modp = LONG2FIX(mod);
379
+ }
380
+
381
+ /* div() for Ruby
382
+ * This behaves different from C99 for negative arguments.
383
+ */
384
+ static inline VALUE
385
+ rb_fix_div_fix(VALUE x, VALUE y)
386
+ {
387
+ VALUE div;
388
+ rb_fix_divmod_fix(x, y, &div, NULL);
389
+ return div;
390
+ }
391
+
392
+ /* mod() for Ruby
393
+ * This behaves different from C99 for negative arguments.
394
+ */
395
+ static inline VALUE
396
+ rb_fix_mod_fix(VALUE x, VALUE y)
397
+ {
398
+ VALUE mod;
399
+ rb_fix_divmod_fix(x, y, NULL, &mod);
400
+ return mod;
401
+ }
402
+
403
+ #if defined(HAVE_UINT128_T)
404
+ # define bit_length(x) \
405
+ (unsigned int) \
406
+ (sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
407
+ sizeof(x) <= SIZEOF_LONG ? SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)) : \
408
+ sizeof(x) <= SIZEOF_LONG_LONG ? SIZEOF_LONG_LONG * CHAR_BIT - nlz_long_long((unsigned LONG_LONG)(x)) : \
409
+ SIZEOF_INT128_T * CHAR_BIT - nlz_int128((uint128_t)(x)))
410
+ #elif defined(HAVE_LONG_LONG)
411
+ # define bit_length(x) \
412
+ (unsigned int) \
413
+ (sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
414
+ sizeof(x) <= SIZEOF_LONG ? SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)) : \
415
+ SIZEOF_LONG_LONG * CHAR_BIT - nlz_long_long((unsigned LONG_LONG)(x)))
416
+ #else
417
+ # define bit_length(x) \
418
+ (unsigned int) \
419
+ (sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
420
+ SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)))
421
+ #endif
422
+
423
+ #ifndef BDIGIT
424
+ # if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
425
+ # define BDIGIT unsigned int
426
+ # define SIZEOF_BDIGIT SIZEOF_INT
427
+ # define BDIGIT_DBL unsigned LONG_LONG
428
+ # define BDIGIT_DBL_SIGNED LONG_LONG
429
+ # define PRI_BDIGIT_PREFIX ""
430
+ # define PRI_BDIGIT_DBL_PREFIX PRI_LL_PREFIX
431
+ # elif SIZEOF_INT*2 <= SIZEOF_LONG
432
+ # define BDIGIT unsigned int
433
+ # define SIZEOF_BDIGIT SIZEOF_INT
434
+ # define BDIGIT_DBL unsigned long
435
+ # define BDIGIT_DBL_SIGNED long
436
+ # define PRI_BDIGIT_PREFIX ""
437
+ # define PRI_BDIGIT_DBL_PREFIX "l"
438
+ # elif SIZEOF_SHORT*2 <= SIZEOF_LONG
439
+ # define BDIGIT unsigned short
440
+ # define SIZEOF_BDIGIT SIZEOF_SHORT
441
+ # define BDIGIT_DBL unsigned long
442
+ # define BDIGIT_DBL_SIGNED long
443
+ # define PRI_BDIGIT_PREFIX "h"
444
+ # define PRI_BDIGIT_DBL_PREFIX "l"
445
+ # else
446
+ # define BDIGIT unsigned short
447
+ # define SIZEOF_BDIGIT (SIZEOF_LONG/2)
448
+ # define SIZEOF_ACTUAL_BDIGIT SIZEOF_LONG
449
+ # define BDIGIT_DBL unsigned long
450
+ # define BDIGIT_DBL_SIGNED long
451
+ # define PRI_BDIGIT_PREFIX "h"
452
+ # define PRI_BDIGIT_DBL_PREFIX "l"
453
+ # endif
454
+ #endif
455
+ #ifndef SIZEOF_ACTUAL_BDIGIT
456
+ # define SIZEOF_ACTUAL_BDIGIT SIZEOF_BDIGIT
457
+ #endif
458
+
459
+ #ifdef PRI_BDIGIT_PREFIX
460
+ # define PRIdBDIGIT PRI_BDIGIT_PREFIX"d"
461
+ # define PRIiBDIGIT PRI_BDIGIT_PREFIX"i"
462
+ # define PRIoBDIGIT PRI_BDIGIT_PREFIX"o"
463
+ # define PRIuBDIGIT PRI_BDIGIT_PREFIX"u"
464
+ # define PRIxBDIGIT PRI_BDIGIT_PREFIX"x"
465
+ # define PRIXBDIGIT PRI_BDIGIT_PREFIX"X"
466
+ #endif
467
+
468
+ #ifdef PRI_BDIGIT_DBL_PREFIX
469
+ # define PRIdBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"d"
470
+ # define PRIiBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"i"
471
+ # define PRIoBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"o"
472
+ # define PRIuBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"u"
473
+ # define PRIxBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"x"
474
+ # define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X"
475
+ #endif
476
+
477
+ #define BIGNUM_EMBED_LEN_NUMBITS 3
478
+ #ifndef BIGNUM_EMBED_LEN_MAX
479
+ # if (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT) < (1 << BIGNUM_EMBED_LEN_NUMBITS)-1
480
+ # define BIGNUM_EMBED_LEN_MAX (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT)
481
+ # else
482
+ # define BIGNUM_EMBED_LEN_MAX ((1 << BIGNUM_EMBED_LEN_NUMBITS)-1)
483
+ # endif
484
+ #endif
485
+
486
+ struct RBignum {
487
+ struct RBasic basic;
488
+ union {
489
+ struct {
490
+ size_t len;
491
+ BDIGIT *digits;
492
+ } heap;
493
+ BDIGIT ary[BIGNUM_EMBED_LEN_MAX];
494
+ } as;
495
+ };
496
+ #define BIGNUM_SIGN_BIT ((VALUE)FL_USER1)
497
+ /* sign: positive:1, negative:0 */
498
+ #define BIGNUM_SIGN(b) ((RBASIC(b)->flags & BIGNUM_SIGN_BIT) != 0)
499
+ #define BIGNUM_SET_SIGN(b,sign) \
500
+ ((sign) ? (RBASIC(b)->flags |= BIGNUM_SIGN_BIT) \
501
+ : (RBASIC(b)->flags &= ~BIGNUM_SIGN_BIT))
502
+ #define BIGNUM_POSITIVE_P(b) BIGNUM_SIGN(b)
503
+ #define BIGNUM_NEGATIVE_P(b) (!BIGNUM_SIGN(b))
504
+ #define BIGNUM_NEGATE(b) (RBASIC(b)->flags ^= BIGNUM_SIGN_BIT)
505
+
506
+ #define BIGNUM_EMBED_FLAG ((VALUE)FL_USER2)
507
+ #define BIGNUM_EMBED_LEN_MASK ((VALUE)(FL_USER5|FL_USER4|FL_USER3))
508
+ #define BIGNUM_EMBED_LEN_SHIFT (FL_USHIFT+BIGNUM_EMBED_LEN_NUMBITS)
509
+ #define BIGNUM_LEN(b) \
510
+ ((RBASIC(b)->flags & BIGNUM_EMBED_FLAG) ? \
511
+ (size_t)((RBASIC(b)->flags >> BIGNUM_EMBED_LEN_SHIFT) & \
512
+ (BIGNUM_EMBED_LEN_MASK >> BIGNUM_EMBED_LEN_SHIFT)) : \
513
+ RBIGNUM(b)->as.heap.len)
514
+ /* LSB:BIGNUM_DIGITS(b)[0], MSB:BIGNUM_DIGITS(b)[BIGNUM_LEN(b)-1] */
515
+ #define BIGNUM_DIGITS(b) \
516
+ ((RBASIC(b)->flags & BIGNUM_EMBED_FLAG) ? \
517
+ RBIGNUM(b)->as.ary : \
518
+ RBIGNUM(b)->as.heap.digits)
519
+ #define BIGNUM_LENINT(b) rb_long2int(BIGNUM_LEN(b))
520
+
521
+ #define RBIGNUM(obj) (R_CAST(RBignum)(obj))
522
+
523
+ struct RRational {
524
+ struct RBasic basic;
525
+ const VALUE num;
526
+ const VALUE den;
527
+ };
528
+
529
+ #define RRATIONAL(obj) (R_CAST(RRational)(obj))
530
+ #define RRATIONAL_SET_NUM(rat, n) RB_OBJ_WRITE((rat), &((struct RRational *)(rat))->num,(n))
531
+ #define RRATIONAL_SET_DEN(rat, d) RB_OBJ_WRITE((rat), &((struct RRational *)(rat))->den,(d))
532
+
533
+ struct RFloat {
534
+ struct RBasic basic;
535
+ double float_value;
536
+ };
537
+
538
+ #define RFLOAT(obj) (R_CAST(RFloat)(obj))
539
+
540
+ struct RComplex {
541
+ struct RBasic basic;
542
+ const VALUE real;
543
+ const VALUE imag;
544
+ };
545
+
546
+ #define RCOMPLEX(obj) (R_CAST(RComplex)(obj))
547
+
548
+ #ifdef RCOMPLEX_SET_REAL /* shortcut macro for internal only */
549
+ #undef RCOMPLEX_SET_REAL
550
+ #undef RCOMPLEX_SET_IMAG
551
+ #define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->real,(r))
552
+ #define RCOMPLEX_SET_IMAG(cmp, i) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i))
553
+ #endif
554
+
555
+ struct RHash {
556
+ struct RBasic basic;
557
+ struct st_table *ntbl; /* possibly 0 */
558
+ int iter_lev;
559
+ const VALUE ifnone;
560
+ };
561
+
562
+ #define RHASH(obj) (R_CAST(RHash)(obj))
563
+
564
+ #ifdef RHASH_ITER_LEV
565
+ #undef RHASH_ITER_LEV
566
+ #undef RHASH_IFNONE
567
+ #undef RHASH_SIZE
568
+ #define RHASH_ITER_LEV(h) (RHASH(h)->iter_lev)
569
+ #define RHASH_IFNONE(h) (RHASH(h)->ifnone)
570
+ #define RHASH_SIZE(h) (RHASH(h)->ntbl ? RHASH(h)->ntbl->num_entries : (st_index_t)0)
571
+ #endif
572
+
573
+ /* missing/setproctitle.c */
574
+ #ifndef HAVE_SETPROCTITLE
575
+ extern void ruby_init_setproctitle(int argc, char *argv[]);
576
+ #endif
577
+
578
+ #define RSTRUCT_EMBED_LEN_MAX RSTRUCT_EMBED_LEN_MAX
579
+ #define RSTRUCT_EMBED_LEN_MASK RSTRUCT_EMBED_LEN_MASK
580
+ #define RSTRUCT_EMBED_LEN_SHIFT RSTRUCT_EMBED_LEN_SHIFT
581
+ enum {
582
+ RSTRUCT_EMBED_LEN_MAX = 3,
583
+ RSTRUCT_EMBED_LEN_MASK = (RUBY_FL_USER2|RUBY_FL_USER1),
584
+ RSTRUCT_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+1),
585
+
586
+ RSTRUCT_ENUM_END
587
+ };
588
+
589
+ struct RStruct {
590
+ struct RBasic basic;
591
+ union {
592
+ struct {
593
+ long len;
594
+ const VALUE *ptr;
595
+ } heap;
596
+ const VALUE ary[RSTRUCT_EMBED_LEN_MAX];
597
+ } as;
598
+ };
599
+
600
+ #undef RSTRUCT_LEN
601
+ #undef RSTRUCT_PTR
602
+ #undef RSTRUCT_SET
603
+ #undef RSTRUCT_GET
604
+ #define RSTRUCT_EMBED_LEN(st) \
605
+ (long)((RBASIC(st)->flags >> RSTRUCT_EMBED_LEN_SHIFT) & \
606
+ (RSTRUCT_EMBED_LEN_MASK >> RSTRUCT_EMBED_LEN_SHIFT))
607
+ #define RSTRUCT_LEN(st) rb_struct_len(st)
608
+ #define RSTRUCT_LENINT(st) rb_long2int(RSTRUCT_LEN(st))
609
+ #define RSTRUCT_CONST_PTR(st) rb_struct_const_ptr(st)
610
+ #define RSTRUCT_PTR(st) ((VALUE *)RSTRUCT_CONST_PTR(RB_OBJ_WB_UNPROTECT_FOR(STRUCT, st)))
611
+ #define RSTRUCT_SET(st, idx, v) RB_OBJ_WRITE(st, &RSTRUCT_CONST_PTR(st)[idx], (v))
612
+ #define RSTRUCT_GET(st, idx) (RSTRUCT_CONST_PTR(st)[idx])
613
+ #define RSTRUCT(obj) (R_CAST(RStruct)(obj))
614
+
615
+ static inline long
616
+ rb_struct_len(VALUE st)
617
+ {
618
+ return (RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ?
619
+ RSTRUCT_EMBED_LEN(st) : RSTRUCT(st)->as.heap.len;
620
+ }
621
+
622
+ static inline const VALUE *
623
+ rb_struct_const_ptr(VALUE st)
624
+ {
625
+ return FIX_CONST_VALUE_PTR((RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ?
626
+ RSTRUCT(st)->as.ary : RSTRUCT(st)->as.heap.ptr);
627
+ }
628
+
629
+ /* class.c */
630
+
631
+ struct rb_deprecated_classext_struct {
632
+ char conflict[sizeof(VALUE) * 3];
633
+ };
634
+
635
+ struct rb_subclass_entry;
636
+ typedef struct rb_subclass_entry rb_subclass_entry_t;
637
+
638
+ struct rb_subclass_entry {
639
+ VALUE klass;
640
+ rb_subclass_entry_t *next;
641
+ };
642
+
643
+ #if defined(HAVE_LONG_LONG)
644
+ typedef unsigned LONG_LONG rb_serial_t;
645
+ #define SERIALT2NUM ULL2NUM
646
+ #elif defined(HAVE_UINT64_T)
647
+ typedef uint64_t rb_serial_t;
648
+ #define SERIALT2NUM SIZET2NUM
649
+ #else
650
+ typedef unsigned long rb_serial_t;
651
+ #define SERIALT2NUM ULONG2NUM
652
+ #endif
653
+
654
+ struct rb_classext_struct {
655
+ struct st_table *iv_index_tbl;
656
+ struct st_table *iv_tbl;
657
+ struct rb_id_table *const_tbl;
658
+ struct rb_id_table *callable_m_tbl;
659
+ rb_subclass_entry_t *subclasses;
660
+ rb_subclass_entry_t **parent_subclasses;
661
+ /**
662
+ * In the case that this is an `ICLASS`, `module_subclasses` points to the link
663
+ * in the module's `subclasses` list that indicates that the klass has been
664
+ * included. Hopefully that makes sense.
665
+ */
666
+ rb_subclass_entry_t **module_subclasses;
667
+ rb_serial_t class_serial;
668
+ const VALUE origin_;
669
+ VALUE refined_class;
670
+ rb_alloc_func_t allocator;
671
+ };
672
+
673
+ typedef struct rb_classext_struct rb_classext_t;
674
+
675
+ #undef RClass
676
+ struct RClass {
677
+ struct RBasic basic;
678
+ VALUE super;
679
+ rb_classext_t *ptr;
680
+ struct rb_id_table *m_tbl;
681
+ };
682
+
683
+ void rb_class_subclass_add(VALUE super, VALUE klass);
684
+ void rb_class_remove_from_super_subclasses(VALUE);
685
+ int rb_singleton_class_internal_p(VALUE sklass);
686
+
687
+ #define RCLASS_EXT(c) (RCLASS(c)->ptr)
688
+ #define RCLASS_IV_TBL(c) (RCLASS_EXT(c)->iv_tbl)
689
+ #define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl)
690
+ #define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
691
+ #define RCLASS_CALLABLE_M_TBL(c) (RCLASS_EXT(c)->callable_m_tbl)
692
+ #define RCLASS_IV_INDEX_TBL(c) (RCLASS_EXT(c)->iv_index_tbl)
693
+ #define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin_)
694
+ #define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class)
695
+ #define RCLASS_SERIAL(c) (RCLASS_EXT(c)->class_serial)
696
+
697
+ #define RICLASS_IS_ORIGIN FL_USER5
698
+
699
+ static inline void
700
+ RCLASS_SET_ORIGIN(VALUE klass, VALUE origin)
701
+ {
702
+ RB_OBJ_WRITE(klass, &RCLASS_ORIGIN(klass), origin);
703
+ if (klass != origin) FL_SET(origin, RICLASS_IS_ORIGIN);
704
+ }
705
+
706
+ #undef RCLASS_SUPER
707
+ static inline VALUE
708
+ RCLASS_SUPER(VALUE klass)
709
+ {
710
+ return RCLASS(klass)->super;
711
+ }
712
+
713
+ static inline VALUE
714
+ RCLASS_SET_SUPER(VALUE klass, VALUE super)
715
+ {
716
+ if (super) {
717
+ rb_class_remove_from_super_subclasses(klass);
718
+ rb_class_subclass_add(super, klass);
719
+ }
720
+ RB_OBJ_WRITE(klass, &RCLASS(klass)->super, super);
721
+ return super;
722
+ }
723
+ /* IMEMO: Internal memo object */
724
+
725
+ #ifndef IMEMO_DEBUG
726
+ #define IMEMO_DEBUG 0
727
+ #endif
728
+
729
+ struct RIMemo {
730
+ VALUE flags;
731
+ VALUE v0;
732
+ VALUE v1;
733
+ VALUE v2;
734
+ VALUE v3;
735
+ };
736
+
737
+ enum imemo_type {
738
+ imemo_env = 0,
739
+ imemo_cref = 1,
740
+ imemo_svar = 2,
741
+ imemo_throw_data = 3,
742
+ imemo_ifunc = 4,
743
+ imemo_memo = 5,
744
+ imemo_ment = 6,
745
+ imemo_iseq = 7,
746
+ imemo_mask = 0x07
747
+ };
748
+
749
+ static inline enum imemo_type
750
+ imemo_type(VALUE imemo)
751
+ {
752
+ return (RBASIC(imemo)->flags >> FL_USHIFT) & imemo_mask;
753
+ }
754
+
755
+ /* FL_USER0 to FL_USER2 is for type */
756
+ #define IMEMO_FL_USHIFT (FL_USHIFT + 3)
757
+ #define IMEMO_FL_USER0 FL_USER3
758
+ #define IMEMO_FL_USER1 FL_USER4
759
+ #define IMEMO_FL_USER2 FL_USER5
760
+ #define IMEMO_FL_USER3 FL_USER6
761
+ #define IMEMO_FL_USER4 FL_USER7
762
+
763
+ /* CREF in method.h */
764
+
765
+ /* SVAR */
766
+
767
+ struct vm_svar {
768
+ VALUE flags;
769
+ const VALUE cref_or_me;
770
+ const VALUE lastline;
771
+ const VALUE backref;
772
+ const VALUE others;
773
+ };
774
+
775
+ /* THROW_DATA */
776
+
777
+ #define THROW_DATA_CONSUMED IMEMO_FL_USER0
778
+
779
+ struct vm_throw_data {
780
+ VALUE flags;
781
+ VALUE reserved;
782
+ const VALUE throw_obj;
783
+ const struct rb_control_frame_struct *catch_frame;
784
+ VALUE throw_state;
785
+ };
786
+
787
+ #define THROW_DATA_P(err) RB_TYPE_P(((VALUE)err), T_IMEMO)
788
+
789
+ /* IFUNC */
790
+
791
+ struct vm_ifunc_argc {
792
+ #if SIZEOF_INT * 2 > SIZEOF_VALUE
793
+ int min: (SIZEOF_VALUE * CHAR_BIT) / 2;
794
+ int max: (SIZEOF_VALUE * CHAR_BIT) / 2;
795
+ #else
796
+ int min, max;
797
+ #endif
798
+ };
799
+
800
+ struct vm_ifunc {
801
+ VALUE flags;
802
+ VALUE reserved;
803
+ VALUE (*func)(ANYARGS);
804
+ const void *data;
805
+ struct vm_ifunc_argc argc;
806
+ };
807
+
808
+ #define IFUNC_NEW(a, b, c) ((struct vm_ifunc *)rb_imemo_new(imemo_ifunc, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0))
809
+ struct vm_ifunc *rb_vm_ifunc_new(VALUE (*func)(ANYARGS), const void *data, int min_argc, int max_argc);
810
+ static inline struct vm_ifunc *
811
+ rb_vm_ifunc_proc_new(VALUE (*func)(ANYARGS), const void *data)
812
+ {
813
+ return rb_vm_ifunc_new(func, data, 0, UNLIMITED_ARGUMENTS);
814
+ }
815
+
816
+ /* MEMO */
817
+
818
+ struct MEMO {
819
+ VALUE flags;
820
+ VALUE reserved;
821
+ const VALUE v1;
822
+ const VALUE v2;
823
+ union {
824
+ long cnt;
825
+ long state;
826
+ const VALUE value;
827
+ VALUE (*func)(ANYARGS);
828
+ } u3;
829
+ };
830
+
831
+ #define MEMO_V1_SET(m, v) RB_OBJ_WRITE((m), &(m)->v1, (v))
832
+ #define MEMO_V2_SET(m, v) RB_OBJ_WRITE((m), &(m)->v2, (v))
833
+
834
+ #define MEMO_CAST(m) ((struct MEMO *)m)
835
+
836
+ #define MEMO_NEW(a, b, c) ((struct MEMO *)rb_imemo_new(imemo_memo, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0))
837
+
838
+ #define roomof(x, y) (((x) + (y) - 1) / (y))
839
+ #define type_roomof(x, y) roomof(sizeof(x), sizeof(y))
840
+ #define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
841
+ #define NEW_MEMO_FOR(type, value) \
842
+ ((value) = rb_ary_tmp_new_fill(type_roomof(type, VALUE)), MEMO_FOR(type, value))
843
+ #define NEW_PARTIAL_MEMO_FOR(type, value, member) \
844
+ ((value) = rb_ary_tmp_new_fill(type_roomof(type, VALUE)), \
845
+ rb_ary_set_len((value), offsetof(type, member) / sizeof(VALUE)), \
846
+ MEMO_FOR(type, value))
847
+
848
+ #define STRING_P(s) (RB_TYPE_P((s), T_STRING) && CLASS_OF(s) == rb_cString)
849
+
850
+ #ifdef RUBY_INTEGER_UNIFICATION
851
+ # define rb_cFixnum rb_cInteger
852
+ # define rb_cBignum rb_cInteger
853
+ #endif
854
+
855
+ enum {
856
+ cmp_opt_Fixnum,
857
+ cmp_opt_String,
858
+ cmp_optimizable_count
859
+ };
860
+
861
+ struct cmp_opt_data {
862
+ unsigned int opt_methods;
863
+ unsigned int opt_inited;
864
+ };
865
+
866
+ #define NEW_CMP_OPT_MEMO(type, value) \
867
+ NEW_PARTIAL_MEMO_FOR(type, value, cmp_opt)
868
+ #define CMP_OPTIMIZABLE_BIT(type) (1U << TOKEN_PASTE(cmp_opt_,type))
869
+ #define CMP_OPTIMIZABLE(data, type) \
870
+ (((data).opt_inited & CMP_OPTIMIZABLE_BIT(type)) ? \
871
+ ((data).opt_methods & CMP_OPTIMIZABLE_BIT(type)) : \
872
+ (((data).opt_inited |= CMP_OPTIMIZABLE_BIT(type)), \
873
+ rb_method_basic_definition_p(TOKEN_PASTE(rb_c,type), id_cmp) && \
874
+ ((data).opt_methods |= CMP_OPTIMIZABLE_BIT(type))))
875
+
876
+ #define OPTIMIZED_CMP(a, b, data) \
877
+ ((FIXNUM_P(a) && FIXNUM_P(b) && CMP_OPTIMIZABLE(data, Fixnum)) ? \
878
+ (((long)a > (long)b) ? 1 : ((long)a < (long)b) ? -1 : 0) : \
879
+ (STRING_P(a) && STRING_P(b) && CMP_OPTIMIZABLE(data, String)) ? \
880
+ rb_str_cmp(a, b) : \
881
+ rb_cmpint(rb_funcallv(a, id_cmp, 1, &b), a, b))
882
+
883
+ /* ment is in method.h */
884
+
885
+ /* global variable */
886
+
887
+ struct rb_global_entry {
888
+ struct rb_global_variable *var;
889
+ ID id;
890
+ };
891
+
892
+ struct rb_global_entry *rb_global_entry(ID);
893
+ VALUE rb_gvar_get(struct rb_global_entry *);
894
+ VALUE rb_gvar_set(struct rb_global_entry *, VALUE);
895
+ VALUE rb_gvar_defined(struct rb_global_entry *);
896
+
897
+ struct vtm; /* defined by timev.h */
898
+
899
+ /* array.c */
900
+ VALUE rb_ary_last(int, const VALUE *, VALUE);
901
+ void rb_ary_set_len(VALUE, long);
902
+ void rb_ary_delete_same(VALUE, VALUE);
903
+ VALUE rb_ary_tmp_new_fill(long capa);
904
+ VALUE rb_ary_at(VALUE, VALUE);
905
+ size_t rb_ary_memsize(VALUE);
906
+ #ifdef __GNUC__
907
+ #define rb_ary_new_from_args(n, ...) \
908
+ __extension__ ({ \
909
+ const VALUE args_to_new_ary[] = {__VA_ARGS__}; \
910
+ if (__builtin_constant_p(n)) { \
911
+ STATIC_ASSERT(rb_ary_new_from_args, numberof(args_to_new_ary) == (n)); \
912
+ } \
913
+ rb_ary_new_from_values(numberof(args_to_new_ary), args_to_new_ary); \
914
+ })
915
+ #endif
916
+
917
+ /* bignum.c */
918
+ extern const char ruby_digitmap[];
919
+ double rb_big_fdiv_double(VALUE x, VALUE y);
920
+ VALUE rb_big_uminus(VALUE x);
921
+ VALUE rb_big_hash(VALUE);
922
+ VALUE rb_big_odd_p(VALUE);
923
+ VALUE rb_big_even_p(VALUE);
924
+ size_t rb_big_size(VALUE);
925
+ VALUE rb_integer_float_cmp(VALUE x, VALUE y);
926
+ VALUE rb_integer_float_eq(VALUE x, VALUE y);
927
+ VALUE rb_cstr_parse_inum(const char *str, ssize_t len, char **endp, int base);
928
+ VALUE rb_big_comp(VALUE x);
929
+ VALUE rb_big_aref(VALUE x, VALUE y);
930
+ VALUE rb_big_abs(VALUE x);
931
+ VALUE rb_big_size_m(VALUE big);
932
+ VALUE rb_big_bit_length(VALUE big);
933
+ VALUE rb_big_remainder(VALUE x, VALUE y);
934
+ VALUE rb_big_gt(VALUE x, VALUE y);
935
+ VALUE rb_big_ge(VALUE x, VALUE y);
936
+ VALUE rb_big_lt(VALUE x, VALUE y);
937
+ VALUE rb_big_le(VALUE x, VALUE y);
938
+
939
+ /* class.c */
940
+ VALUE rb_class_boot(VALUE);
941
+ VALUE rb_class_inherited(VALUE, VALUE);
942
+ VALUE rb_make_metaclass(VALUE, VALUE);
943
+ VALUE rb_include_class_new(VALUE, VALUE);
944
+ void rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE);
945
+ void rb_class_detach_subclasses(VALUE);
946
+ void rb_class_detach_module_subclasses(VALUE);
947
+ void rb_class_remove_from_module_subclasses(VALUE);
948
+ VALUE rb_obj_methods(int argc, const VALUE *argv, VALUE obj);
949
+ VALUE rb_obj_protected_methods(int argc, const VALUE *argv, VALUE obj);
950
+ VALUE rb_obj_private_methods(int argc, const VALUE *argv, VALUE obj);
951
+ VALUE rb_obj_public_methods(int argc, const VALUE *argv, VALUE obj);
952
+ int rb_obj_basic_to_s_p(VALUE);
953
+ VALUE rb_special_singleton_class(VALUE);
954
+ VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach);
955
+ VALUE rb_singleton_class_get(VALUE obj);
956
+ void Init_class_hierarchy(void);
957
+
958
+ int rb_class_has_methods(VALUE c);
959
+ void rb_undef_methods_from(VALUE klass, VALUE super);
960
+
961
+ /* compar.c */
962
+ VALUE rb_invcmp(VALUE, VALUE);
963
+
964
+ /* compile.c */
965
+ struct rb_block;
966
+ int rb_dvar_defined(ID, const struct rb_block *);
967
+ int rb_local_defined(ID, const struct rb_block *);
968
+ CONSTFUNC(const char * rb_insns_name(int i));
969
+ VALUE rb_insns_name_array(void);
970
+
971
+ /* complex.c */
972
+ VALUE rb_complex_plus(VALUE, VALUE);
973
+ VALUE rb_complex_mul(VALUE, VALUE);
974
+ VALUE rb_complex_abs(VALUE x);
975
+ VALUE rb_complex_sqrt(VALUE x);
976
+
977
+ /* cont.c */
978
+ VALUE rb_obj_is_fiber(VALUE);
979
+ void rb_fiber_reset_root_local_storage(VALUE);
980
+ void ruby_register_rollback_func_for_ensure(VALUE (*ensure_func)(ANYARGS), VALUE (*rollback_func)(ANYARGS));
981
+
982
+ /* debug.c */
983
+ PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
984
+
985
+ /* dmyext.c */
986
+ void Init_enc(void);
987
+ void Init_ext(void);
988
+
989
+ /* encoding.c */
990
+ ID rb_id_encoding(void);
991
+ CONSTFUNC(void rb_gc_mark_encodings(void));
992
+ rb_encoding *rb_enc_get_from_index(int index);
993
+ rb_encoding *rb_enc_check_str(VALUE str1, VALUE str2);
994
+ int rb_encdb_replicate(const char *alias, const char *orig);
995
+ int rb_encdb_alias(const char *alias, const char *orig);
996
+ int rb_encdb_dummy(const char *name);
997
+ void rb_encdb_declare(const char *name);
998
+ void rb_enc_set_base(const char *name, const char *orig);
999
+ int rb_enc_set_dummy(int index);
1000
+ void rb_encdb_set_unicode(int index);
1001
+ PUREFUNC(int rb_data_is_encoding(VALUE obj));
1002
+
1003
+ /* enum.c */
1004
+ VALUE rb_f_send(int argc, VALUE *argv, VALUE recv);
1005
+ VALUE rb_nmin_run(VALUE obj, VALUE num, int by, int rev, int ary);
1006
+
1007
+ /* error.c */
1008
+ extern VALUE rb_eEAGAIN;
1009
+ extern VALUE rb_eEWOULDBLOCK;
1010
+ extern VALUE rb_eEINPROGRESS;
1011
+ void rb_report_bug_valist(VALUE file, int line, const char *fmt, va_list args);
1012
+ PRINTF_ARGS(void rb_compile_error_str(VALUE file, int line, void *enc, const char *fmt, ...), 4, 5);
1013
+ VALUE rb_syntax_error_append(VALUE, VALUE, int, int, rb_encoding*, const char*, va_list);
1014
+ VALUE rb_check_backtrace(VALUE);
1015
+ NORETURN(void rb_async_bug_errno(const char *,int));
1016
+ const char *rb_builtin_type_name(int t);
1017
+ const char *rb_builtin_class_name(VALUE x);
1018
+ PRINTF_ARGS(void rb_enc_warn(rb_encoding *enc, const char *fmt, ...), 2, 3);
1019
+ PRINTF_ARGS(void rb_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3);
1020
+ PRINTF_ARGS(void rb_sys_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3);
1021
+ VALUE rb_name_err_new(VALUE mesg, VALUE recv, VALUE method);
1022
+ #define rb_name_err_raise_str(mesg, recv, name) \
1023
+ rb_exc_raise(rb_name_err_new(mesg, recv, name))
1024
+ #define rb_name_err_raise(mesg, recv, name) \
1025
+ rb_name_err_raise_str(rb_fstring_cstr(mesg), (recv), (name))
1026
+ NORETURN(void ruby_only_for_internal_use(const char *));
1027
+ #define ONLY_FOR_INTERNAL_USE(func) ruby_only_for_internal_use(func)
1028
+
1029
+ /* eval.c */
1030
+ VALUE rb_refinement_module_get_refined_class(VALUE module);
1031
+
1032
+ /* eval_error.c */
1033
+ void ruby_error_print(void);
1034
+ VALUE rb_get_backtrace(VALUE info);
1035
+
1036
+ /* eval_jump.c */
1037
+ void rb_call_end_proc(VALUE data);
1038
+ void rb_mark_end_proc(void);
1039
+
1040
+ /* file.c */
1041
+ VALUE rb_home_dir_of(VALUE user, VALUE result);
1042
+ VALUE rb_default_home_dir(VALUE result);
1043
+ VALUE rb_realpath_internal(VALUE basedir, VALUE path, int strict);
1044
+ void rb_file_const(const char*, VALUE);
1045
+ int rb_file_load_ok(const char *);
1046
+ VALUE rb_file_expand_path_fast(VALUE, VALUE);
1047
+ VALUE rb_file_expand_path_internal(VALUE, VALUE, int, int, VALUE);
1048
+ VALUE rb_get_path_check_to_string(VALUE, int);
1049
+ VALUE rb_get_path_check_convert(VALUE, VALUE, int);
1050
+ void Init_File(void);
1051
+ int ruby_is_fd_loadable(int fd);
1052
+
1053
+ #ifdef RUBY_FUNCTION_NAME_STRING
1054
+ # if defined __GNUC__ && __GNUC__ >= 4
1055
+ # pragma GCC visibility push(default)
1056
+ # endif
1057
+ NORETURN(void rb_sys_fail_path_in(const char *func_name, VALUE path));
1058
+ NORETURN(void rb_syserr_fail_path_in(const char *func_name, int err, VALUE path));
1059
+ # if defined __GNUC__ && __GNUC__ >= 4
1060
+ # pragma GCC visibility pop
1061
+ # endif
1062
+ # define rb_sys_fail_path(path) rb_sys_fail_path_in(RUBY_FUNCTION_NAME_STRING, path)
1063
+ # define rb_syserr_fail_path(err, path) rb_syserr_fail_path_in(RUBY_FUNCTION_NAME_STRING, (err), (path))
1064
+ #else
1065
+ # define rb_sys_fail_path(path) rb_sys_fail_str(path)
1066
+ # define rb_syserr_fail_path(err, path) rb_syserr_fail_str((err), (path))
1067
+ #endif
1068
+
1069
+ /* gc.c */
1070
+ extern VALUE *ruby_initial_gc_stress_ptr;
1071
+ extern int ruby_disable_gc;
1072
+ void Init_heap(void);
1073
+ void *ruby_mimmalloc(size_t size);
1074
+ void ruby_mimfree(void *ptr);
1075
+ void rb_objspace_set_event_hook(const rb_event_flag_t event);
1076
+ #if USE_RGENGC
1077
+ void rb_gc_writebarrier_remember(VALUE obj);
1078
+ #else
1079
+ #define rb_gc_writebarrier_remember(obj) 0
1080
+ #endif
1081
+ void ruby_gc_set_params(int safe_level);
1082
+ void rb_copy_wb_protected_attribute(VALUE dest, VALUE obj);
1083
+
1084
+ #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) || defined(_WIN32)
1085
+ #define ruby_sized_xrealloc(ptr, new_size, old_size) ruby_xrealloc(ptr, new_size)
1086
+ #define ruby_sized_xrealloc2(ptr, new_count, element_size, old_count) ruby_xrealloc(ptr, new_count, element_size)
1087
+ #define ruby_sized_xfree(ptr, size) ruby_xfree(ptr)
1088
+ #define SIZED_REALLOC_N(var,type,n,old_n) REALLOC_N(var, type, n)
1089
+ #else
1090
+ void *ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_ALLOC_SIZE((2));
1091
+ void *ruby_sized_xrealloc2(void *ptr, size_t new_count, size_t element_size, size_t old_count) RUBY_ATTR_ALLOC_SIZE((2, 3));
1092
+ void ruby_sized_xfree(void *x, size_t size);
1093
+ #define SIZED_REALLOC_N(var,type,n,old_n) ((var)=(type*)ruby_sized_xrealloc((char*)(var), (n) * sizeof(type), (old_n) * sizeof(type)))
1094
+ #endif
1095
+
1096
+ void rb_gc_resurrect(VALUE ptr);
1097
+
1098
+ /* optimized version of NEWOBJ() */
1099
+ #undef NEWOBJF_OF
1100
+ #undef RB_NEWOBJ_OF
1101
+ #define RB_NEWOBJ_OF(obj,type,klass,flags) \
1102
+ type *(obj) = (type*)(((flags) & FL_WB_PROTECTED) ? \
1103
+ rb_wb_protected_newobj_of(klass, (flags) & ~FL_WB_PROTECTED) : \
1104
+ rb_wb_unprotected_newobj_of(klass, flags))
1105
+ #define NEWOBJ_OF(obj,type,klass,flags) RB_NEWOBJ_OF(obj,type,klass,flags)
1106
+
1107
+ /* hash.c */
1108
+ struct st_table *rb_hash_tbl_raw(VALUE hash);
1109
+ VALUE rb_hash_has_key(VALUE hash, VALUE key);
1110
+ VALUE rb_hash_default_value(VALUE hash, VALUE key);
1111
+ VALUE rb_hash_set_default_proc(VALUE hash, VALUE proc);
1112
+ long rb_objid_hash(st_index_t index);
1113
+ long rb_dbl_long_hash(double d);
1114
+ st_table *rb_init_identtable(void);
1115
+ st_table *rb_init_identtable_with_size(st_index_t size);
1116
+ VALUE rb_hash_compare_by_id_p(VALUE hash);
1117
+
1118
+ #define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h)
1119
+ VALUE rb_hash_keys(VALUE hash);
1120
+ VALUE rb_hash_values(VALUE hash);
1121
+ VALUE rb_hash_rehash(VALUE hash);
1122
+ int rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val);
1123
+ #define HASH_DELETED FL_USER1
1124
+ #define HASH_PROC_DEFAULT FL_USER2
1125
+
1126
+ /* inits.c */
1127
+ void rb_call_inits(void);
1128
+
1129
+ /* io.c */
1130
+ const char *ruby_get_inplace_mode(void);
1131
+ void ruby_set_inplace_mode(const char *);
1132
+ ssize_t rb_io_bufread(VALUE io, void *buf, size_t size);
1133
+ void rb_stdio_set_default_encoding(void);
1134
+ VALUE rb_io_flush_raw(VALUE, int);
1135
+ size_t rb_io_memsize(const rb_io_t *);
1136
+
1137
+ /* load.c */
1138
+ VALUE rb_get_load_path(void);
1139
+ VALUE rb_get_expanded_load_path(void);
1140
+ int rb_require_internal(VALUE fname, int safe);
1141
+ NORETURN(void rb_load_fail(VALUE, const char*));
1142
+
1143
+ /* loadpath.c */
1144
+ extern const char ruby_exec_prefix[];
1145
+ extern const char ruby_initial_load_paths[];
1146
+
1147
+ /* localeinit.c */
1148
+ int Init_enc_set_filesystem_encoding(void);
1149
+
1150
+ /* math.c */
1151
+ VALUE rb_math_atan2(VALUE, VALUE);
1152
+ VALUE rb_math_cos(VALUE);
1153
+ VALUE rb_math_cosh(VALUE);
1154
+ VALUE rb_math_exp(VALUE);
1155
+ VALUE rb_math_hypot(VALUE, VALUE);
1156
+ VALUE rb_math_log(int argc, const VALUE *argv);
1157
+ VALUE rb_math_sin(VALUE);
1158
+ VALUE rb_math_sinh(VALUE);
1159
+ VALUE rb_math_sqrt(VALUE);
1160
+
1161
+ /* newline.c */
1162
+ void Init_newline(void);
1163
+
1164
+ /* numeric.c */
1165
+
1166
+ #define FIXNUM_POSITIVE_P(num) ((SIGNED_VALUE)(num) > (SIGNED_VALUE)INT2FIX(0))
1167
+ #define FIXNUM_NEGATIVE_P(num) ((SIGNED_VALUE)(num) < 0)
1168
+ #define FIXNUM_ZERO_P(num) ((num) == INT2FIX(0))
1169
+
1170
+ #define INT_NEGATIVE_P(x) (FIXNUM_P(x) ? FIXNUM_NEGATIVE_P(x) : BIGNUM_NEGATIVE_P(x))
1171
+
1172
+ #ifndef ROUND_DEFAULT
1173
+ # define ROUND_DEFAULT RUBY_NUM_ROUND_HALF_UP
1174
+ #endif
1175
+ enum ruby_num_rounding_mode {
1176
+ RUBY_NUM_ROUND_HALF_UP,
1177
+ RUBY_NUM_ROUND_HALF_EVEN,
1178
+ RUBY_NUM_ROUND_HALF_DOWN,
1179
+ RUBY_NUM_ROUND_DEFAULT = ROUND_DEFAULT
1180
+ };
1181
+ #define ROUND_TO(mode, even, up, down) \
1182
+ ((mode) == RUBY_NUM_ROUND_HALF_EVEN ? even : \
1183
+ (mode) == RUBY_NUM_ROUND_HALF_UP ? up : down)
1184
+ #define ROUND_FUNC(mode, name) \
1185
+ ROUND_TO(mode, name##_half_even, name##_half_up, name##_half_down)
1186
+ #define ROUND_CALL(mode, name, args) \
1187
+ ROUND_TO(mode, name##_half_even args, \
1188
+ name##_half_up args, name##_half_down args)
1189
+
1190
+ int rb_num_to_uint(VALUE val, unsigned int *ret);
1191
+ VALUE ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl);
1192
+ int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl);
1193
+ double ruby_float_mod(double x, double y);
1194
+ int rb_num_negative_p(VALUE);
1195
+ VALUE rb_int_succ(VALUE num);
1196
+ VALUE rb_int_pred(VALUE num);
1197
+ VALUE rb_int_uminus(VALUE num);
1198
+ VALUE rb_float_uminus(VALUE num);
1199
+ VALUE rb_int_plus(VALUE x, VALUE y);
1200
+ VALUE rb_int_minus(VALUE x, VALUE y);
1201
+ VALUE rb_int_mul(VALUE x, VALUE y);
1202
+ VALUE rb_int_idiv(VALUE x, VALUE y);
1203
+ VALUE rb_int_modulo(VALUE x, VALUE y);
1204
+ VALUE rb_int_round(VALUE num, int ndigits, enum ruby_num_rounding_mode mode);
1205
+ VALUE rb_int2str(VALUE num, int base);
1206
+ VALUE rb_dbl_hash(double d);
1207
+ VALUE rb_fix_plus(VALUE x, VALUE y);
1208
+ VALUE rb_int_gt(VALUE x, VALUE y);
1209
+ VALUE rb_float_gt(VALUE x, VALUE y);
1210
+ VALUE rb_int_ge(VALUE x, VALUE y);
1211
+ enum ruby_num_rounding_mode rb_num_get_rounding_option(VALUE opts);
1212
+ double rb_int_fdiv_double(VALUE x, VALUE y);
1213
+ VALUE rb_int_pow(VALUE x, VALUE y);
1214
+ VALUE rb_float_pow(VALUE x, VALUE y);
1215
+ VALUE rb_int_cmp(VALUE x, VALUE y);
1216
+ VALUE rb_int_equal(VALUE x, VALUE y);
1217
+ VALUE rb_int_divmod(VALUE x, VALUE y);
1218
+ VALUE rb_int_and(VALUE x, VALUE y);
1219
+ VALUE rb_int_lshift(VALUE x, VALUE y);
1220
+ VALUE rb_int_div(VALUE x, VALUE y);
1221
+ VALUE rb_int_abs(VALUE num);
1222
+ VALUE rb_float_abs(VALUE flt);
1223
+
1224
+ #if USE_FLONUM
1225
+ #define RUBY_BIT_ROTL(v, n) (((v) << (n)) | ((v) >> ((sizeof(v) * 8) - n)))
1226
+ #define RUBY_BIT_ROTR(v, n) (((v) >> (n)) | ((v) << ((sizeof(v) * 8) - n)))
1227
+ #endif
1228
+
1229
+ static inline double
1230
+ rb_float_flonum_value(VALUE v)
1231
+ {
1232
+ #if USE_FLONUM
1233
+ if (v != (VALUE)0x8000000000000002) { /* LIKELY */
1234
+ union {
1235
+ double d;
1236
+ VALUE v;
1237
+ } t;
1238
+
1239
+ VALUE b63 = (v >> 63);
1240
+ /* e: xx1... -> 011... */
1241
+ /* xx0... -> 100... */
1242
+ /* ^b63 */
1243
+ t.v = RUBY_BIT_ROTR((2 - b63) | (v & ~(VALUE)0x03), 3);
1244
+ return t.d;
1245
+ }
1246
+ #endif
1247
+ return 0.0;
1248
+ }
1249
+
1250
+ static inline double
1251
+ rb_float_noflonum_value(VALUE v)
1252
+ {
1253
+ return ((struct RFloat *)v)->float_value;
1254
+ }
1255
+
1256
+ static inline double
1257
+ rb_float_value_inline(VALUE v)
1258
+ {
1259
+ if (FLONUM_P(v)) {
1260
+ return rb_float_flonum_value(v);
1261
+ }
1262
+ return rb_float_noflonum_value(v);
1263
+ }
1264
+
1265
+ static inline VALUE
1266
+ rb_float_new_inline(double d)
1267
+ {
1268
+ #if USE_FLONUM
1269
+ union {
1270
+ double d;
1271
+ VALUE v;
1272
+ } t;
1273
+ int bits;
1274
+
1275
+ t.d = d;
1276
+ bits = (int)((VALUE)(t.v >> 60) & 0x7);
1277
+ /* bits contains 3 bits of b62..b60. */
1278
+ /* bits - 3 = */
1279
+ /* b011 -> b000 */
1280
+ /* b100 -> b001 */
1281
+
1282
+ if (t.v != 0x3000000000000000 /* 1.72723e-77 */ &&
1283
+ !((bits-3) & ~0x01)) {
1284
+ return (RUBY_BIT_ROTL(t.v, 3) & ~(VALUE)0x01) | 0x02;
1285
+ }
1286
+ else if (t.v == (VALUE)0) {
1287
+ /* +0.0 */
1288
+ return 0x8000000000000002;
1289
+ }
1290
+ /* out of range */
1291
+ #endif
1292
+ return rb_float_new_in_heap(d);
1293
+ }
1294
+
1295
+ #define rb_float_value(v) rb_float_value_inline(v)
1296
+ #define rb_float_new(d) rb_float_new_inline(d)
1297
+
1298
+ /* object.c */
1299
+ void rb_obj_copy_ivar(VALUE dest, VALUE obj);
1300
+ CONSTFUNC(VALUE rb_obj_equal(VALUE obj1, VALUE obj2));
1301
+ CONSTFUNC(VALUE rb_obj_not(VALUE obj));
1302
+ VALUE rb_class_search_ancestor(VALUE klass, VALUE super);
1303
+ NORETURN(void rb_undefined_alloc(VALUE klass));
1304
+ double rb_num_to_dbl(VALUE val);
1305
+ VALUE rb_obj_dig(int argc, VALUE *argv, VALUE self, VALUE notfound);
1306
+
1307
+ struct RBasicRaw {
1308
+ VALUE flags;
1309
+ VALUE klass;
1310
+ };
1311
+
1312
+ #define RBASIC_CLEAR_CLASS(obj) memset(&(((struct RBasicRaw *)((VALUE)(obj)))->klass), 0, sizeof(VALUE))
1313
+ #define RBASIC_SET_CLASS_RAW(obj, cls) memcpy(&((struct RBasicRaw *)((VALUE)(obj)))->klass, &(cls), sizeof(VALUE))
1314
+ #define RBASIC_SET_CLASS(obj, cls) do { \
1315
+ VALUE _obj_ = (obj); \
1316
+ RB_OBJ_WRITE(_obj_, &((struct RBasicRaw *)(_obj_))->klass, cls); \
1317
+ } while (0)
1318
+
1319
+ /* parse.y */
1320
+ #ifndef USE_SYMBOL_GC
1321
+ #define USE_SYMBOL_GC 1
1322
+ #endif
1323
+ VALUE rb_parser_get_yydebug(VALUE);
1324
+ VALUE rb_parser_set_yydebug(VALUE, VALUE);
1325
+ VALUE rb_parser_set_context(VALUE, const struct rb_block *, int);
1326
+ void *rb_parser_load_file(VALUE parser, VALUE name);
1327
+ int rb_is_const_name(VALUE name);
1328
+ int rb_is_class_name(VALUE name);
1329
+ int rb_is_global_name(VALUE name);
1330
+ int rb_is_instance_name(VALUE name);
1331
+ int rb_is_attrset_name(VALUE name);
1332
+ int rb_is_local_name(VALUE name);
1333
+ int rb_is_method_name(VALUE name);
1334
+ int rb_is_junk_name(VALUE name);
1335
+ PUREFUNC(int rb_is_const_sym(VALUE sym));
1336
+ PUREFUNC(int rb_is_class_sym(VALUE sym));
1337
+ PUREFUNC(int rb_is_global_sym(VALUE sym));
1338
+ PUREFUNC(int rb_is_instance_sym(VALUE sym));
1339
+ PUREFUNC(int rb_is_attrset_sym(VALUE sym));
1340
+ PUREFUNC(int rb_is_local_sym(VALUE sym));
1341
+ PUREFUNC(int rb_is_method_sym(VALUE sym));
1342
+ PUREFUNC(int rb_is_junk_sym(VALUE sym));
1343
+ ID rb_make_internal_id(void);
1344
+ void rb_gc_free_dsymbol(VALUE);
1345
+ ID rb_id_attrget(ID id);
1346
+
1347
+ /* proc.c */
1348
+ VALUE rb_proc_location(VALUE self);
1349
+ st_index_t rb_hash_proc(st_index_t hash, VALUE proc);
1350
+ int rb_block_arity(void);
1351
+ int rb_block_min_max_arity(int *max);
1352
+ VALUE rb_func_proc_new(rb_block_call_func_t func, VALUE val);
1353
+ VALUE rb_func_lambda_new(rb_block_call_func_t func, VALUE val, int min_argc, int max_argc);
1354
+
1355
+ /* process.c */
1356
+ #define RB_MAX_GROUPS (65536)
1357
+
1358
+ struct rb_execarg {
1359
+ union {
1360
+ struct {
1361
+ VALUE shell_script;
1362
+ } sh;
1363
+ struct {
1364
+ VALUE command_name;
1365
+ VALUE command_abspath; /* full path string or nil */
1366
+ VALUE argv_str;
1367
+ VALUE argv_buf;
1368
+ } cmd;
1369
+ } invoke;
1370
+ VALUE redirect_fds;
1371
+ VALUE envp_str;
1372
+ VALUE envp_buf;
1373
+ VALUE dup2_tmpbuf;
1374
+ unsigned use_shell : 1;
1375
+ unsigned pgroup_given : 1;
1376
+ unsigned umask_given : 1;
1377
+ unsigned unsetenv_others_given : 1;
1378
+ unsigned unsetenv_others_do : 1;
1379
+ unsigned close_others_given : 1;
1380
+ unsigned close_others_do : 1;
1381
+ unsigned chdir_given : 1;
1382
+ unsigned new_pgroup_given : 1;
1383
+ unsigned new_pgroup_flag : 1;
1384
+ unsigned uid_given : 1;
1385
+ unsigned gid_given : 1;
1386
+ rb_pid_t pgroup_pgid; /* asis(-1), new pgroup(0), specified pgroup (0<V). */
1387
+ VALUE rlimit_limits; /* Qfalse or [[rtype, softlim, hardlim], ...] */
1388
+ mode_t umask_mask;
1389
+ rb_uid_t uid;
1390
+ rb_gid_t gid;
1391
+ int close_others_maxhint;
1392
+ VALUE fd_dup2;
1393
+ VALUE fd_close;
1394
+ VALUE fd_open;
1395
+ VALUE fd_dup2_child;
1396
+ VALUE env_modification; /* Qfalse or [[k1,v1], ...] */
1397
+ VALUE path_env;
1398
+ VALUE chdir_dir;
1399
+ };
1400
+
1401
+ /* argv_str contains extra two elements.
1402
+ * The beginning one is for /bin/sh used by exec_with_sh.
1403
+ * The last one for terminating NULL used by execve.
1404
+ * See rb_exec_fillarg() in process.c. */
1405
+ #define ARGVSTR2ARGC(argv_str) (RSTRING_LEN(argv_str) / sizeof(char *) - 2)
1406
+ #define ARGVSTR2ARGV(argv_str) ((char **)RSTRING_PTR(argv_str) + 1)
1407
+
1408
+ rb_pid_t rb_fork_ruby(int *status);
1409
+ void rb_last_status_clear(void);
1410
+
1411
+ /* rational.c */
1412
+ VALUE rb_rational_uminus(VALUE self);
1413
+ VALUE rb_rational_plus(VALUE self, VALUE other);
1414
+ VALUE rb_lcm(VALUE x, VALUE y);
1415
+ VALUE rb_rational_reciprocal(VALUE x);
1416
+ VALUE rb_cstr_to_rat(const char *, int);
1417
+ VALUE rb_rational_abs(VALUE self);
1418
+ VALUE rb_rational_cmp(VALUE self, VALUE other);
1419
+
1420
+ /* re.c */
1421
+ VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline);
1422
+ VALUE rb_reg_check_preprocess(VALUE);
1423
+ long rb_reg_search0(VALUE, VALUE, long, int, int);
1424
+ VALUE rb_reg_match_p(VALUE re, VALUE str, long pos);
1425
+ void rb_backref_set_string(VALUE string, long pos, long len);
1426
+ int rb_match_count(VALUE match);
1427
+ int rb_match_nth_defined(int nth, VALUE match);
1428
+
1429
+ /* signal.c */
1430
+ extern int ruby_enable_coredump;
1431
+ int rb_get_next_signal(void);
1432
+ int rb_sigaltstack_size(void);
1433
+
1434
+ /* strftime.c */
1435
+ #ifdef RUBY_ENCODING_H
1436
+ VALUE rb_strftime_timespec(const char *format, size_t format_len, rb_encoding *enc,
1437
+ const struct vtm *vtm, struct timespec *ts, int gmt);
1438
+ VALUE rb_strftime(const char *format, size_t format_len, rb_encoding *enc,
1439
+ const struct vtm *vtm, VALUE timev, int gmt);
1440
+ #endif
1441
+
1442
+ /* string.c */
1443
+ VALUE rb_fstring(VALUE);
1444
+ VALUE rb_fstring_new(const char *ptr, long len);
1445
+ #define rb_fstring_lit(str) rb_fstring_new((str), rb_strlen_lit(str))
1446
+ #define rb_fstring_literal(str) rb_fstring_lit(str)
1447
+ VALUE rb_fstring_cstr(const char *str);
1448
+ #ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
1449
+ # define rb_fstring_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
1450
+ (__builtin_constant_p(str)) ? \
1451
+ rb_fstring_new((str), (long)strlen(str)) : \
1452
+ rb_fstring_cstr(str) \
1453
+ )
1454
+ #endif
1455
+ #ifdef RUBY_ENCODING_H
1456
+ VALUE rb_fstring_enc_new(const char *ptr, long len, rb_encoding *enc);
1457
+ #define rb_fstring_enc_lit(str, enc) rb_fstring_enc_new((str), rb_strlen_lit(str), (enc))
1458
+ #define rb_fstring_enc_literal(str, enc) rb_fstring_enc_lit(str, enc)
1459
+ VALUE rb_fstring_enc_cstr(const char *ptr, rb_encoding *enc);
1460
+ # ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
1461
+ # define rb_fstring_enc_cstr(str, enc) RB_GNUC_EXTENSION_BLOCK( \
1462
+ (__builtin_constant_p(str)) ? \
1463
+ rb_fstring_enc_new((str), (long)strlen(str), (enc)) : \
1464
+ rb_fstring_enc_cstr(str, enc) \
1465
+ )
1466
+ # endif
1467
+ #endif
1468
+ int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p);
1469
+ int rb_str_symname_p(VALUE);
1470
+ VALUE rb_str_quote_unprintable(VALUE);
1471
+ VALUE rb_id_quote_unprintable(ID);
1472
+ #define QUOTE(str) rb_str_quote_unprintable(str)
1473
+ #define QUOTE_ID(id) rb_id_quote_unprintable(id)
1474
+ char *rb_str_fill_terminator(VALUE str, const int termlen);
1475
+ void rb_str_change_terminator_length(VALUE str, const int oldtermlen, const int termlen);
1476
+ VALUE rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg);
1477
+ VALUE rb_str_tmp_frozen_acquire(VALUE str);
1478
+ void rb_str_tmp_frozen_release(VALUE str, VALUE tmp);
1479
+ VALUE rb_str_chomp_string(VALUE str, VALUE chomp);
1480
+ #ifdef RUBY_ENCODING_H
1481
+ VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc);
1482
+ VALUE rb_str_cat_conv_enc_opts(VALUE newstr, long ofs, const char *ptr, long len,
1483
+ rb_encoding *from, int ecflags, VALUE ecopts);
1484
+ VALUE rb_enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl);
1485
+ #endif
1486
+ #define STR_NOEMBED FL_USER1
1487
+ #define STR_SHARED FL_USER2 /* = ELTS_SHARED */
1488
+ #define STR_EMBED_P(str) (!FL_TEST_RAW((str), STR_NOEMBED))
1489
+ #define STR_SHARED_P(s) FL_ALL_RAW((s), STR_NOEMBED|ELTS_SHARED)
1490
+ #define is_ascii_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT)
1491
+ #define is_broken_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN)
1492
+ size_t rb_str_memsize(VALUE);
1493
+ VALUE rb_sym_proc_call(ID mid, int argc, const VALUE *argv, VALUE passed_proc);
1494
+ VALUE rb_sym_to_proc(VALUE sym);
1495
+
1496
+ /* symbol.c */
1497
+ #ifdef RUBY_ENCODING_H
1498
+ VALUE rb_sym_intern(const char *ptr, long len, rb_encoding *enc);
1499
+ VALUE rb_sym_intern_cstr(const char *ptr, rb_encoding *enc);
1500
+ #ifdef __GNUC__
1501
+ #define rb_sym_intern_cstr(ptr, enc) __extension__ ( \
1502
+ { \
1503
+ (__builtin_constant_p(ptr)) ? \
1504
+ rb_sym_intern((ptr), (long)strlen(ptr), (enc)) : \
1505
+ rb_sym_intern_cstr((ptr), (enc)); \
1506
+ })
1507
+ #endif
1508
+ #endif
1509
+ VALUE rb_sym_intern_ascii(const char *ptr, long len);
1510
+ VALUE rb_sym_intern_ascii_cstr(const char *ptr);
1511
+ #ifdef __GNUC__
1512
+ #define rb_sym_intern_ascii_cstr(ptr) __extension__ ( \
1513
+ { \
1514
+ (__builtin_constant_p(ptr)) ? \
1515
+ rb_sym_intern_ascii((ptr), (long)strlen(ptr)) : \
1516
+ rb_sym_intern_ascii_cstr(ptr); \
1517
+ })
1518
+ #endif
1519
+
1520
+ /* struct.c */
1521
+ VALUE rb_struct_init_copy(VALUE copy, VALUE s);
1522
+ VALUE rb_struct_lookup(VALUE s, VALUE idx);
1523
+
1524
+ /* time.c */
1525
+ struct timeval rb_time_timeval(VALUE);
1526
+
1527
+ /* thread.c */
1528
+ VALUE rb_obj_is_mutex(VALUE obj);
1529
+ VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
1530
+ void rb_thread_execute_interrupts(VALUE th);
1531
+ void rb_clear_trace_func(void);
1532
+ VALUE rb_get_coverages(void);
1533
+ VALUE rb_thread_shield_new(void);
1534
+ VALUE rb_thread_shield_wait(VALUE self);
1535
+ VALUE rb_thread_shield_release(VALUE self);
1536
+ VALUE rb_thread_shield_destroy(VALUE self);
1537
+ int rb_thread_to_be_killed(VALUE thread);
1538
+ void rb_mutex_allow_trap(VALUE self, int val);
1539
+ VALUE rb_uninterruptible(VALUE (*b_proc)(ANYARGS), VALUE data);
1540
+ VALUE rb_mutex_owned_p(VALUE self);
1541
+ void ruby_kill(rb_pid_t pid, int sig);
1542
+
1543
+ /* thread_pthread.c, thread_win32.c */
1544
+ void Init_native_thread(void);
1545
+ int rb_divert_reserved_fd(int fd);
1546
+
1547
+ /* transcode.c */
1548
+ extern VALUE rb_cEncodingConverter;
1549
+ size_t rb_econv_memsize(rb_econv_t *);
1550
+
1551
+ /* us_ascii.c */
1552
+ extern rb_encoding OnigEncodingUS_ASCII;
1553
+
1554
+ /* util.c */
1555
+ char *ruby_dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve);
1556
+ char *ruby_hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign, char **rve);
1557
+
1558
+ /* utf_8.c */
1559
+ extern rb_encoding OnigEncodingUTF_8;
1560
+
1561
+ /* variable.c */
1562
+ void rb_gc_mark_global_tbl(void);
1563
+ size_t rb_generic_ivar_memsize(VALUE);
1564
+ VALUE rb_search_class_path(VALUE);
1565
+ VALUE rb_attr_delete(VALUE, ID);
1566
+ VALUE rb_ivar_lookup(VALUE obj, ID id, VALUE undef);
1567
+ void rb_autoload_str(VALUE mod, ID id, VALUE file);
1568
+ void rb_deprecate_constant(VALUE mod, const char *name);
1569
+
1570
+ /* version.c */
1571
+ extern const char ruby_engine[];
1572
+
1573
+ /* vm_insnhelper.h */
1574
+ rb_serial_t rb_next_class_serial(void);
1575
+
1576
+ /* vm.c */
1577
+ VALUE rb_obj_is_thread(VALUE obj);
1578
+ void rb_vm_mark(void *ptr);
1579
+ void Init_BareVM(void);
1580
+ void Init_vm_objects(void);
1581
+ PUREFUNC(VALUE rb_vm_top_self(void));
1582
+ void rb_thread_recycle_stack_release(VALUE *);
1583
+ void rb_vm_change_state(void);
1584
+ void rb_vm_inc_const_missing_count(void);
1585
+ void rb_thread_mark(void *th);
1586
+ const void **rb_vm_get_insns_address_table(void);
1587
+ VALUE rb_sourcefilename(void);
1588
+ VALUE rb_source_location(int *pline);
1589
+ const char *rb_source_loc(int *pline);
1590
+ void rb_vm_pop_cfunc_frame(void);
1591
+ int rb_vm_add_root_module(ID id, VALUE module);
1592
+ void rb_vm_check_redefinition_by_prepend(VALUE klass);
1593
+ VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements);
1594
+ VALUE ruby_vm_special_exception_copy(VALUE);
1595
+ PUREFUNC(st_table *rb_vm_fstring_table(void));
1596
+
1597
+
1598
+ /* vm_dump.c */
1599
+ void rb_print_backtrace(void);
1600
+
1601
+ /* vm_eval.c */
1602
+ void Init_vm_eval(void);
1603
+ VALUE rb_current_realfilepath(void);
1604
+ VALUE rb_check_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE);
1605
+ typedef void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE);
1606
+ VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv,
1607
+ rb_check_funcall_hook *hook, VALUE arg);
1608
+ VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE);
1609
+ VALUE rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, int *stateptr);
1610
+ VALUE rb_yield_1(VALUE val);
1611
+ VALUE rb_yield_lambda(VALUE values);
1612
+ VALUE rb_lambda_call(VALUE obj, ID mid, int argc, const VALUE *argv,
1613
+ rb_block_call_func_t bl_proc, int min_argc, int max_argc,
1614
+ VALUE data2);
1615
+
1616
+ /* vm_insnhelper.c */
1617
+ VALUE rb_equal_opt(VALUE obj1, VALUE obj2);
1618
+
1619
+ /* vm_method.c */
1620
+ void Init_eval_method(void);
1621
+ int rb_method_defined_by(VALUE obj, ID mid, VALUE (*cfunc)(ANYARGS));
1622
+
1623
+ /* miniprelude.c, prelude.c */
1624
+ void Init_prelude(void);
1625
+
1626
+ /* vm_backtrace.c */
1627
+ void Init_vm_backtrace(void);
1628
+ VALUE rb_vm_thread_backtrace(int argc, const VALUE *argv, VALUE thval);
1629
+ VALUE rb_vm_thread_backtrace_locations(int argc, const VALUE *argv, VALUE thval);
1630
+
1631
+ VALUE rb_make_backtrace(void);
1632
+ void rb_backtrace_print_as_bugreport(void);
1633
+ int rb_backtrace_p(VALUE obj);
1634
+ VALUE rb_backtrace_to_str_ary(VALUE obj);
1635
+ VALUE rb_backtrace_to_location_ary(VALUE obj);
1636
+ void rb_backtrace_print_to(VALUE output);
1637
+ VALUE rb_vm_backtrace_object(void);
1638
+
1639
+ RUBY_SYMBOL_EXPORT_BEGIN
1640
+ const char *rb_objspace_data_type_name(VALUE obj);
1641
+
1642
+ /* Temporary. This API will be removed (renamed). */
1643
+ VALUE rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd);
1644
+
1645
+ /* bignum.c (export) */
1646
+ VALUE rb_big_mul_normal(VALUE x, VALUE y);
1647
+ VALUE rb_big_mul_balance(VALUE x, VALUE y);
1648
+ VALUE rb_big_mul_karatsuba(VALUE x, VALUE y);
1649
+ VALUE rb_big_mul_toom3(VALUE x, VALUE y);
1650
+ VALUE rb_big_sq_fast(VALUE x);
1651
+ VALUE rb_big_divrem_normal(VALUE x, VALUE y);
1652
+ VALUE rb_big2str_poweroftwo(VALUE x, int base);
1653
+ VALUE rb_big2str_generic(VALUE x, int base);
1654
+ VALUE rb_str2big_poweroftwo(VALUE arg, int base, int badcheck);
1655
+ VALUE rb_str2big_normal(VALUE arg, int base, int badcheck);
1656
+ VALUE rb_str2big_karatsuba(VALUE arg, int base, int badcheck);
1657
+ #if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
1658
+ VALUE rb_big_mul_gmp(VALUE x, VALUE y);
1659
+ VALUE rb_big_divrem_gmp(VALUE x, VALUE y);
1660
+ VALUE rb_big2str_gmp(VALUE x, int base);
1661
+ VALUE rb_str2big_gmp(VALUE arg, int base, int badcheck);
1662
+ #endif
1663
+
1664
+ /* error.c (export) */
1665
+ int rb_bug_reporter_add(void (*func)(FILE *, void *), void *data);
1666
+ NORETURN(void rb_unexpected_type(VALUE,int));
1667
+ #undef Check_Type
1668
+ #define Check_Type(v, t) \
1669
+ (!RB_TYPE_P((VALUE)(v), (t)) || \
1670
+ ((t) == RUBY_T_DATA && RTYPEDDATA_P(v)) ? \
1671
+ rb_unexpected_type((VALUE)(v), (t)) : (void)0)
1672
+
1673
+ /* file.c (export) */
1674
+ #ifdef HAVE_READLINK
1675
+ VALUE rb_readlink(VALUE path, rb_encoding *enc);
1676
+ #endif
1677
+ #ifdef __APPLE__
1678
+ VALUE rb_str_normalize_ospath(const char *ptr, long len);
1679
+ #endif
1680
+
1681
+ /* hash.c (export) */
1682
+ VALUE rb_hash_delete_entry(VALUE hash, VALUE key);
1683
+ VALUE rb_ident_hash_new(void);
1684
+
1685
+ /* io.c (export) */
1686
+ void rb_maygvl_fd_fix_cloexec(int fd);
1687
+ int rb_gc_for_fd(int err);
1688
+ void rb_write_error_str(VALUE mesg);
1689
+
1690
+ /* numeric.c (export) */
1691
+ VALUE rb_int_positive_pow(long x, unsigned long y);
1692
+
1693
+ /* process.c (export) */
1694
+ int rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen);
1695
+ rb_pid_t rb_fork_async_signal_safe(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fds, char *errmsg, size_t errmsg_buflen);
1696
+ VALUE rb_execarg_new(int argc, const VALUE *argv, int accept_shell);
1697
+ struct rb_execarg *rb_execarg_get(VALUE execarg_obj); /* dangerous. needs GC guard. */
1698
+ VALUE rb_execarg_init(int argc, const VALUE *argv, int accept_shell, VALUE execarg_obj);
1699
+ int rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val);
1700
+ void rb_execarg_parent_start(VALUE execarg_obj);
1701
+ void rb_execarg_parent_end(VALUE execarg_obj);
1702
+ int rb_execarg_run_options(const struct rb_execarg *e, struct rb_execarg *s, char* errmsg, size_t errmsg_buflen);
1703
+ VALUE rb_execarg_extract_options(VALUE execarg_obj, VALUE opthash);
1704
+ void rb_execarg_setenv(VALUE execarg_obj, VALUE env);
1705
+
1706
+ /* rational.c (export) */
1707
+ VALUE rb_gcd(VALUE x, VALUE y);
1708
+ VALUE rb_gcd_normal(VALUE self, VALUE other);
1709
+ #if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
1710
+ VALUE rb_gcd_gmp(VALUE x, VALUE y);
1711
+ #endif
1712
+
1713
+ /* string.c (export) */
1714
+ #ifdef RUBY_ENCODING_H
1715
+ /* internal use */
1716
+ VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb_encoding *enc);
1717
+ #endif
1718
+
1719
+ /* thread.c (export) */
1720
+ int ruby_thread_has_gvl_p(void); /* for ext/fiddle/closure.c */
1721
+
1722
+ /* util.c (export) */
1723
+ extern const signed char ruby_digit36_to_number_table[];
1724
+ extern const char ruby_hexdigits[];
1725
+ extern unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, size_t *retlen, int *overflow);
1726
+
1727
+ /* variable.c (export) */
1728
+ void rb_mark_generic_ivar(VALUE);
1729
+ VALUE rb_const_missing(VALUE klass, VALUE name);
1730
+ int rb_class_ivar_set(VALUE klass, ID vid, VALUE value);
1731
+ st_table *rb_st_copy(VALUE obj, struct st_table *orig_tbl);
1732
+
1733
+ /* gc.c (export) */
1734
+ VALUE rb_wb_protected_newobj_of(VALUE, VALUE);
1735
+ VALUE rb_wb_unprotected_newobj_of(VALUE, VALUE);
1736
+
1737
+ size_t rb_obj_memsize_of(VALUE);
1738
+ void rb_gc_verify_internal_consistency(void);
1739
+
1740
+ #define RB_OBJ_GC_FLAGS_MAX 5
1741
+ size_t rb_obj_gc_flags(VALUE, ID[], size_t);
1742
+ void rb_gc_mark_values(long n, const VALUE *values);
1743
+
1744
+ #if IMEMO_DEBUG
1745
+ VALUE rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0, const char *file, int line);
1746
+ #define rb_imemo_new(type, v1, v2, v3, v0) rb_imemo_new_debug(type, v1, v2, v3, v0, __FILE__, __LINE__)
1747
+ #else
1748
+ VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0);
1749
+ #endif
1750
+
1751
+ RUBY_SYMBOL_EXPORT_END
1752
+
1753
+ #define RUBY_DTRACE_CREATE_HOOK(name, arg) \
1754
+ RUBY_DTRACE_HOOK(name##_CREATE, arg)
1755
+ #define RUBY_DTRACE_HOOK(name, arg) \
1756
+ do { \
1757
+ if (UNLIKELY(RUBY_DTRACE_##name##_ENABLED())) { \
1758
+ int dtrace_line; \
1759
+ const char *dtrace_file = rb_source_loc(&dtrace_line); \
1760
+ if (!dtrace_file) dtrace_file = ""; \
1761
+ RUBY_DTRACE_##name(arg, dtrace_file, dtrace_line); \
1762
+ } \
1763
+ } while (0)
1764
+
1765
+ #define RB_OBJ_BUILTIN_TYPE(obj) rb_obj_builtin_type(obj)
1766
+ #define OBJ_BUILTIN_TYPE(obj) RB_OBJ_BUILTIN_TYPE(obj)
1767
+ #ifdef __GNUC__
1768
+ #define rb_obj_builtin_type(obj) \
1769
+ __extension__({ \
1770
+ VALUE arg_obj = (obj); \
1771
+ RB_SPECIAL_CONST_P(arg_obj) ? -1 : \
1772
+ RB_BUILTIN_TYPE(arg_obj); \
1773
+ })
1774
+ #else
1775
+ static inline int
1776
+ rb_obj_builtin_type(VALUE obj)
1777
+ {
1778
+ return RB_SPECIAL_CONST_P(obj) ? -1 :
1779
+ RB_BUILTIN_TYPE(obj);
1780
+ }
1781
+ #endif
1782
+
1783
+ #if defined(__cplusplus)
1784
+ #if 0
1785
+ { /* satisfy cc-mode */
1786
+ #endif
1787
+ } /* extern "C" { */
1788
+ #endif
1789
+
1790
+ #endif /* RUBY_INTERNAL_H */