zscan 2.0.6 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/ext/extconf.rb +9 -1
  3. data/ext/pack/builtin-27.h +79 -0
  4. data/ext/pack/builtin.h +79 -0
  5. data/ext/pack/internal-27.h +96 -0
  6. data/ext/pack/internal-27/array.h +103 -0
  7. data/ext/pack/internal-27/bignum.h +246 -0
  8. data/ext/pack/internal-27/bits.h +566 -0
  9. data/ext/pack/internal-27/class.h +162 -0
  10. data/ext/pack/internal-27/compar.h +50 -0
  11. data/ext/pack/internal-27/compile.h +32 -0
  12. data/ext/pack/internal-27/compilers.h +108 -0
  13. data/ext/pack/internal-27/complex.h +29 -0
  14. data/ext/pack/internal-27/cont.h +23 -0
  15. data/ext/pack/internal-27/dir.h +17 -0
  16. data/ext/pack/internal-27/enc.h +20 -0
  17. data/ext/pack/internal-27/encoding.h +28 -0
  18. data/ext/pack/internal-27/enum.h +19 -0
  19. data/ext/pack/internal-27/enumerator.h +22 -0
  20. data/ext/pack/internal-27/error.h +129 -0
  21. data/ext/pack/internal-27/eval.h +33 -0
  22. data/ext/pack/internal-27/file.h +39 -0
  23. data/ext/pack/internal-27/fixnum.h +185 -0
  24. data/ext/pack/internal-27/gc.h +153 -0
  25. data/ext/pack/internal-27/hash.h +234 -0
  26. data/ext/pack/internal-27/imemo.h +242 -0
  27. data/ext/pack/internal-27/inits.h +51 -0
  28. data/ext/pack/internal-27/io.h +35 -0
  29. data/ext/pack/internal-27/load.h +19 -0
  30. data/ext/pack/internal-27/loadpath.h +17 -0
  31. data/ext/pack/internal-27/math.h +24 -0
  32. data/ext/pack/internal-27/missing.h +19 -0
  33. data/ext/pack/internal-27/mjit.h +29 -0
  34. data/ext/pack/internal-27/numeric.h +249 -0
  35. data/ext/pack/internal-27/object.h +60 -0
  36. data/ext/pack/internal-27/parse.h +23 -0
  37. data/ext/pack/internal-27/proc.h +32 -0
  38. data/ext/pack/internal-27/process.h +130 -0
  39. data/ext/pack/internal-27/random.h +17 -0
  40. data/ext/pack/internal-27/range.h +37 -0
  41. data/ext/pack/internal-27/rational.h +68 -0
  42. data/ext/pack/internal-27/re.h +29 -0
  43. data/ext/pack/internal-27/sanitizers.h +191 -0
  44. data/ext/pack/internal-27/serial.h +24 -0
  45. data/ext/pack/internal-27/signal.h +22 -0
  46. data/ext/pack/internal-27/static_assert.h +17 -0
  47. data/ext/pack/internal-27/string.h +135 -0
  48. data/ext/pack/internal-27/struct.h +154 -0
  49. data/ext/pack/internal-27/symbol.h +41 -0
  50. data/ext/pack/internal-27/thread.h +52 -0
  51. data/ext/pack/internal-27/time.h +35 -0
  52. data/ext/pack/internal-27/transcode.h +21 -0
  53. data/ext/pack/internal-27/util.h +31 -0
  54. data/ext/pack/internal-27/variable.h +92 -0
  55. data/ext/pack/internal-27/vm.h +127 -0
  56. data/ext/pack/internal-27/warnings.h +17 -0
  57. data/ext/pack/internal.h +57 -2102
  58. data/ext/pack/internal/array.h +103 -0
  59. data/ext/pack/internal/bignum.h +246 -0
  60. data/ext/pack/internal/bits.h +566 -0
  61. data/ext/pack/internal/class.h +162 -0
  62. data/ext/pack/internal/compar.h +50 -0
  63. data/ext/pack/internal/compile.h +32 -0
  64. data/ext/pack/internal/compilers.h +108 -0
  65. data/ext/pack/internal/complex.h +29 -0
  66. data/ext/pack/internal/cont.h +23 -0
  67. data/ext/pack/internal/dir.h +17 -0
  68. data/ext/pack/internal/enc.h +20 -0
  69. data/ext/pack/internal/encoding.h +28 -0
  70. data/ext/pack/internal/enum.h +19 -0
  71. data/ext/pack/internal/enumerator.h +22 -0
  72. data/ext/pack/internal/error.h +129 -0
  73. data/ext/pack/internal/eval.h +33 -0
  74. data/ext/pack/internal/file.h +39 -0
  75. data/ext/pack/internal/fixnum.h +185 -0
  76. data/ext/pack/internal/gc.h +153 -0
  77. data/ext/pack/internal/hash.h +234 -0
  78. data/ext/pack/internal/imemo.h +242 -0
  79. data/ext/pack/internal/inits.h +51 -0
  80. data/ext/pack/internal/io.h +35 -0
  81. data/ext/pack/internal/load.h +19 -0
  82. data/ext/pack/internal/loadpath.h +17 -0
  83. data/ext/pack/internal/math.h +24 -0
  84. data/ext/pack/internal/missing.h +19 -0
  85. data/ext/pack/internal/mjit.h +29 -0
  86. data/ext/pack/internal/numeric.h +249 -0
  87. data/ext/pack/internal/object.h +60 -0
  88. data/ext/pack/internal/parse.h +23 -0
  89. data/ext/pack/internal/proc.h +32 -0
  90. data/ext/pack/internal/process.h +130 -0
  91. data/ext/pack/internal/random.h +17 -0
  92. data/ext/pack/internal/range.h +37 -0
  93. data/ext/pack/internal/rational.h +68 -0
  94. data/ext/pack/internal/re.h +29 -0
  95. data/ext/pack/internal/sanitizers.h +191 -0
  96. data/ext/pack/internal/serial.h +24 -0
  97. data/ext/pack/internal/signal.h +22 -0
  98. data/ext/pack/internal/static_assert.h +17 -0
  99. data/ext/pack/internal/string.h +135 -0
  100. data/ext/pack/internal/struct.h +154 -0
  101. data/ext/pack/internal/symbol.h +41 -0
  102. data/ext/pack/internal/thread.h +52 -0
  103. data/ext/pack/internal/time.h +35 -0
  104. data/ext/pack/internal/transcode.h +21 -0
  105. data/ext/pack/internal/util.h +31 -0
  106. data/ext/pack/internal/variable.h +92 -0
  107. data/ext/pack/internal/vm.h +127 -0
  108. data/ext/pack/internal/warnings.h +17 -0
  109. data/ext/pack/pack-26.c +2 -109
  110. data/ext/pack/pack-27.c +1022 -0
  111. data/ext/pack/pack.c +57 -1047
  112. data/lib/zscan.rb +1 -1
  113. data/zscan.gemspec +1 -1
  114. metadata +109 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6ce7dfdae1102ea13d7fb8f453b38e585cadd9ce33b4234980f83ef72590cd6
