zscan 2.0.6 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,60 @@
1
+ #ifndef INTERNAL_OBJECT_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_OBJECT_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 Object.
11
+ */
12
+ #include "ruby/ruby.h" /* for VALUE */
13
+
14
+ /* object.c */
15
+ VALUE rb_class_search_ancestor(VALUE klass, VALUE super);
16
+ NORETURN(void rb_undefined_alloc(VALUE klass));
17
+ double rb_num_to_dbl(VALUE val);
18
+ VALUE rb_obj_dig(int argc, VALUE *argv, VALUE self, VALUE notfound);
19
+ VALUE rb_immutable_obj_clone(int, VALUE *, VALUE);
20
+ VALUE rb_check_convert_type_with_id(VALUE,int,const char*,ID);
21
+ int rb_bool_expected(VALUE, const char *);
22
+ static inline void RBASIC_CLEAR_CLASS(VALUE obj);
23
+ static inline void RBASIC_SET_CLASS_RAW(VALUE obj, VALUE klass);
24
+ static inline void RBASIC_SET_CLASS(VALUE obj, VALUE klass);
25
+
26
+ RUBY_SYMBOL_EXPORT_BEGIN
27
+ /* object.c (export) */
28
+ int rb_opts_exception_p(VALUE opts, int default_value);
29
+ RUBY_SYMBOL_EXPORT_END
30
+
31
+ MJIT_SYMBOL_EXPORT_BEGIN
32
+ CONSTFUNC(VALUE rb_obj_equal(VALUE obj1, VALUE obj2));
33
+ CONSTFUNC(VALUE rb_obj_not(VALUE obj));
34
+ VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2);
35
+ void rb_obj_copy_ivar(VALUE dest, VALUE obj);
36
+ VALUE rb_false(VALUE obj);
37
+ VALUE rb_convert_type_with_id(VALUE v, int t, const char* nam, ID mid);
38
+ MJIT_SYMBOL_EXPORT_END
39
+
40
+ static inline void
41
+ RBASIC_SET_CLASS_RAW(VALUE obj, VALUE klass)
42
+ {
43
+ struct { VALUE flags; VALUE klass; } *ptr = (void *)obj;
44
+ ptr->klass = klass;
45
+ }
46
+
47
+ static inline void
48
+ RBASIC_CLEAR_CLASS(VALUE obj)
49
+ {
50
+ RBASIC_SET_CLASS_RAW(obj, 0);
51
+ }
52
+
53
+ static inline void
54
+ RBASIC_SET_CLASS(VALUE obj, VALUE klass)
55
+ {
56
+ VALUE oldv = RBASIC_CLASS(obj);
57
+ RBASIC_SET_CLASS_RAW(obj, klass);
58
+ RB_OBJ_WRITTEN(obj, oldv, klass);
59
+ }
60
+ #endif /* INTERNAL_OBJECT_H */
@@ -0,0 +1,23 @@
1
+ #ifndef INTERNAL_PARSE_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_PARSE_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 the parser.
11
+ */
12
+ #include "ruby/ruby.h" /* for VALUE */
13
+ struct rb_iseq_struct; /* in vm_core.h */
14
+
15
+ /* parse.y */
16
+ VALUE rb_parser_set_yydebug(VALUE, VALUE);
17
+ void *rb_parser_load_file(VALUE parser, VALUE name);
18
+
19
+ RUBY_SYMBOL_EXPORT_BEGIN
20
+ VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
21
+ RUBY_SYMBOL_EXPORT_END
22
+
23
+ #endif /* INTERNAL_PARSE_H */
@@ -0,0 +1,32 @@
1
+ #ifndef INTERNAL_PROC_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_PROC_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 Proc.
11
+ */
12
+ #include "ruby/ruby.h" /* for rb_block_call_func_t */
13
+ #include "ruby/st.h" /* for st_index_t */
14
+ struct rb_block; /* in vm_core.h */
15
+ struct rb_iseq_struct; /* in vm_core.h */
16
+
17
+ /* proc.c */
18
+ VALUE rb_proc_location(VALUE self);
19
+ st_index_t rb_hash_proc(st_index_t hash, VALUE proc);
20
+ int rb_block_pair_yield_optimizable(void);
21
+ int rb_block_arity(void);
22
+ int rb_block_min_max_arity(int *max);
23
+ VALUE rb_block_to_s(VALUE self, const struct rb_block *block, const char *additional_info);
24
+
25
+ MJIT_SYMBOL_EXPORT_BEGIN
26
+ VALUE rb_func_proc_new(rb_block_call_func_t func, VALUE val);
27
+ VALUE rb_func_lambda_new(rb_block_call_func_t func, VALUE val, int min_argc, int max_argc);
28
+ VALUE rb_iseq_location(const struct rb_iseq_struct *iseq);
29
+ VALUE rb_sym_to_proc(VALUE sym);
30
+ MJIT_SYMBOL_EXPORT_END
31
+
32
+ #endif /* INTERNAL_PROC_H */
@@ -0,0 +1,130 @@
1
+ #ifndef INTERNAL_PROCESS_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_PROCESS_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 Process.
11
+ */
12
+ #include "ruby/internal/config.h" /* for rb_pid_t */
13
+ #include <stddef.h> /* for size_t */
14
+
15
+ #ifdef HAVE_SYS_TYPES_H
16
+ # include <sys/types.h> /* for mode_t */
17
+ #endif
18
+
19
+ #ifdef _WIN32
20
+ # include "ruby/win32.h" /* for mode_t */
21
+ #endif
22
+
23
+ #include "ruby/ruby.h" /* for VALUE */
24
+ #include "internal/imemo.h" /* for RB_IMEMO_TMPBUF_PTR */
25
+ #include "internal/warnings.h" /* for COMPILER_WARNING_PUSH */
26
+
27
+ #define RB_MAX_GROUPS (65536)
28
+
29
+ struct waitpid_state;
30
+ struct rb_execarg {
31
+ union {
32
+ struct {
33
+ VALUE shell_script;
34
+ } sh;
35
+ struct {
36
+ VALUE command_name;
37
+ VALUE command_abspath; /* full path string or nil */
38
+ VALUE argv_str;
39
+ VALUE argv_buf;
40
+ } cmd;
41
+ } invoke;
42
+ VALUE redirect_fds;
43
+ VALUE envp_str;
44
+ VALUE envp_buf;
45
+ VALUE dup2_tmpbuf;
46
+ unsigned use_shell : 1;
47
+ unsigned pgroup_given : 1;
48
+ unsigned umask_given : 1;
49
+ unsigned unsetenv_others_given : 1;
50
+ unsigned unsetenv_others_do : 1;
51
+ unsigned close_others_given : 1;
52
+ unsigned close_others_do : 1;
53
+ unsigned chdir_given : 1;
54
+ unsigned new_pgroup_given : 1;
55
+ unsigned new_pgroup_flag : 1;
56
+ unsigned uid_given : 1;
57
+ unsigned gid_given : 1;
58
+ unsigned exception : 1;
59
+ unsigned exception_given : 1;
60
+ struct waitpid_state *waitpid_state; /* for async process management */
61
+ rb_pid_t pgroup_pgid; /* asis(-1), new pgroup(0), specified pgroup (0<V). */
62
+ VALUE rlimit_limits; /* Qfalse or [[rtype, softlim, hardlim], ...] */
63
+ mode_t umask_mask;
64
+ rb_uid_t uid;
65
+ rb_gid_t gid;
66
+ int close_others_maxhint;
67
+ VALUE fd_dup2;
68
+ VALUE fd_close;
69
+ VALUE fd_open;
70
+ VALUE fd_dup2_child;
71
+ VALUE env_modification; /* Qfalse or [[k1,v1], ...] */
72
+ VALUE path_env;
73
+ VALUE chdir_dir;
74
+ };
75
+
76
+ /* process.c */
77
+ rb_pid_t rb_fork_ruby(int *status);
78
+ void rb_last_status_clear(void);
79
+ static inline char **ARGVSTR2ARGV(VALUE argv_str);
80
+ static inline size_t ARGVSTR2ARGC(VALUE argv_str);
81
+
82
+ RUBY_SYMBOL_EXPORT_BEGIN
83
+ /* process.c (export) */
84
+ int rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen);
85
+ 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);
86
+ VALUE rb_execarg_new(int argc, const VALUE *argv, int accept_shell, int allow_exc_opt);
87
+ struct rb_execarg *rb_execarg_get(VALUE execarg_obj); /* dangerous. needs GC guard. */
88
+ int rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val);
89
+ void rb_execarg_parent_start(VALUE execarg_obj);
90
+ void rb_execarg_parent_end(VALUE execarg_obj);
91
+ int rb_execarg_run_options(const struct rb_execarg *e, struct rb_execarg *s, char* errmsg, size_t errmsg_buflen);
92
+ VALUE rb_execarg_extract_options(VALUE execarg_obj, VALUE opthash);
93
+ void rb_execarg_setenv(VALUE execarg_obj, VALUE env);
94
+ RUBY_SYMBOL_EXPORT_END
95
+
96
+ /* argv_str contains extra two elements.
97
+ * The beginning one is for /bin/sh used by exec_with_sh.
98
+ * The last one for terminating NULL used by execve.
99
+ * See rb_exec_fillarg() in process.c. */
100
+ static inline char **
101
+ ARGVSTR2ARGV(VALUE argv_str)
102
+ {
103
+ char **buf = RB_IMEMO_TMPBUF_PTR(argv_str);
104
+ return &buf[1];
105
+ }
106
+
107
+ static inline size_t
108
+ ARGVSTR2ARGC(VALUE argv_str)
109
+ {
110
+ size_t i = 0;
111
+ char *const *p = ARGVSTR2ARGV(argv_str);
112
+ while (p[i++])
113
+ ;
114
+ return i - 1;
115
+ }
116
+
117
+ #ifdef HAVE_WORKING_FORK
118
+ COMPILER_WARNING_PUSH
119
+ #if __has_warning("-Wdeprecated-declarations") || RBIMPL_COMPILER_IS(GCC)
120
+ COMPILER_WARNING_IGNORED(-Wdeprecated-declarations)
121
+ #endif
122
+ static inline rb_pid_t
123
+ rb_fork(void)
124
+ {
125
+ return fork();
126
+ }
127
+ COMPILER_WARNING_POP
128
+ #endif
129
+
130
+ #endif /* INTERNAL_PROCESS_H */
@@ -0,0 +1,17 @@
1
+ #ifndef INTERNAL_RANDOM_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_RANDOM_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 Random.
11
+ */
12
+ #include <stddef.h> /* for size_t */
13
+
14
+ /* random.c */
15
+ int ruby_fill_random_bytes(void *, size_t, int);
16
+
17
+ #endif /* INTERNAL_RANDOM_H */
@@ -0,0 +1,37 @@
1
+ #ifndef INTERNAL_RANGE_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_RANGE_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 Range.
11
+ */
12
+ #include "internal/struct.h" /* for RSTRUCT */
13
+
14
+ /* range.c */
15
+ static inline VALUE RANGE_BEG(VALUE r);
16
+ static inline VALUE RANGE_END(VALUE r);
17
+ static inline VALUE RANGE_EXCL(VALUE r);
18
+
19
+ static inline VALUE
20
+ RANGE_BEG(VALUE r)
21
+ {
22
+ return RSTRUCT(r)->as.ary[0];
23
+ }
24
+
25
+ static inline VALUE
26
+ RANGE_END(VALUE r)
27
+ {
28
+ return RSTRUCT(r)->as.ary[1];
29
+ }
30
+
31
+ static inline VALUE
32
+ RANGE_EXCL(VALUE r)
33
+ {
34
+ return RSTRUCT(r)->as.ary[2];
35
+ }
36
+
37
+ #endif /* INTERNAL_RANGE_H */
@@ -0,0 +1,68 @@
1
+ #ifndef INTERNAL_RATIONAL_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_RATIONAL_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 Rational.
11
+ */
12
+ #include "ruby/internal/config.h" /* for HAVE_LIBGMP */
13
+ #include "ruby/ruby.h" /* for struct RBasic */
14
+ #include "internal/gc.h" /* for RB_OBJ_WRITE */
15
+ #include "internal/numeric.h" /* for INT_POSITIVE_P */
16
+ #include "ruby_assert.h" /* for assert */
17
+
18
+ struct RRational {
19
+ struct RBasic basic;
20
+ VALUE num;
21
+ VALUE den;
22
+ };
23
+
24
+ #define RRATIONAL(obj) (R_CAST(RRational)(obj))
25
+
26
+ /* rational.c */
27
+ VALUE rb_rational_canonicalize(VALUE x);
28
+ VALUE rb_rational_uminus(VALUE self);
29
+ VALUE rb_rational_plus(VALUE self, VALUE other);
30
+ VALUE rb_rational_mul(VALUE self, VALUE other);
31
+ VALUE rb_lcm(VALUE x, VALUE y);
32
+ VALUE rb_rational_reciprocal(VALUE x);
33
+ VALUE rb_cstr_to_rat(const char *, int);
34
+ VALUE rb_rational_abs(VALUE self);
35
+ VALUE rb_rational_cmp(VALUE self, VALUE other);
36
+ VALUE rb_rational_pow(VALUE self, VALUE other);
37
+ VALUE rb_numeric_quo(VALUE x, VALUE y);
38
+ VALUE rb_float_numerator(VALUE x);
39
+ VALUE rb_float_denominator(VALUE x);
40
+
41
+ static inline void RATIONAL_SET_NUM(VALUE r, VALUE n);
42
+ static inline void RATIONAL_SET_DEN(VALUE r, VALUE d);
43
+
44
+ RUBY_SYMBOL_EXPORT_BEGIN
45
+ /* rational.c (export) */
46
+ VALUE rb_gcd(VALUE x, VALUE y);
47
+ VALUE rb_gcd_normal(VALUE self, VALUE other);
48
+ #if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
49
+ VALUE rb_gcd_gmp(VALUE x, VALUE y);
50
+ #endif
51
+ RUBY_SYMBOL_EXPORT_END
52
+
53
+ static inline void
54
+ RATIONAL_SET_NUM(VALUE r, VALUE n)
55
+ {
56
+ assert(RB_INTEGER_TYPE_P(n));
57
+ RB_OBJ_WRITE(r, &RRATIONAL(r)->num, n);
58
+ }
59
+
60
+ static inline void
61
+ RATIONAL_SET_DEN(VALUE r, VALUE d)
62
+ {
63
+ assert(RB_INTEGER_TYPE_P(d));
64
+ assert(INT_POSITIVE_P(d));
65
+ RB_OBJ_WRITE(r, &RRATIONAL(r)->den, d);
66
+ }
67
+
68
+ #endif /* INTERNAL_RATIONAL_H */
@@ -0,0 +1,29 @@
1
+ #ifndef INTERNAL_RE_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_RE_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 Regexp.
11
+ */
12
+ #include "ruby/internal/stdbool.h" /* for bool */
13
+ #include "ruby/ruby.h" /* for VALUE */
14
+
15
+ /* re.c */
16
+ VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline);
17
+ VALUE rb_reg_check_preprocess(VALUE);
18
+ long rb_reg_search0(VALUE, VALUE, long, int, int);
19
+ VALUE rb_reg_match_p(VALUE re, VALUE str, long pos);
20
+ bool rb_reg_start_with_p(VALUE re, VALUE str);
21
+ void rb_backref_set_string(VALUE string, long pos, long len);
22
+ void rb_match_unbusy(VALUE);
23
+ int rb_match_count(VALUE match);
24
+ int rb_match_nth_defined(int nth, VALUE match);
25
+ MJIT_SYMBOL_EXPORT_BEGIN
26
+ VALUE rb_reg_new_ary(VALUE ary, int options);
27
+ MJIT_SYMBOL_EXPORT_END
28
+
29
+ #endif /* INTERNAL_RE_H */
@@ -0,0 +1,191 @@
1
+ #ifndef INTERNAL_SANITIZERS_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_SANITIZERS_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 ASAN / MSAN / etc.
11
+ */
12
+ #include "ruby/internal/config.h"
13
+ #include "internal/compilers.h" /* for __has_feature */
14
+
15
+ #ifdef HAVE_VALGRIND_MEMCHECK_H
16
+ # include <valgrind/memcheck.h>
17
+ #endif
18
+
19
+ #ifdef HAVE_SANITIZER_ASAN_INTERFACE_H
20
+ # include <sanitizer/asan_interface.h>
21
+ #endif
22
+
23
+ #ifdef HAVE_SANITIZER_MSAN_INTERFACE_H
24
+ # if __has_feature(memory_sanitizer)
25
+ # include <sanitizer/msan_interface.h>
26
+ # endif
27
+ #endif
28
+
29
+ #include "ruby/internal/stdbool.h" /* for bool */
30
+ #include "ruby/ruby.h" /* for VALUE */
31
+
32
+ #if 0
33
+ #elif __has_feature(memory_sanitizer) && __has_feature(address_sanitizer)
34
+ # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
35
+ __attribute__((__no_sanitize__("memory, address"), __noinline__)) x
36
+ #elif __has_feature(address_sanitizer)
37
+ # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
38
+ __attribute__((__no_sanitize__("address"), __noinline__)) x
39
+ #elif defined(NO_SANITIZE_ADDRESS)
40
+ # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
41
+ NO_SANITIZE_ADDRESS(NOINLINE(x))
42
+ #elif defined(NO_ADDRESS_SAFETY_ANALYSIS)
43
+ # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
44
+ NO_ADDRESS_SAFETY_ANALYSIS(NOINLINE(x))
45
+ #else
46
+ # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) x
47
+ #endif
48
+
49
+ #if defined(NO_SANITIZE) && RBIMPL_COMPILER_IS(GCC)
50
+ /* GCC warns about unknown sanitizer, which is annoying. */
51
+ # include "internal/warnings.h"
52
+ # undef NO_SANITIZE
53
+ # define NO_SANITIZE(x, y) \
54
+ COMPILER_WARNING_PUSH; \
55
+ COMPILER_WARNING_IGNORED(-Wattributes); \
56
+ __attribute__((__no_sanitize__(x))) y; \
57
+ COMPILER_WARNING_POP
58
+ #endif
59
+
60
+ #ifndef NO_SANITIZE
61
+ # define NO_SANITIZE(x, y) y
62
+ #endif
63
+
64
+ #if !__has_feature(address_sanitizer)
65
+ # define __asan_poison_memory_region(x, y)
66
+ # define __asan_unpoison_memory_region(x, y)
67
+ # define __asan_region_is_poisoned(x, y) 0
68
+ #endif
69
+
70
+ #if !__has_feature(memory_sanitizer)
71
+ # define __msan_allocated_memory(x, y) ((void)(x), (void)(y))
72
+ # define __msan_poison(x, y) ((void)(x), (void)(y))
73
+ # define __msan_unpoison(x, y) ((void)(x), (void)(y))
74
+ # define __msan_unpoison_string(x) ((void)(x))
75
+ #endif
76
+
77
+ #ifdef VALGRIND_MAKE_READABLE
78
+ # define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE((p), (n))
79
+ #endif
80
+
81
+ #ifdef VALGRIND_MAKE_WRITABLE
82
+ # define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE((p), (n))
83
+ #endif
84
+
85
+ #ifndef VALGRIND_MAKE_MEM_DEFINED
86
+ # define VALGRIND_MAKE_MEM_DEFINED(p, n) 0
87
+ #endif
88
+
89
+ #ifndef VALGRIND_MAKE_MEM_UNDEFINED
90
+ # define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
91
+ #endif
92
+
93
+ #ifndef MJIT_HEADER
94
+
95
+ /*!
96
+ * This function asserts that a (continuous) memory region from ptr to size
97
+ * being "poisoned". Both read / write access to such memory region are
98
+ * prohibited until properly unpoisoned. The region must be previously
99
+ * allocated (do not pass a freed pointer here), but not necessarily be an
100
+ * entire object that the malloc returns. You can punch hole a part of a
101
+ * gigantic heap arena. This is handy when you do not free an allocated memory
102
+ * region to reuse later: poison when you keep it unused, and unpoison when you
103
+ * reuse.
104
+ *
105
+ * \param[in] ptr pointer to the beginning of the memory region to poison.
106
+ * \param[in] size the length of the memory region to poison.
107
+ */
108
+ static inline void
109
+ asan_poison_memory_region(const volatile void *ptr, size_t size)
110
+ {
111
+ __msan_poison(ptr, size);
112
+ __asan_poison_memory_region(ptr, size);
113
+ }
114
+
115
+ /*!
116
+ * This is a variant of asan_poison_memory_region that takes a VALUE.
117
+ *
118
+ * \param[in] obj target object.
119
+ */
120
+ static inline void
121
+ asan_poison_object(VALUE obj)
122
+ {
123
+ MAYBE_UNUSED(struct RVALUE *) ptr = (void *)obj;
124
+ asan_poison_memory_region(ptr, SIZEOF_VALUE);
125
+ }
126
+
127
+ #if !__has_feature(address_sanitizer)
128
+ #define asan_poison_object_if(ptr, obj) ((void)(ptr), (void)(obj))
129
+ #else
130
+ #define asan_poison_object_if(ptr, obj) do { \
131
+ if (ptr) asan_poison_object(obj); \
132
+ } while (0)
133
+ #endif
134
+
135
+ /*!
136
+ * This function predicates if the given object is fully addressable or not.
137
+ *
138
+ * \param[in] obj target object.
139
+ * \retval 0 the given object is fully addressable.
140
+ * \retval otherwise pointer to first such byte who is poisoned.
141
+ */
142
+ static inline void *
143
+ asan_poisoned_object_p(VALUE obj)
144
+ {
145
+ MAYBE_UNUSED(struct RVALUE *) ptr = (void *)obj;
146
+ return __asan_region_is_poisoned(ptr, SIZEOF_VALUE);
147
+ }
148
+
149
+ /*!
150
+ * This function asserts that a (formally poisoned) memory region from ptr to
151
+ * size is now addressable. Write access to such memory region gets allowed.
152
+ * However read access might or might not be possible depending on situations,
153
+ * because the region can have contents of previous usages. That information
154
+ * should be passed by the malloc_p flag. If that is true, the contents of the
155
+ * region is _not_ fully defined (like the return value of malloc behaves).
156
+ * Reading from there is NG; write something first. If malloc_p is false on
157
+ * the other hand, that memory region is fully defined and can be read
158
+ * immediately.
159
+ *
160
+ * \param[in] ptr pointer to the beginning of the memory region to unpoison.
161
+ * \param[in] size the length of the memory region.
162
+ * \param[in] malloc_p if the memory region is like a malloc's return value or not.
163
+ */
164
+ static inline void
165
+ asan_unpoison_memory_region(const volatile void *ptr, size_t size, bool malloc_p)
166
+ {
167
+ __asan_unpoison_memory_region(ptr, size);
168
+ if (malloc_p) {
169
+ __msan_allocated_memory(ptr, size);
170
+ }
171
+ else {
172
+ __msan_unpoison(ptr, size);
173
+ }
174
+ }
175
+
176
+ /*!
177
+ * This is a variant of asan_unpoison_memory_region that takes a VALUE.
178
+ *
179
+ * \param[in] obj target object.
180
+ * \param[in] malloc_p if the memory region is like a malloc's return value or not.
181
+ */
182
+ static inline void
183
+ asan_unpoison_object(VALUE obj, bool newobj_p)
184
+ {
185
+ MAYBE_UNUSED(struct RVALUE *) ptr = (void *)obj;
186
+ asan_unpoison_memory_region(ptr, SIZEOF_VALUE, newobj_p);
187
+ }
188
+
189
+ #endif /* MJIT_HEADER */
190
+
191
+ #endif /* INTERNAL_SANITIZERS_H */