4
- data.tar.gz: 6bc96f87de54c08e69ab2e42804e4513146b94470377f5cf05a40f32cdca258f
3
+ metadata.gz: c39c7ce41a6b386642a66bb35bab9a001ee161b6801c874d8c75977787a40e5f
4
+ data.tar.gz: 72daec28345deed995304ddf8256bbd47485ae2aa37ec6fb080eafe09e8c19a6
5
5
  SHA512:
6
- metadata.gz: 914deacaba1053755a6a24bc019f25b4c14dbb2668bca6a4e95f0e1f731e1523b42bb81b7b81bf42baf23d5f3a5cace271ee9bff805423698c5ed2665f31bdab
7
- data.tar.gz: abda8791d596bbccd138a36a61bc4df9bee0c4dda7da420b34364ba791d466d26b6952bdd2d331566197af37d5da5bce9a132f3de73d7a6acc6342a9aa4c8adf
6
+ metadata.gz: 2e3cf5fb6db0e380b30e35ae253bc2bb43471768fed90a483b549e3ba90ea8e6dcae418939fb08941475412a64064b6135869125c0e8dc6871f32b1f8c69bf1f
7
+ data.tar.gz: 96d100ccfe0953736ed543ef0f8080bd9fa1f7674da8df28372b60fb18fe0541518ff1d37d8440fa40dfcd0376e80f66a531c86630d35d2ddf125bc14165e6fd
@@ -1,15 +1,23 @@
1
1
  require "mkmf"
2
2
  require "fileutils"
3
+ require 'shellwords'
3
4
 
4
5
  if RbConfig::MAKEFILE_CONFIG['CC'] !~ /clang/
5
6
  $CFLAGS << ' -std=c99 -Wno-declaration-after-statement -Wno-strict-aliasing'
6
7
  end
8
+ $CFLAGS << " -I #{File.expand_path(__dir__ + '/pack').shellescape}"
7
9
 
8
10
  create_makefile 'zscan'
9
11
 
10
12
  makefile = File.read 'Makefile'
11
13
 
12
- if RUBY_VERSION >= '2.6'
14
+ if RUBY_VERSION >= '2.7'
15
+ FileUtils.cp "pack/internal-27.h", "pack/internal.h"
16
+ FileUtils.cp "pack/builtin-27.h", "pack/builtin.h"
17
+ FileUtils.cp "pack/pack-27.c", "pack/pack.c"
18
+ FileUtils.rm_rf "pack/internal"
19
+ FileUtils.cp_r "pack/internal-27", "pack/internal"
20
+ elsif RUBY_VERSION >= '2.6'
13
21
  FileUtils.cp "pack/internal-26.h", "pack/internal.h"
14
22
  FileUtils.cp "pack/pack-26.c", "pack/pack.c"
15
23
  elsif RUBY_VERSION > '2.4'
@@ -0,0 +1,79 @@
1
+ #ifndef BUILTIN_H_INCLUDED
2
+ #define BUILTIN_H_INCLUDED
3
+
4
+ // invoke
5
+
6
+ struct rb_builtin_function {
7
+ // for invocation
8
+ const void * const func_ptr;
9
+ const int argc;
10
+
11
+ // for load
12
+ const int index;
13
+ const char * const name;
14
+ };
15
+
16
+ #define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity) { \
17
+ .name = #_name, \
18
+ .func_ptr = (void *)_fname, \
19
+ .argc = _arity, \
20
+ .index = _i \
21
+ }
22
+
23
+ void rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table);
24
+
25
+ #ifndef rb_execution_context_t
26
+ typedef struct rb_execution_context_struct rb_execution_context_t;
27
+ #define rb_execution_context_t rb_execution_context_t
28
+ #endif
29
+
30
+ /* The following code is generated by the following Ruby script:
31
+
32
+ 16.times{|i|
33
+ args = (i > 0 ? ', ' : '') + (0...i).map{"VALUE"}.join(', ')
34
+ puts "static inline void rb_builtin_function_check_arity#{i}(VALUE (*f)(rb_execution_context_t *ec, VALUE self#{args})){}"
35
+ }
36
+ */
37
+
38
+ static inline void rb_builtin_function_check_arity0(VALUE (*f)(rb_execution_context_t *ec, VALUE self)){}
39
+ static inline void rb_builtin_function_check_arity1(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE)){}
40
+ static inline void rb_builtin_function_check_arity2(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE)){}
41
+ static inline void rb_builtin_function_check_arity3(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE)){}
42
+ static inline void rb_builtin_function_check_arity4(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE)){}
43
+ static inline void rb_builtin_function_check_arity5(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE)){}
44
+ static inline void rb_builtin_function_check_arity6(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
45
+ static inline void rb_builtin_function_check_arity7(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
46
+ static inline void rb_builtin_function_check_arity8(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
47
+ static inline void rb_builtin_function_check_arity9(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
48
+ static inline void rb_builtin_function_check_arity10(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
49
+ static inline void rb_builtin_function_check_arity11(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
50
+ static inline void rb_builtin_function_check_arity12(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
51
+ static inline void rb_builtin_function_check_arity13(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
52
+ static inline void rb_builtin_function_check_arity14(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
53
+ static inline void rb_builtin_function_check_arity15(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
54
+
55
+ VALUE rb_vm_lvar_exposed(rb_execution_context_t *ec, int index);
56
+
57
+ // __builtin_inline!
58
+
59
+ PUREFUNC(static inline VALUE rb_vm_lvar(rb_execution_context_t *ec, int index));
60
+
61
+ static inline VALUE
62
+ rb_vm_lvar(rb_execution_context_t *ec, int index)
63
+ {
64
+ #if VM_CORE_H_EC_DEFINED
65
+ return ec->cfp->ep[index];
66
+ #else
67
+ return rb_vm_lvar_exposed(ec, index);
68
+ #endif
69
+ }
70
+
71
+ // dump/load
72
+
73
+ struct builtin_binary {
74
+ const char *feature; // feature name
75
+ const unsigned char *bin; // binary by ISeq#to_binary
76
+ size_t bin_size;
77
+ };
78
+
79
+ #endif // BUILTIN_H_INCLUDED
@@ -0,0 +1,79 @@
1
+ #ifndef BUILTIN_H_INCLUDED
2
+ #define BUILTIN_H_INCLUDED
3
+
4
+ // invoke
5
+
6
+ struct rb_builtin_function {
7
+ // for invocation
8
+ const void * const func_ptr;
9
+ const int argc;
10
+
11
+ // for load
12
+ const int index;
13
+ const char * const name;
14
+ };
15
+
16
+ #define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity) { \
17
+ .name = #_name, \
18
+ .func_ptr = (void *)_fname, \
19
+ .argc = _arity, \
20
+ .index = _i \
21
+ }
22
+
23
+ void rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table);
24
+
25
+ #ifndef rb_execution_context_t
26
+ typedef struct rb_execution_context_struct rb_execution_context_t;
27
+ #define rb_execution_context_t rb_execution_context_t
28
+ #endif
29
+
30
+ /* The following code is generated by the following Ruby script:
31
+
32
+ 16.times{|i|
33
+ args = (i > 0 ? ', ' : '') + (0...i).map{"VALUE"}.join(', ')
34
+ puts "static inline void rb_builtin_function_check_arity#{i}(VALUE (*f)(rb_execution_context_t *ec, VALUE self#{args})){}"
35
+ }
36
+ */
37
+
38
+ static inline void rb_builtin_function_check_arity0(VALUE (*f)(rb_execution_context_t *ec, VALUE self)){}
39
+ static inline void rb_builtin_function_check_arity1(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE)){}
40
+ static inline void rb_builtin_function_check_arity2(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE)){}
41
+ static inline void rb_builtin_function_check_arity3(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE)){}
42
+ static inline void rb_builtin_function_check_arity4(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE)){}
43
+ static inline void rb_builtin_function_check_arity5(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE)){}
44
+ static inline void rb_builtin_function_check_arity6(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
45
+ static inline void rb_builtin_function_check_arity7(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
46
+ static inline void rb_builtin_function_check_arity8(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
47
+ static inline void rb_builtin_function_check_arity9(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
48
+ static inline void rb_builtin_function_check_arity10(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
49
+ static inline void rb_builtin_function_check_arity11(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
50
+ static inline void rb_builtin_function_check_arity12(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
51
+ static inline void rb_builtin_function_check_arity13(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
52
+ static inline void rb_builtin_function_check_arity14(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
53
+ static inline void rb_builtin_function_check_arity15(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
54
+
55
+ VALUE rb_vm_lvar_exposed(rb_execution_context_t *ec, int index);
56
+
57
+ // __builtin_inline!
58
+
59
+ PUREFUNC(static inline VALUE rb_vm_lvar(rb_execution_context_t *ec, int index));
60
+
61
+ static inline VALUE
62
+ rb_vm_lvar(rb_execution_context_t *ec, int index)
63
+ {
64
+ #if VM_CORE_H_EC_DEFINED
65
+ return ec->cfp->ep[index];
66
+ #else
67
+ return rb_vm_lvar_exposed(ec, index);
68
+ #endif
69
+ }
70
+
71
+ // dump/load
72
+
73
+ struct builtin_binary {
74
+ const char *feature; // feature name
75
+ const unsigned char *bin; // binary by ISeq#to_binary
76
+ size_t bin_size;
77
+ };
78
+
79
+ #endif // BUILTIN_H_INCLUDED
@@ -0,0 +1,96 @@
1
+ #ifndef RUBY_INTERNAL_H /*-*-C-*-vi:se ft=c:*/
2
+ #define RUBY_INTERNAL_H 1
3
+ /**
4
+ * @file
5
+ * @author $Author$
6
+ * @date Tue May 17 11:42:20 JST 2011
7
+ * @copyright Copyright (C) 2011 Yukihiro Matsumoto
8
+ * @copyright This file is a part of the programming language Ruby.
9
+ * Permission is hereby granted, to either redistribute and/or
10
+ * modify this file, provided that the conditions mentioned in the
11
+ * file COPYING are met. Consult the file for details.
12
+ */
13
+ #include "ruby/internal/config.h"
14
+
15
+ #ifdef __cplusplus
16
+ # error not for C++
17
+ #endif
18
+
19
+ #define LIKELY(x) RB_LIKELY(x)
20
+ #define UNLIKELY(x) RB_UNLIKELY(x)
21
+
22
+ #define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
23
+ #define roomof(x, y) (((x) + (y) - 1) / (y))
24
+ #define type_roomof(x, y) roomof(sizeof(x), sizeof(y))
25
+
26
+ /* Prevent compiler from reordering access */
27
+ #define ACCESS_ONCE(type,x) (*((volatile type *)&(x)))
28
+
29
+ #include "ruby/ruby.h"
30
+
31
+ /* Following macros were formerly defined in this header but moved to somewhere
32
+ * else. In order to detect them we undef here. */
33
+
34
+ /* internal/class.h */
35
+ #undef RClass
36
+ #undef RCLASS_SUPER
37
+
38
+ /* internal/gc.h */
39
+ #undef NEWOBJ_OF
40
+ #undef RB_NEWOBJ_OF
41
+ #undef RB_OBJ_WRITE
42
+
43
+ /* internal/hash.h */
44
+ #undef RHASH_IFNONE
45
+ #undef RHASH_SIZE
46
+
47
+ /* internal/struct.h */
48
+ #undef RSTRUCT_LEN
49
+ #undef RSTRUCT_PTR
50
+ #undef RSTRUCT_SET
51
+ #undef RSTRUCT_GET
52
+
53
+ /* Also, we keep the following macros here. They are expected to be
54
+ * overridden in each headers. */
55
+
56
+ /* internal/array.h */
57
+ #define rb_ary_new_from_args(...) rb_nonexistent_symbol(__VA_ARGS__)
58
+
59
+ /* internal/io.h */
60
+ #define rb_io_fptr_finalize(...) rb_nonexistent_symbol(__VA_ARGS__)
61
+
62
+ /* internal/string.h */
63
+ #define rb_fstring_cstr(...) rb_nonexistent_symbol(__VA_ARGS__)
64
+
65
+ /* internal/symbol.h */
66
+ #define rb_sym_intern_ascii_cstr(...) rb_nonexistent_symbol(__VA_ARGS__)
67
+
68
+ /* internal/vm.h */
69
+ #define rb_funcallv(...) rb_nonexistent_symbol(__VA_ARGS__)
70
+ #define rb_method_basic_definition_p(...) rb_nonexistent_symbol(__VA_ARGS__)
71
+
72
+
73
+ /* MRI debug support */
74
+
75
+ /* gc.c */
76
+ void rb_obj_info_dump(VALUE obj);
77
+ void rb_obj_info_dump_loc(VALUE obj, const char *file, int line, const char *func);
78
+
79
+ /* debug.c */
80
+ void ruby_debug_breakpoint(void);
81
+ PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
82
+
83
+ // show obj data structure without any side-effect
84
+ #define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
85
+
86
+ // same as rp, but add message header
87
+ #define rp_m(msg, obj) do { \
88
+ fprintf(stderr, "%s", (msg)); \
89
+ rb_obj_info_dump((VALUE)obj); \
90
+ } while (0)
91
+
92
+ // `ruby_debug_breakpoint()` does nothing,
93
+ // but breakpoint is set in run.gdb, so `make gdb` can stop here.
94
+ #define bp() ruby_debug_breakpoint()
95
+
96
+ #endif /* RUBY_INTERNAL_H */
@@ -0,0 +1,103 @@
1
+ #ifndef INTERNAL_ARRAY_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_ARRAY_H
3
+ /**
4
+ * @file
5
+ * @author Ruby developers <ruby-core@ruby-lang.org>
6
+ * @copyright This file is a part of the programming language Ruby.
7
+ * Permission is hereby granted, to either redistribute and/or
8
+ * modify this file, provided that the conditions mentioned in the
9
+ * file COPYING are met. Consult the file for details.
10
+ * @brief Internal header for Array.
11
+ */
12
+ #include "ruby/internal/config.h"
13
+ #include <stddef.h> /* for size_t */
14
+ #include "internal/static_assert.h" /* for STATIC_ASSERT */
15
+ #include "ruby/internal/stdbool.h" /* for bool */
16
+ #include "ruby/ruby.h" /* for RARRAY_LEN */
17
+
18
+ #ifndef ARRAY_DEBUG
19
+ # define ARRAY_DEBUG (0+RUBY_DEBUG)
20
+ #endif
21
+
22
+ #define RARRAY_PTR_IN_USE_FLAG FL_USER14
23
+
24
+ /* array.c */
25
+ VALUE rb_ary_last(int, const VALUE *, VALUE);
26
+ void rb_ary_set_len(VALUE, long);
27
+ void rb_ary_delete_same(VALUE, VALUE);
28
+ VALUE rb_ary_tmp_new_fill(long capa);
29
+ VALUE rb_ary_at(VALUE, VALUE);
30
+ size_t rb_ary_memsize(VALUE);
31
+ VALUE rb_to_array_type(VALUE obj);
32
+ static inline VALUE rb_ary_entry_internal(VALUE ary, long offset);
33
+ static inline bool ARY_PTR_USING_P(VALUE ary);
34
+ static inline void RARY_TRANSIENT_SET(VALUE ary);
35
+ static inline void RARY_TRANSIENT_UNSET(VALUE ary);
36
+
37
+ RUBY_SYMBOL_EXPORT_BEGIN
38
+ /* array.c (export) */
39
+ void rb_ary_detransient(VALUE a);
40
+ VALUE *rb_ary_ptr_use_start(VALUE ary);
41
+ void rb_ary_ptr_use_end(VALUE ary);
42
+ RUBY_SYMBOL_EXPORT_END
43
+
44
+ MJIT_SYMBOL_EXPORT_BEGIN
45
+ VALUE rb_ary_tmp_new_from_values(VALUE, long, const VALUE *);
46
+ VALUE rb_check_to_array(VALUE ary);
47
+ VALUE rb_ary_behead(VALUE, long);
48
+ VALUE rb_ary_aref1(VALUE ary, VALUE i);
49
+ MJIT_SYMBOL_EXPORT_END
50
+
51
+ static inline VALUE
52
+ rb_ary_entry_internal(VALUE ary, long offset)
53
+ {
54
+ long len = RARRAY_LEN(ary);
55
+ const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
56
+ if (len == 0) return Qnil;
57
+ if (offset < 0) {
58
+ offset += len;
59
+ if (offset < 0) return Qnil;
60
+ }
61
+ else if (len <= offset) {
62
+ return Qnil;
63
+ }
64
+ return ptr[offset];
65
+ }
66
+
67
+ static inline bool
68
+ ARY_PTR_USING_P(VALUE ary)
69
+ {
70
+ return FL_TEST_RAW(ary, RARRAY_PTR_IN_USE_FLAG);
71
+ }
72
+
73
+ static inline void
74
+ RARY_TRANSIENT_SET(VALUE ary)
75
+ {
76
+ #if USE_TRANSIENT_HEAP
77
+ FL_SET_RAW(ary, RARRAY_TRANSIENT_FLAG);
78
+ #endif
79
+ }
80
+
81
+ static inline void
82
+ RARY_TRANSIENT_UNSET(VALUE ary)
83
+ {
84
+ #if USE_TRANSIENT_HEAP
85
+ FL_UNSET_RAW(ary, RARRAY_TRANSIENT_FLAG);
86
+ #endif
87
+ }
88
+
89
+ #undef rb_ary_new_from_args
90
+ #if RBIMPL_HAS_WARNING("-Wgnu-zero-variadic-macro-arguments")
91
+ # /* Skip it; clang -pedantic doesn't like the following */
92
+ #elif defined(__GNUC__) && defined(HAVE_VA_ARGS_MACRO)
93
+ #define rb_ary_new_from_args(n, ...) \
94
+ __extension__ ({ \
95
+ const VALUE args_to_new_ary[] = {__VA_ARGS__}; \
96
+ if (__builtin_constant_p(n)) { \
97
+ STATIC_ASSERT(rb_ary_new_from_args, numberof(args_to_new_ary) == (n)); \
98
+ } \
99
+ rb_ary_new_from_values(numberof(args_to_new_ary), args_to_new_ary); \
100
+ })
101
+ #endif
102
+
103
+ #endif /* INTERNAL_ARRAY_H */
@@ -0,0 +1,246 @@
1
+ #ifndef INTERNAL_BIGNUM_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_BIGNUM_H
3
+ /**
4
+ * @file
5
+ * @author Ruby developers <ruby-core@ruby-lang.org>
6
+ * @copyright This file is a part of the programming language Ruby.
7
+ * Permission is hereby granted, to either redistribute and/or
8
+ * modify this file, provided that the conditions mentioned in the
9
+ * file COPYING are met. Consult the file for details.
10
+ * @brief Internal header for Bignums.
11
+ */
12
+ #include "ruby/internal/config.h" /* for HAVE_LIBGMP */
13
+ #include <stddef.h> /* for size_t */
14
+
15
+ #ifdef HAVE_SYS_TYPES_H
16
+ # include <sys/types.h> /* for ssize_t (note: on Windows ssize_t is */
17
+ #endif /* `#define`d in ruby/config.h) */
18
+
19
+ #include "ruby/internal/stdbool.h" /* for bool */
20
+ #include "ruby/ruby.h" /* for struct RBasic */
21
+
22
+ #ifndef BDIGIT
23
+ # if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
24
+ # define BDIGIT unsigned int
25
+ # define SIZEOF_BDIGIT SIZEOF_INT
26
+ # define BDIGIT_DBL unsigned LONG_LONG
27
+ # define BDIGIT_DBL_SIGNED LONG_LONG
28
+ # define PRI_BDIGIT_PREFIX ""
29
+ # define PRI_BDIGIT_DBL_PREFIX PRI_LL_PREFIX
30
+ # elif SIZEOF_INT*2 <= SIZEOF_LONG
31
+ # define BDIGIT unsigned int
32
+ # define SIZEOF_BDIGIT SIZEOF_INT
33
+ # define BDIGIT_DBL unsigned long
34
+ # define BDIGIT_DBL_SIGNED long
35
+ # define PRI_BDIGIT_PREFIX ""
36
+ # define PRI_BDIGIT_DBL_PREFIX "l"
37
+ # elif SIZEOF_SHORT*2 <= SIZEOF_LONG
38
+ # define BDIGIT unsigned short
39
+ # define SIZEOF_BDIGIT SIZEOF_SHORT
40
+ # define BDIGIT_DBL unsigned long
41
+ # define BDIGIT_DBL_SIGNED long
42
+ # define PRI_BDIGIT_PREFIX "h"
43
+ # define PRI_BDIGIT_DBL_PREFIX "l"
44
+ # else
45
+ # define BDIGIT unsigned short
46
+ # define SIZEOF_BDIGIT (SIZEOF_LONG/2)
47
+ # define SIZEOF_ACTUAL_BDIGIT SIZEOF_LONG
48
+ # define BDIGIT_DBL unsigned long
49
+ # define BDIGIT_DBL_SIGNED long
50
+ # define PRI_BDIGIT_PREFIX "h"
51
+ # define PRI_BDIGIT_DBL_PREFIX "l"
52
+ # endif
53
+ #endif
54
+
55
+ #ifndef SIZEOF_ACTUAL_BDIGIT
56
+ # define SIZEOF_ACTUAL_BDIGIT SIZEOF_BDIGIT
57
+ #endif
58
+
59
+ #ifdef PRI_BDIGIT_PREFIX
60
+ # define PRIdBDIGIT PRI_BDIGIT_PREFIX"d"
61
+ # define PRIiBDIGIT PRI_BDIGIT_PREFIX"i"
62
+ # define PRIoBDIGIT PRI_BDIGIT_PREFIX"o"
63
+ # define PRIuBDIGIT PRI_BDIGIT_PREFIX"u"
64
+ # define PRIxBDIGIT PRI_BDIGIT_PREFIX"x"
65
+ # define PRIXBDIGIT PRI_BDIGIT_PREFIX"X"
66
+ #endif
67
+
68
+ #ifdef PRI_BDIGIT_DBL_PREFIX
69
+ # define PRIdBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"d"
70
+ # define PRIiBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"i"
71
+ # define PRIoBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"o"
72
+ # define PRIuBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"u"
73
+ # define PRIxBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"x"
74
+ # define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X"
75
+ #endif
76
+
77
+ #define RBIGNUM(obj) (R_CAST(RBignum)(obj))
78
+ #define BIGNUM_SIGN_BIT FL_USER1
79
+ #define BIGNUM_EMBED_FLAG ((VALUE)FL_USER2)
80
+ #define BIGNUM_EMBED_LEN_NUMBITS 3
81
+ #define BIGNUM_EMBED_LEN_MASK \
82
+ (~(~(VALUE)0U << BIGNUM_EMBED_LEN_NUMBITS) << BIGNUM_EMBED_LEN_SHIFT)
83
+ #define BIGNUM_EMBED_LEN_SHIFT \
84
+ (FL_USHIFT+3) /* bit offset of BIGNUM_EMBED_LEN_MASK */
85
+ #ifndef BIGNUM_EMBED_LEN_MAX
86
+ # if (SIZEOF_VALUE*RVALUE_EMBED_LEN_MAX/SIZEOF_ACTUAL_BDIGIT) < (1 << BIGNUM_EMBED_LEN_NUMBITS)-1
87
+ # define BIGNUM_EMBED_LEN_MAX (SIZEOF_VALUE*RVALUE_EMBED_LEN_MAX/SIZEOF_ACTUAL_BDIGIT)
88
+ # else
89
+ # define BIGNUM_EMBED_LEN_MAX ((1 << BIGNUM_EMBED_LEN_NUMBITS)-1)
90
+ # endif
91
+ #endif
92
+
93
+ enum rb_int_parse_flags {
94
+ RB_INT_PARSE_SIGN = 0x01,
95
+ RB_INT_PARSE_UNDERSCORE = 0x02,
96
+ RB_INT_PARSE_PREFIX = 0x04,
97
+ RB_INT_PARSE_ALL = 0x07,
98
+ RB_INT_PARSE_DEFAULT = 0x07,
99
+ };
100
+
101
+ struct RBignum {
102
+ struct RBasic basic;
103
+ union {
104
+ struct {
105
+ size_t len;
106
+ BDIGIT *digits;
107
+ } heap;
108
+ BDIGIT ary[BIGNUM_EMBED_LEN_MAX];
109
+ } as;
110
+ };
111
+
112
+ /* bignum.c */
113
+ extern const char ruby_digitmap[];
114
+ double rb_big_fdiv_double(VALUE x, VALUE y);
115
+ VALUE rb_big_uminus(VALUE x);
116
+ VALUE rb_big_hash(VALUE);
117
+ VALUE rb_big_odd_p(VALUE);
118
+ VALUE rb_big_even_p(VALUE);
119
+ size_t rb_big_size(VALUE);
120
+ VALUE rb_integer_float_cmp(VALUE x, VALUE y);
121
+ VALUE rb_integer_float_eq(VALUE x, VALUE y);
122
+ VALUE rb_str_convert_to_inum(VALUE str, int base, int badcheck, int raise_exception);
123
+ VALUE rb_big_comp(VALUE x);
124
+ VALUE rb_big_aref(VALUE x, VALUE y);
125
+ VALUE rb_big_abs(VALUE x);
126
+ VALUE rb_big_size_m(VALUE big);
127
+ VALUE rb_big_bit_length(VALUE big);
128
+ VALUE rb_big_remainder(VALUE x, VALUE y);
129
+ VALUE rb_big_gt(VALUE x, VALUE y);
130
+ VALUE rb_big_ge(VALUE x, VALUE y);
131
+ VALUE rb_big_lt(VALUE x, VALUE y);
132
+ VALUE rb_big_le(VALUE x, VALUE y);
133
+ VALUE rb_int_powm(int const argc, VALUE * const argv, VALUE const num);
134
+ static inline bool BIGNUM_SIGN(VALUE b);
135
+ static inline bool BIGNUM_POSITIVE_P(VALUE b);
136
+ static inline bool BIGNUM_NEGATIVE_P(VALUE b);
137
+ static inline void BIGNUM_SET_SIGN(VALUE b, bool sign);
138
+ static inline void BIGNUM_NEGATE(VALUE b);
139
+ static inline size_t BIGNUM_LEN(VALUE b);
140
+ static inline BDIGIT *BIGNUM_DIGITS(VALUE b);
141
+ static inline int BIGNUM_LENINT(VALUE b);
142
+ static inline bool BIGNUM_EMBED_P(VALUE b);
143
+
144
+ RUBY_SYMBOL_EXPORT_BEGIN
145
+ /* bignum.c (export) */
146
+ VALUE rb_big_mul_normal(VALUE x, VALUE y);
147
+ VALUE rb_big_mul_balance(VALUE x, VALUE y);
148
+ VALUE rb_big_mul_karatsuba(VALUE x, VALUE y);
149
+ VALUE rb_big_mul_toom3(VALUE x, VALUE y);
150
+ VALUE rb_big_sq_fast(VALUE x);
151
+ VALUE rb_big_divrem_normal(VALUE x, VALUE y);
152
+ VALUE rb_big2str_poweroftwo(VALUE x, int base);
153
+ VALUE rb_big2str_generic(VALUE x, int base);
154
+ VALUE rb_str2big_poweroftwo(VALUE arg, int base, int badcheck);
155
+ VALUE rb_str2big_normal(VALUE arg, int base, int badcheck);
156
+ VALUE rb_str2big_karatsuba(VALUE arg, int base, int badcheck);
157
+ #if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
158
+ VALUE rb_big_mul_gmp(VALUE x, VALUE y);
159
+ VALUE rb_big_divrem_gmp(VALUE x, VALUE y);
160
+ VALUE rb_big2str_gmp(VALUE x, int base);
161
+ VALUE rb_str2big_gmp(VALUE arg, int base, int badcheck);
162
+ #endif
163
+ VALUE rb_int_parse_cstr(const char *str, ssize_t len, char **endp, size_t *ndigits, int base, int flags);
164
+ RUBY_SYMBOL_EXPORT_END
165
+
166
+ MJIT_SYMBOL_EXPORT_BEGIN
167
+ #if defined(HAVE_INT128_T)
168
+ VALUE rb_int128t2big(int128_t n);
169
+ #endif
170
+ MJIT_SYMBOL_EXPORT_END
171
+
172
+ /* sign: positive:1, negative:0 */
173
+ static inline bool
174
+ BIGNUM_SIGN(VALUE b)
175
+ {
176
+ return FL_TEST_RAW(b, BIGNUM_SIGN_BIT);
177
+ }
178
+
179
+ static inline bool
180
+ BIGNUM_POSITIVE_P(VALUE b)
181
+ {
182
+ return BIGNUM_SIGN(b);
183
+ }
184
+
185
+ static inline bool
186
+ BIGNUM_NEGATIVE_P(VALUE b)
187
+ {
188
+ return ! BIGNUM_POSITIVE_P(b);
189
+ }
190
+
191
+ static inline void
192
+ BIGNUM_SET_SIGN(VALUE b, bool sign)
193
+ {
194
+ if (sign) {
195
+ FL_SET_RAW(b, BIGNUM_SIGN_BIT);
196
+ }
197
+ else {
198
+ FL_UNSET_RAW(b, BIGNUM_SIGN_BIT);
199
+ }
200
+ }
201
+
202
+ static inline void
203
+ BIGNUM_NEGATE(VALUE b)
204
+ {
205
+ FL_REVERSE_RAW(b, BIGNUM_SIGN_BIT);
206
+ }
207
+
208
+ static inline size_t
209
+ BIGNUM_LEN(VALUE b)
210
+ {
211
+ if (! BIGNUM_EMBED_P(b)) {
212
+ return RBIGNUM(b)->as.heap.len;
213
+ }
214
+ else {
215
+ size_t ret = RBASIC(b)->flags;
216
+ ret &= BIGNUM_EMBED_LEN_MASK;
217
+ ret >>= BIGNUM_EMBED_LEN_SHIFT;
218
+ return ret;
219
+ }
220
+ }
221
+
222
+ static inline int
223
+ BIGNUM_LENINT(VALUE b)
224
+ {
225
+ return rb_long2int(BIGNUM_LEN(b));
226
+ }
227
+
228
+ /* LSB:BIGNUM_DIGITS(b)[0], MSB:BIGNUM_DIGITS(b)[BIGNUM_LEN(b)-1] */
229
+ static inline BDIGIT *
230
+ BIGNUM_DIGITS(VALUE b)
231
+ {
232
+ if (BIGNUM_EMBED_P(b)) {
233
+ return RBIGNUM(b)->as.ary;
234
+ }
235
+ else {
236
+ return RBIGNUM(b)->as.heap.digits;
237
+ }
238
+ }
239
+
240
+ static inline bool
241
+ BIGNUM_EMBED_P(VALUE b)
242
+ {
243
+ return FL_TEST_RAW(b, BIGNUM_EMBED_FLAG);
244
+ }
245
+
246
+ #endif /* INTERNAL_BIGNUM_H */