did_you_mean 0.2.0 → 0.3.0

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/did_you_mean.gemspec +4 -0
  4. data/ext/did_you_mean/extconf.rb +7 -2
  5. data/ext/did_you_mean/ruby_headers/220/addr2line.h +21 -0
  6. data/ext/did_you_mean/ruby_headers/220/constant.h +36 -0
  7. data/ext/did_you_mean/ruby_headers/220/dln.h +51 -0
  8. data/ext/did_you_mean/ruby_headers/220/encdb.h +170 -0
  9. data/ext/did_you_mean/ruby_headers/220/eval_intern.h +256 -0
  10. data/ext/did_you_mean/ruby_headers/220/gc.h +102 -0
  11. data/ext/did_you_mean/ruby_headers/220/id.h +171 -0
  12. data/ext/did_you_mean/ruby_headers/220/internal.h +1006 -0
  13. data/ext/did_you_mean/ruby_headers/220/iseq.h +136 -0
  14. data/ext/did_you_mean/ruby_headers/220/method.h +142 -0
  15. data/ext/did_you_mean/ruby_headers/220/node.h +543 -0
  16. data/ext/did_you_mean/ruby_headers/220/parse.h +183 -0
  17. data/ext/did_you_mean/ruby_headers/220/probes.h +83 -0
  18. data/ext/did_you_mean/ruby_headers/220/probes_helper.h +67 -0
  19. data/ext/did_you_mean/ruby_headers/220/regenc.h +223 -0
  20. data/ext/did_you_mean/ruby_headers/220/regint.h +911 -0
  21. data/ext/did_you_mean/ruby_headers/220/regparse.h +363 -0
  22. data/ext/did_you_mean/ruby_headers/220/revision.h +1 -0
  23. data/ext/did_you_mean/ruby_headers/220/ruby_atomic.h +170 -0
  24. data/ext/did_you_mean/ruby_headers/220/siphash.h +48 -0
  25. data/ext/did_you_mean/ruby_headers/220/thread_native.h +23 -0
  26. data/ext/did_you_mean/ruby_headers/220/thread_pthread.h +56 -0
  27. data/ext/did_you_mean/ruby_headers/220/thread_win32.h +45 -0
  28. data/ext/did_you_mean/ruby_headers/220/timev.h +42 -0
  29. data/ext/did_you_mean/ruby_headers/220/transcode_data.h +123 -0
  30. data/ext/did_you_mean/ruby_headers/220/transdb.h +190 -0
  31. data/ext/did_you_mean/ruby_headers/220/verconf.h +13 -0
  32. data/ext/did_you_mean/ruby_headers/220/version.h +53 -0
  33. data/ext/did_you_mean/ruby_headers/220/vm_core.h +1024 -0
  34. data/ext/did_you_mean/ruby_headers/220/vm_debug.h +37 -0
  35. data/ext/did_you_mean/ruby_headers/220/vm_exec.h +182 -0
  36. data/ext/did_you_mean/ruby_headers/220/vm_insnhelper.h +273 -0
  37. data/ext/did_you_mean/ruby_headers/220/vm_opts.h +56 -0
  38. data/lib/did_you_mean/version.rb +1 -1
  39. metadata +51 -4
@@ -0,0 +1,102 @@
1
+
2
+ #ifndef RUBY_GC_H
3
+ #define RUBY_GC_H 1
4
+
5
+ #if defined(__x86_64__) && !defined(_ILP32) && defined(__GNUC__) && !defined(__native_client__)
6
+ #define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movq\t%%rsp, %0" : "=r" (*(p)))
7
+ #elif defined(__i386) && defined(__GNUC__) && !defined(__native_client__)
8
+ #define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movl\t%%esp, %0" : "=r" (*(p)))
9
+ #else
10
+ NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p));
11
+ #define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p)
12
+ #define USE_CONSERVATIVE_STACK_END
13
+ #endif
14
+
15
+ /* for GC debug */
16
+
17
+ #ifndef RUBY_MARK_FREE_DEBUG
18
+ #define RUBY_MARK_FREE_DEBUG 0
19
+ #endif
20
+
21
+ #if RUBY_MARK_FREE_DEBUG
22
+ extern int ruby_gc_debug_indent;
23
+
24
+ static inline void
25
+ rb_gc_debug_indent(void)
26
+ {
27
+ printf("%*s", ruby_gc_debug_indent, "");
28
+ }
29
+
30
+ static inline void
31
+ rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr)
32
+ {
33
+ if (st == 0) {
34
+ ruby_gc_debug_indent--;
35
+ }
36
+ rb_gc_debug_indent();
37
+ printf("%s: %s %s (%p)\n", mode, st ? "->" : "<-", msg, ptr);
38
+
39
+ if (st) {
40
+ ruby_gc_debug_indent++;
41
+ }
42
+
43
+ fflush(stdout);
44
+ }
45
+
46
+ #define RUBY_MARK_ENTER(msg) rb_gc_debug_body("mark", (msg), 1, ptr)
47
+ #define RUBY_MARK_LEAVE(msg) rb_gc_debug_body("mark", (msg), 0, ptr)
48
+ #define RUBY_FREE_ENTER(msg) rb_gc_debug_body("free", (msg), 1, ptr)
49
+ #define RUBY_FREE_LEAVE(msg) rb_gc_debug_body("free", (msg), 0, ptr)
50
+ #define RUBY_GC_INFO rb_gc_debug_indent(); printf
51
+
52
+ #else
53
+ #define RUBY_MARK_ENTER(msg)
54
+ #define RUBY_MARK_LEAVE(msg)
55
+ #define RUBY_FREE_ENTER(msg)
56
+ #define RUBY_FREE_LEAVE(msg)
57
+ #define RUBY_GC_INFO if(0)printf
58
+ #endif
59
+
60
+ #define RUBY_MARK_UNLESS_NULL(ptr) if(RTEST(ptr)){rb_gc_mark(ptr);}
61
+ #define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);(ptr)=NULL;}
62
+
63
+ #if STACK_GROW_DIRECTION > 0
64
+ # define STACK_UPPER(x, a, b) (a)
65
+ #elif STACK_GROW_DIRECTION < 0
66
+ # define STACK_UPPER(x, a, b) (b)
67
+ #else
68
+ RUBY_EXTERN int ruby_stack_grow_direction;
69
+ int ruby_get_stack_grow_direction(volatile VALUE *addr);
70
+ # define stack_growup_p(x) ( \
71
+ (ruby_stack_grow_direction ? \
72
+ ruby_stack_grow_direction : \
73
+ ruby_get_stack_grow_direction(x)) > 0)
74
+ # define STACK_UPPER(x, a, b) (stack_growup_p(x) ? (a) : (b))
75
+ #endif
76
+
77
+ #if STACK_GROW_DIRECTION
78
+ #define STACK_GROW_DIR_DETECTION
79
+ #define STACK_DIR_UPPER(a,b) STACK_UPPER(0, (a), (b))
80
+ #else
81
+ #define STACK_GROW_DIR_DETECTION VALUE stack_grow_dir_detection
82
+ #define STACK_DIR_UPPER(a,b) STACK_UPPER(&stack_grow_dir_detection, (a), (b))
83
+ #endif
84
+ #define IS_STACK_DIR_UPPER() STACK_DIR_UPPER(1,0)
85
+
86
+ RUBY_SYMBOL_EXPORT_BEGIN
87
+
88
+ /* exports for objspace module */
89
+ size_t rb_objspace_data_type_memsize(VALUE obj);
90
+ void rb_objspace_reachable_objects_from(VALUE obj, void (func)(VALUE, void *), void *data);
91
+ void rb_objspace_reachable_objects_from_root(void (func)(const char *category, VALUE, void *), void *data);
92
+ int rb_objspace_markable_object_p(VALUE obj);
93
+ int rb_objspace_internal_object_p(VALUE obj);
94
+ int rb_objspace_marked_object_p(VALUE obj);
95
+
96
+ void rb_objspace_each_objects(
97
+ int (*callback)(void *start, void *end, size_t stride, void *data),
98
+ void *data);
99
+
100
+ RUBY_SYMBOL_EXPORT_END
101
+
102
+ #endif /* RUBY_GC_H */
@@ -0,0 +1,171 @@
1
+ /* DO NOT EDIT THIS FILE DIRECTLY */
2
+ /**********************************************************************
3
+
4
+ id.h -
5
+
6
+ $Author$
7
+ created at: Sun Oct 19 21:12:51 2008
8
+
9
+ Copyright (C) 2007 Koichi Sasada
10
+
11
+ **********************************************************************/
12
+
13
+ #ifndef RUBY_ID_H
14
+ #define RUBY_ID_H
15
+
16
+ enum ruby_id_types {
17
+ RUBY_ID_LOCAL = 0x00,
18
+ RUBY_ID_INSTANCE = 0x01,
19
+ RUBY_ID_GLOBAL = 0x03,
20
+ RUBY_ID_ATTRSET = 0x04,
21
+ RUBY_ID_CONST = 0x05,
22
+ RUBY_ID_CLASS = 0x06,
23
+ RUBY_ID_JUNK = 0x07,
24
+ RUBY_ID_INTERNAL = RUBY_ID_JUNK,
25
+ RUBY_ID_SCOPE_SHIFT = 3,
26
+ RUBY_ID_SCOPE_MASK = ~(~0U<<RUBY_ID_SCOPE_SHIFT)
27
+ };
28
+
29
+ #define ID_SCOPE_SHIFT RUBY_ID_SCOPE_SHIFT
30
+ #define ID_SCOPE_MASK RUBY_ID_SCOPE_MASK
31
+ #define ID_LOCAL RUBY_ID_LOCAL
32
+ #define ID_INSTANCE RUBY_ID_INSTANCE
33
+ #define ID_GLOBAL RUBY_ID_GLOBAL
34
+ #define ID_ATTRSET RUBY_ID_ATTRSET
35
+ #define ID_CONST RUBY_ID_CONST
36
+ #define ID_CLASS RUBY_ID_CLASS
37
+ #define ID_JUNK RUBY_ID_JUNK
38
+ #define ID_INTERNAL RUBY_ID_INTERNAL
39
+
40
+ #define ID2ATTRSET(id) (((id)&~ID_SCOPE_MASK)|ID_ATTRSET)
41
+
42
+ #define symIFUNC ID2SYM(idIFUNC)
43
+ #define symCFUNC ID2SYM(idCFUNC)
44
+
45
+ #define RUBY_TOKEN_DOT2 128
46
+ #define RUBY_TOKEN_DOT3 129
47
+ #define RUBY_TOKEN_UPLUS 130
48
+ #define RUBY_TOKEN_UMINUS 131
49
+ #define RUBY_TOKEN_POW 132
50
+ #define RUBY_TOKEN_DSTAR 133
51
+ #define RUBY_TOKEN_CMP 134
52
+ #define RUBY_TOKEN_LSHFT 135
53
+ #define RUBY_TOKEN_RSHFT 136
54
+ #define RUBY_TOKEN_LEQ 137
55
+ #define RUBY_TOKEN_GEQ 138
56
+ #define RUBY_TOKEN_EQ 139
57
+ #define RUBY_TOKEN_EQQ 140
58
+ #define RUBY_TOKEN_NEQ 141
59
+ #define RUBY_TOKEN_MATCH 142
60
+ #define RUBY_TOKEN_NMATCH 143
61
+ #define RUBY_TOKEN_AREF 144
62
+ #define RUBY_TOKEN_ASET 145
63
+ #define RUBY_TOKEN_COLON2 146
64
+ #define RUBY_TOKEN_COLON3 147
65
+ #define RUBY_TOKEN(t) RUBY_TOKEN_##t
66
+
67
+ enum ruby_method_ids {
68
+ idDot2 = RUBY_TOKEN(DOT2),
69
+ idDot3 = RUBY_TOKEN(DOT3),
70
+ idUPlus = RUBY_TOKEN(UPLUS),
71
+ idUMinus = RUBY_TOKEN(UMINUS),
72
+ idPow = RUBY_TOKEN(POW),
73
+ idCmp = RUBY_TOKEN(CMP),
74
+ idPLUS = '+',
75
+ idMINUS = '-',
76
+ idMULT = '*',
77
+ idDIV = '/',
78
+ idMOD = '%',
79
+ idLT = '<',
80
+ idLTLT = RUBY_TOKEN(LSHFT),
81
+ idLE = RUBY_TOKEN(LEQ),
82
+ idGT = '>',
83
+ idGE = RUBY_TOKEN(GEQ),
84
+ idEq = RUBY_TOKEN(EQ),
85
+ idEqq = RUBY_TOKEN(EQQ),
86
+ idNeq = RUBY_TOKEN(NEQ),
87
+ idNot = '!',
88
+ idBackquote = '`',
89
+ idEqTilde = RUBY_TOKEN(MATCH),
90
+ idNeqTilde = RUBY_TOKEN(NMATCH),
91
+ idAREF = RUBY_TOKEN(AREF),
92
+ idASET = RUBY_TOKEN(ASET),
93
+ tPRESERVED_ID_BEGIN = 147,
94
+ idNULL,
95
+ idEmptyP,
96
+ idEqlP,
97
+ idRespond_to,
98
+ idRespond_to_missing,
99
+ idIFUNC,
100
+ idCFUNC,
101
+ id_core_set_method_alias,
102
+ id_core_set_variable_alias,
103
+ id_core_undef_method,
104
+ id_core_define_method,
105
+ id_core_define_singleton_method,
106
+ id_core_set_postexe,
107
+ id_core_hash_from_ary,
108
+ id_core_hash_merge_ary,
109
+ id_core_hash_merge_ptr,
110
+ id_core_hash_merge_kwd,
111
+ tPRESERVED_ID_END,
112
+ tFreeze,
113
+ tInspect,
114
+ tIntern,
115
+ tObject_id,
116
+ tConst_missing,
117
+ tMethodMissing,
118
+ tMethod_added,
119
+ tSingleton_method_added,
120
+ tMethod_removed,
121
+ tSingleton_method_removed,
122
+ tMethod_undefined,
123
+ tSingleton_method_undefined,
124
+ tLength,
125
+ tSize,
126
+ tGets,
127
+ tSucc,
128
+ tEach,
129
+ tProc,
130
+ tLambda,
131
+ tSend,
132
+ t__send__,
133
+ t__attached__,
134
+ tInitialize,
135
+ tInitialize_copy,
136
+ tInitialize_clone,
137
+ tInitialize_dup,
138
+ tUScore,
139
+ #define TOKEN2LOCALID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_LOCAL)
140
+ TOKEN2LOCALID(Freeze),
141
+ TOKEN2LOCALID(Inspect),
142
+ TOKEN2LOCALID(Intern),
143
+ TOKEN2LOCALID(Object_id),
144
+ TOKEN2LOCALID(Const_missing),
145
+ TOKEN2LOCALID(MethodMissing),
146
+ TOKEN2LOCALID(Method_added),
147
+ TOKEN2LOCALID(Singleton_method_added),
148
+ TOKEN2LOCALID(Method_removed),
149
+ TOKEN2LOCALID(Singleton_method_removed),
150
+ TOKEN2LOCALID(Method_undefined),
151
+ TOKEN2LOCALID(Singleton_method_undefined),
152
+ TOKEN2LOCALID(Length),
153
+ TOKEN2LOCALID(Size),
154
+ TOKEN2LOCALID(Gets),
155
+ TOKEN2LOCALID(Succ),
156
+ TOKEN2LOCALID(Each),
157
+ TOKEN2LOCALID(Proc),
158
+ TOKEN2LOCALID(Lambda),
159
+ TOKEN2LOCALID(Send),
160
+ TOKEN2LOCALID(__send__),
161
+ TOKEN2LOCALID(__attached__),
162
+ TOKEN2LOCALID(Initialize),
163
+ TOKEN2LOCALID(Initialize_copy),
164
+ TOKEN2LOCALID(Initialize_clone),
165
+ TOKEN2LOCALID(Initialize_dup),
166
+ TOKEN2LOCALID(UScore),
167
+ tLAST_OP_ID = tPRESERVED_ID_END-1,
168
+ idLAST_OP_ID = tLAST_OP_ID >> ID_SCOPE_SHIFT
169
+ };
170
+
171
+ #endif /* RUBY_ID_H */
@@ -0,0 +1,1006 @@
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
+ #if defined(__cplusplus)
16
+ extern "C" {
17
+ #if 0
18
+ } /* satisfy cc-mode */
19
+ #endif
20
+ #endif
21
+
22
+ /* likely */
23
+ #if __GNUC__ >= 3
24
+ #define LIKELY(x) (__builtin_expect((x), 1))
25
+ #define UNLIKELY(x) (__builtin_expect((x), 0))
26
+ #else /* __GNUC__ >= 3 */
27
+ #define LIKELY(x) (x)
28
+ #define UNLIKELY(x) (x)
29
+ #endif /* __GNUC__ >= 3 */
30
+
31
+ #ifndef __has_attribute
32
+ # define __has_attribute(x) 0
33
+ #endif
34
+
35
+ #if __has_attribute(unused)
36
+ #define UNINITIALIZED_VAR(x) x __attribute__((unused))
37
+ #elif defined(__GNUC__) && __GNUC__ >= 3
38
+ #define UNINITIALIZED_VAR(x) x = x
39
+ #else
40
+ #define UNINITIALIZED_VAR(x) x
41
+ #endif
42
+
43
+ #ifdef HAVE_VALGRIND_MEMCHECK_H
44
+ # include <valgrind/memcheck.h>
45
+ # ifndef VALGRIND_MAKE_MEM_DEFINED
46
+ # define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE((p), (n))
47
+ # endif
48
+ # ifndef VALGRIND_MAKE_MEM_UNDEFINED
49
+ # define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE((p), (n))
50
+ # endif
51
+ #else
52
+ # define VALGRIND_MAKE_MEM_DEFINED(p, n) 0
53
+ # define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
54
+ #endif
55
+
56
+ #define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
57
+
58
+ #define STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[1 - 2*!(expr)]
59
+
60
+ #define GCC_VERSION_SINCE(major, minor, patchlevel) \
61
+ (defined(__GNUC__) && !defined(__INTEL_COMPILER) && \
62
+ ((__GNUC__ > (major)) || \
63
+ (__GNUC__ == (major) && __GNUC_MINOR__ > (minor)) || \
64
+ (__GNUC__ == (major) && __GNUC_MINOR__ == (minor) && __GNUC_PATCHLEVEL__ >= (patchlevel))))
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 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 __builtin_clz(x);
142
+ #else
143
+ unsigned int y;
144
+ # if 64 < SIZEOF_INT * CHAR_BIT
145
+ int n = 128;
146
+ # elif 32 < SIZEOF_INT * CHAR_BIT
147
+ int n = 64;
148
+ # else
149
+ 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 (int)(n - x);
163
+ #endif
164
+ }
165
+
166
+ static inline 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 __builtin_clzl(x);
172
+ #else
173
+ unsigned long y;
174
+ # if 64 < SIZEOF_LONG * CHAR_BIT
175
+ int n = 128;
176
+ # elif 32 < SIZEOF_LONG * CHAR_BIT
177
+ int n = 64;
178
+ # else
179
+ 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 (int)(n - x);
193
+ #endif
194
+ }
195
+
196
+ #ifdef HAVE_LONG_LONG
197
+ static inline 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 __builtin_clzll(x);
203
+ #else
204
+ unsigned LONG_LONG y;
205
+ # if 64 < SIZEOF_LONG_LONG * CHAR_BIT
206
+ int n = 128;
207
+ # elif 32 < SIZEOF_LONG_LONG * CHAR_BIT
208
+ int n = 64;
209
+ # else
210
+ 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 (int)(n - x);
224
+ #endif
225
+ }
226
+ #endif
227
+
228
+ #ifdef HAVE_UINT128_T
229
+ static inline int
230
+ nlz_int128(uint128_t x)
231
+ {
232
+ uint128_t y;
233
+ 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 (int)(n - x);
242
+ }
243
+ #endif
244
+
245
+ #if defined(HAVE_UINT128_T)
246
+ # define bit_length(x) \
247
+ (sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
248
+ sizeof(x) <= SIZEOF_LONG ? SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)) : \
249
+ sizeof(x) <= SIZEOF_LONG_LONG ? SIZEOF_LONG_LONG * CHAR_BIT - nlz_long_long((unsigned LONG_LONG)(x)) : \
250
+ SIZEOF_INT128_T * CHAR_BIT - nlz_int128((uint128_t)(x)))
251
+ #elif defined(HAVE_LONG_LONG)
252
+ # define bit_length(x) \
253
+ (sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
254
+ sizeof(x) <= SIZEOF_LONG ? SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)) : \
255
+ SIZEOF_LONG_LONG * CHAR_BIT - nlz_long_long((unsigned LONG_LONG)(x)))
256
+ #else
257
+ # define bit_length(x) \
258
+ (sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
259
+ SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)))
260
+ #endif
261
+
262
+ struct rb_deprecated_classext_struct {
263
+ char conflict[sizeof(VALUE) * 3];
264
+ };
265
+
266
+ struct rb_subclass_entry;
267
+ typedef struct rb_subclass_entry rb_subclass_entry_t;
268
+
269
+ struct rb_subclass_entry {
270
+ VALUE klass;
271
+ rb_subclass_entry_t *next;
272
+ };
273
+
274
+ #if defined(HAVE_LONG_LONG)
275
+ typedef unsigned LONG_LONG rb_serial_t;
276
+ #define SERIALT2NUM ULL2NUM
277
+ #elif defined(HAVE_UINT64_T)
278
+ typedef uint64_t rb_serial_t;
279
+ #define SERIALT2NUM SIZET2NUM
280
+ #else
281
+ typedef unsigned long rb_serial_t;
282
+ #define SERIALT2NUM ULONG2NUM
283
+ #endif
284
+
285
+ struct rb_classext_struct {
286
+ struct st_table *iv_index_tbl;
287
+ struct st_table *iv_tbl;
288
+ struct st_table *const_tbl;
289
+ rb_subclass_entry_t *subclasses;
290
+ rb_subclass_entry_t **parent_subclasses;
291
+ /**
292
+ * In the case that this is an `ICLASS`, `module_subclasses` points to the link
293
+ * in the module's `subclasses` list that indicates that the klass has been
294
+ * included. Hopefully that makes sense.
295
+ */
296
+ rb_subclass_entry_t **module_subclasses;
297
+ rb_serial_t class_serial;
298
+ VALUE origin;
299
+ VALUE refined_class;
300
+ rb_alloc_func_t allocator;
301
+ };
302
+
303
+ struct method_table_wrapper {
304
+ st_table *tbl;
305
+ size_t serial;
306
+ };
307
+
308
+ #ifndef BDIGIT
309
+ # if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
310
+ # define BDIGIT unsigned int
311
+ # define SIZEOF_BDIGITS SIZEOF_INT
312
+ # define BDIGIT_DBL unsigned LONG_LONG
313
+ # define BDIGIT_DBL_SIGNED LONG_LONG
314
+ # define PRI_BDIGIT_PREFIX ""
315
+ # define PRI_BDIGIT_DBL_PREFIX PRI_LL_PREFIX
316
+ # elif SIZEOF_INT*2 <= SIZEOF_LONG
317
+ # define BDIGIT unsigned int
318
+ # define SIZEOF_BDIGITS SIZEOF_INT
319
+ # define BDIGIT_DBL unsigned long
320
+ # define BDIGIT_DBL_SIGNED long
321
+ # define PRI_BDIGIT_PREFIX ""
322
+ # define PRI_BDIGIT_DBL_PREFIX "l"
323
+ # elif SIZEOF_SHORT*2 <= SIZEOF_LONG
324
+ # define BDIGIT unsigned short
325
+ # define SIZEOF_BDIGITS SIZEOF_SHORT
326
+ # define BDIGIT_DBL unsigned long
327
+ # define BDIGIT_DBL_SIGNED long
328
+ # define PRI_BDIGIT_PREFIX "h"
329
+ # define PRI_BDIGIT_DBL_PREFIX "l"
330
+ # else
331
+ # define BDIGIT unsigned short
332
+ # define SIZEOF_BDIGITS (SIZEOF_LONG/2)
333
+ # define SIZEOF_ACTUAL_BDIGIT SIZEOF_LONG
334
+ # define BDIGIT_DBL unsigned long
335
+ # define BDIGIT_DBL_SIGNED long
336
+ # define PRI_BDIGIT_PREFIX "h"
337
+ # define PRI_BDIGIT_DBL_PREFIX "l"
338
+ # endif
339
+ #endif
340
+ #ifndef SIZEOF_ACTUAL_BDIGIT
341
+ # define SIZEOF_ACTUAL_BDIGIT SIZEOF_BDIGITS
342
+ #endif
343
+
344
+ #ifdef PRI_BDIGIT_PREFIX
345
+ # define PRIdBDIGIT PRI_BDIGIT_PREFIX"d"
346
+ # define PRIiBDIGIT PRI_BDIGIT_PREFIX"i"
347
+ # define PRIoBDIGIT PRI_BDIGIT_PREFIX"o"
348
+ # define PRIuBDIGIT PRI_BDIGIT_PREFIX"u"
349
+ # define PRIxBDIGIT PRI_BDIGIT_PREFIX"x"
350
+ # define PRIXBDIGIT PRI_BDIGIT_PREFIX"X"
351
+ #endif
352
+
353
+ #ifdef PRI_BDIGIT_DBL_PREFIX
354
+ # define PRIdBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"d"
355
+ # define PRIiBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"i"
356
+ # define PRIoBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"o"
357
+ # define PRIuBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"u"
358
+ # define PRIxBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"x"
359
+ # define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X"
360
+ #endif
361
+
362
+ #define BIGNUM_EMBED_LEN_NUMBITS 3
363
+ #ifndef BIGNUM_EMBED_LEN_MAX
364
+ # if (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT) < (1 << BIGNUM_EMBED_LEN_NUMBITS)-1
365
+ # define BIGNUM_EMBED_LEN_MAX (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT)
366
+ # else
367
+ # define BIGNUM_EMBED_LEN_MAX ((1 << BIGNUM_EMBED_LEN_NUMBITS)-1)
368
+ # endif
369
+ #endif
370
+
371
+ struct RBignum {
372
+ struct RBasic basic;
373
+ union {
374
+ struct {
375
+ long len;
376
+ BDIGIT *digits;
377
+ } heap;
378
+ BDIGIT ary[BIGNUM_EMBED_LEN_MAX];
379
+ } as;
380
+ };
381
+ #define BIGNUM_SIGN_BIT FL_USER1
382
+ /* sign: positive:1, negative:0 */
383
+ #define BIGNUM_SIGN(b) ((RBASIC(b)->flags & BIGNUM_SIGN_BIT) != 0)
384
+ #define BIGNUM_SET_SIGN(b,sign) \
385
+ ((sign) ? (RBASIC(b)->flags |= BIGNUM_SIGN_BIT) \
386
+ : (RBASIC(b)->flags &= ~BIGNUM_SIGN_BIT))
387
+ #define BIGNUM_POSITIVE_P(b) BIGNUM_SIGN(b)
388
+ #define BIGNUM_NEGATIVE_P(b) (!BIGNUM_SIGN(b))
389
+
390
+ #define BIGNUM_EMBED_FLAG FL_USER2
391
+ #define BIGNUM_EMBED_LEN_MASK (FL_USER5|FL_USER4|FL_USER3)
392
+ #define BIGNUM_EMBED_LEN_SHIFT (FL_USHIFT+BIGNUM_EMBED_LEN_NUMBITS)
393
+ #define BIGNUM_LEN(b) \
394
+ ((RBASIC(b)->flags & BIGNUM_EMBED_FLAG) ? \
395
+ (long)((RBASIC(b)->flags >> BIGNUM_EMBED_LEN_SHIFT) & \
396
+ (BIGNUM_EMBED_LEN_MASK >> BIGNUM_EMBED_LEN_SHIFT)) : \
397
+ RBIGNUM(b)->as.heap.len)
398
+ /* LSB:BIGNUM_DIGITS(b)[0], MSB:BIGNUM_DIGITS(b)[BIGNUM_LEN(b)-1] */
399
+ #define BIGNUM_DIGITS(b) \
400
+ ((RBASIC(b)->flags & BIGNUM_EMBED_FLAG) ? \
401
+ RBIGNUM(b)->as.ary : \
402
+ RBIGNUM(b)->as.heap.digits)
403
+ #define BIGNUM_LENINT(b) rb_long2int(BIGNUM_LEN(b))
404
+
405
+ #define RBIGNUM(obj) (R_CAST(RBignum)(obj))
406
+
407
+ /* class.c */
408
+ void rb_class_subclass_add(VALUE super, VALUE klass);
409
+ void rb_class_remove_from_super_subclasses(VALUE);
410
+
411
+ #define RCLASS_EXT(c) (RCLASS(c)->ptr)
412
+ #define RCLASS_IV_TBL(c) (RCLASS_EXT(c)->iv_tbl)
413
+ #define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl)
414
+ #define RCLASS_M_TBL_WRAPPER(c) (RCLASS(c)->m_tbl_wrapper)
415
+ #define RCLASS_M_TBL(c) (RCLASS_M_TBL_WRAPPER(c) ? RCLASS_M_TBL_WRAPPER(c)->tbl : 0)
416
+ #define RCLASS_IV_INDEX_TBL(c) (RCLASS_EXT(c)->iv_index_tbl)
417
+ #define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin)
418
+ #define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class)
419
+ #define RCLASS_SERIAL(c) (RCLASS_EXT(c)->class_serial)
420
+
421
+ static inline void
422
+ RCLASS_M_TBL_INIT(VALUE c)
423
+ {
424
+ struct method_table_wrapper *wrapper;
425
+ wrapper = ALLOC(struct method_table_wrapper);
426
+ wrapper->tbl = st_init_numtable();
427
+ wrapper->serial = 0;
428
+ RCLASS_M_TBL_WRAPPER(c) = wrapper;
429
+ }
430
+
431
+ #undef RCLASS_SUPER
432
+ static inline VALUE
433
+ RCLASS_SUPER(VALUE klass)
434
+ {
435
+ return RCLASS(klass)->super;
436
+ }
437
+
438
+ static inline VALUE
439
+ RCLASS_SET_SUPER(VALUE klass, VALUE super)
440
+ {
441
+ if (super) {
442
+ rb_class_remove_from_super_subclasses(klass);
443
+ rb_class_subclass_add(super, klass);
444
+ }
445
+ RB_OBJ_WRITE(klass, &RCLASS(klass)->super, super);
446
+ return super;
447
+ }
448
+
449
+ struct vtm; /* defined by timev.h */
450
+
451
+ /* array.c */
452
+ VALUE rb_ary_last(int, VALUE *, VALUE);
453
+ void rb_ary_set_len(VALUE, long);
454
+ void rb_ary_delete_same(VALUE, VALUE);
455
+
456
+ /* bignum.c */
457
+ VALUE rb_big_fdiv(VALUE x, VALUE y);
458
+ VALUE rb_big_uminus(VALUE x);
459
+ VALUE rb_integer_float_cmp(VALUE x, VALUE y);
460
+ VALUE rb_integer_float_eq(VALUE x, VALUE y);
461
+
462
+ /* class.c */
463
+ void rb_class_foreach_subclass(VALUE klass, void(*f)(VALUE));
464
+ void rb_class_detach_subclasses(VALUE);
465
+ void rb_class_detach_module_subclasses(VALUE);
466
+ void rb_class_remove_from_module_subclasses(VALUE);
467
+ VALUE rb_obj_methods(int argc, VALUE *argv, VALUE obj);
468
+ VALUE rb_obj_protected_methods(int argc, VALUE *argv, VALUE obj);
469
+ VALUE rb_obj_private_methods(int argc, VALUE *argv, VALUE obj);
470
+ VALUE rb_obj_public_methods(int argc, VALUE *argv, VALUE obj);
471
+ int rb_obj_basic_to_s_p(VALUE);
472
+ VALUE rb_special_singleton_class(VALUE);
473
+ VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach);
474
+ VALUE rb_singleton_class_get(VALUE obj);
475
+ void Init_class_hierarchy(void);
476
+
477
+ /* compar.c */
478
+ VALUE rb_invcmp(VALUE, VALUE);
479
+
480
+ /* compile.c */
481
+ int rb_dvar_defined(ID);
482
+ int rb_local_defined(ID);
483
+ int rb_parse_in_eval(void);
484
+ int rb_parse_in_main(void);
485
+ const char * rb_insns_name(int i);
486
+ VALUE rb_insns_name_array(void);
487
+
488
+ /* cont.c */
489
+ VALUE rb_obj_is_fiber(VALUE);
490
+ void rb_fiber_reset_root_local_storage(VALUE);
491
+ void ruby_register_rollback_func_for_ensure(VALUE (*ensure_func)(ANYARGS), VALUE (*rollback_func)(ANYARGS));
492
+
493
+ /* debug.c */
494
+ PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
495
+
496
+ /* dmyext.c */
497
+ void Init_ext(void);
498
+
499
+ /* encoding.c */
500
+ #ifdef RUBY_ENCODING_H
501
+ enum ruby_preserved_encindex {
502
+ ENCINDEX_ASCII,
503
+ ENCINDEX_UTF_8,
504
+ ENCINDEX_US_ASCII,
505
+
506
+ /* preserved indexes */
507
+ ENCINDEX_UTF_16BE,
508
+ ENCINDEX_UTF_16LE,
509
+ ENCINDEX_UTF_32BE,
510
+ ENCINDEX_UTF_32LE,
511
+ ENCINDEX_UTF_16,
512
+ ENCINDEX_UTF_32,
513
+ ENCINDEX_UTF8_MAC,
514
+
515
+ /* for old options of regexp */
516
+ ENCINDEX_EUC_JP,
517
+ ENCINDEX_Windows_31J,
518
+
519
+ ENCINDEX_BUILTIN_MAX
520
+ };
521
+ #endif
522
+ #define rb_ascii8bit_encindex() ENCINDEX_ASCII
523
+ #define rb_utf8_encindex() ENCINDEX_UTF_8
524
+ #define rb_usascii_encindex() ENCINDEX_US_ASCII
525
+ ID rb_id_encoding(void);
526
+ void rb_gc_mark_encodings(void);
527
+
528
+ /* error.c */
529
+ NORETURN(PRINTF_ARGS(void rb_compile_bug(const char*, int, const char*, ...), 3, 4));
530
+ VALUE rb_check_backtrace(VALUE);
531
+ NORETURN(void rb_async_bug_errno(const char *,int));
532
+ const char *rb_builtin_type_name(int t);
533
+ const char *rb_builtin_class_name(VALUE x);
534
+
535
+ /* eval.c */
536
+ VALUE rb_refinement_module_get_refined_class(VALUE module);
537
+
538
+ /* eval_error.c */
539
+ void ruby_error_print(void);
540
+ VALUE rb_get_backtrace(VALUE info);
541
+
542
+ /* eval_jump.c */
543
+ void rb_call_end_proc(VALUE data);
544
+ void rb_mark_end_proc(void);
545
+
546
+ /* file.c */
547
+ VALUE rb_home_dir_of(VALUE user, VALUE result);
548
+ VALUE rb_default_home_dir(VALUE result);
549
+ VALUE rb_realpath_internal(VALUE basedir, VALUE path, int strict);
550
+ void rb_file_const(const char*, VALUE);
551
+ int rb_file_load_ok(const char *);
552
+ VALUE rb_file_expand_path_fast(VALUE, VALUE);
553
+ VALUE rb_file_expand_path_internal(VALUE, VALUE, int, int, VALUE);
554
+ VALUE rb_get_path_check_to_string(VALUE, int);
555
+ VALUE rb_get_path_check_convert(VALUE, VALUE, int);
556
+ void Init_File(void);
557
+
558
+ #ifdef RUBY_FUNCTION_NAME_STRING
559
+ # if defined __GNUC__ && __GNUC__ >= 4
560
+ # pragma GCC visibility push(default)
561
+ # endif
562
+ NORETURN(void rb_sys_fail_path_in(const char *func_name, VALUE path));
563
+ NORETURN(void rb_syserr_fail_path_in(const char *func_name, int err, VALUE path));
564
+ # if defined __GNUC__ && __GNUC__ >= 4
565
+ # pragma GCC visibility pop
566
+ # endif
567
+ # define rb_sys_fail_path(path) rb_sys_fail_path_in(RUBY_FUNCTION_NAME_STRING, path)
568
+ # define rb_syserr_fail_path(err, path) rb_syserr_fail_path_in(RUBY_FUNCTION_NAME_STRING, (err), (path))
569
+ #else
570
+ # define rb_sys_fail_path(path) rb_sys_fail_str(path)
571
+ # define rb_syserr_fail_path(err, path) rb_syserr_fail_str((err), (path))
572
+ #endif
573
+
574
+ /* gc.c */
575
+ void Init_heap(void);
576
+ void *ruby_mimmalloc(size_t size);
577
+ void ruby_mimfree(void *ptr);
578
+ void rb_objspace_set_event_hook(const rb_event_flag_t event);
579
+ void rb_gc_writebarrier_remember_promoted(VALUE obj);
580
+ void ruby_gc_set_params(int safe_level);
581
+
582
+ #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) || defined(_WIN32)
583
+ #define ruby_sized_xrealloc(ptr, new_size, old_size) ruby_xrealloc(ptr, new_size)
584
+ #define ruby_sized_xrealloc2(ptr, new_count, element_size, old_count) ruby_xrealloc(ptr, new_count, element_size)
585
+ #define ruby_sized_xfree(ptr, size) ruby_xfree(ptr)
586
+ #define SIZED_REALLOC_N(var,type,n,old_n) REALLOC_N(var, type, n)
587
+ #else
588
+ void *ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_ALLOC_SIZE((2));
589
+ void *ruby_sized_xrealloc2(void *ptr, size_t new_count, size_t element_size, size_t old_count) RUBY_ATTR_ALLOC_SIZE((2, 3));
590
+ void ruby_sized_xfree(void *x, size_t size);
591
+ #define SIZED_REALLOC_N(var,type,n,old_n) ((var)=(type*)ruby_sized_xrealloc((char*)(var), (n) * sizeof(type), (old_n) * sizeof(type)))
592
+ #endif
593
+
594
+ void rb_gc_resurrect(VALUE ptr);
595
+
596
+ /* hash.c */
597
+ struct st_table *rb_hash_tbl_raw(VALUE hash);
598
+ #define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h)
599
+ VALUE rb_hash_values(VALUE hash);
600
+ #define HASH_DELETED FL_USER1
601
+ #define HASH_PROC_DEFAULT FL_USER2
602
+
603
+ /* inits.c */
604
+ void rb_call_inits(void);
605
+
606
+ /* io.c */
607
+ const char *ruby_get_inplace_mode(void);
608
+ void ruby_set_inplace_mode(const char *);
609
+ ssize_t rb_io_bufread(VALUE io, void *buf, size_t size);
610
+ void rb_stdio_set_default_encoding(void);
611
+ void rb_write_error_str(VALUE mesg);
612
+ VALUE rb_io_flush_raw(VALUE, int);
613
+
614
+ /* iseq.c */
615
+ VALUE rb_iseq_clone(VALUE iseqval, VALUE newcbase);
616
+ VALUE rb_iseq_path(VALUE iseqval);
617
+ VALUE rb_iseq_absolute_path(VALUE iseqval);
618
+ VALUE rb_iseq_label(VALUE iseqval);
619
+ VALUE rb_iseq_base_label(VALUE iseqval);
620
+ VALUE rb_iseq_first_lineno(VALUE iseqval);
621
+ VALUE rb_iseq_klass(VALUE iseqval); /* completely temporary fucntion */
622
+ VALUE rb_iseq_method_name(VALUE self);
623
+
624
+ /* load.c */
625
+ VALUE rb_get_load_path(void);
626
+ VALUE rb_get_expanded_load_path(void);
627
+ NORETURN(void rb_load_fail(VALUE, const char*));
628
+
629
+ /* math.c */
630
+ VALUE rb_math_atan2(VALUE, VALUE);
631
+ VALUE rb_math_cos(VALUE);
632
+ VALUE rb_math_cosh(VALUE);
633
+ VALUE rb_math_exp(VALUE);
634
+ VALUE rb_math_hypot(VALUE, VALUE);
635
+ VALUE rb_math_log(int argc, VALUE *argv);
636
+ VALUE rb_math_sin(VALUE);
637
+ VALUE rb_math_sinh(VALUE);
638
+ VALUE rb_math_sqrt(VALUE);
639
+
640
+ /* newline.c */
641
+ void Init_newline(void);
642
+
643
+ /* numeric.c */
644
+ int rb_num_to_uint(VALUE val, unsigned int *ret);
645
+ VALUE ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl);
646
+ int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl);
647
+ double ruby_float_mod(double x, double y);
648
+ int rb_num_negative_p(VALUE);
649
+ VALUE rb_int_succ(VALUE num);
650
+ VALUE rb_int_pred(VALUE num);
651
+
652
+ #if USE_FLONUM
653
+ #define RUBY_BIT_ROTL(v, n) (((v) << (n)) | ((v) >> ((sizeof(v) * 8) - n)))
654
+ #define RUBY_BIT_ROTR(v, n) (((v) >> (n)) | ((v) << ((sizeof(v) * 8) - n)))
655
+ #endif
656
+
657
+ static inline double
658
+ rb_float_value_inline(VALUE v)
659
+ {
660
+ #if USE_FLONUM
661
+ if (FLONUM_P(v)) {
662
+ if (v != (VALUE)0x8000000000000002) { /* LIKELY */
663
+ union {
664
+ double d;
665
+ VALUE v;
666
+ } t;
667
+
668
+ VALUE b63 = (v >> 63);
669
+ /* e: xx1... -> 011... */
670
+ /* xx0... -> 100... */
671
+ /* ^b63 */
672
+ t.v = RUBY_BIT_ROTR((2 - b63) | (v & ~0x03), 3);
673
+ return t.d;
674
+ }
675
+ else {
676
+ return 0.0;
677
+ }
678
+ }
679
+ #endif
680
+ return ((struct RFloat *)v)->float_value;
681
+ }
682
+
683
+ static inline VALUE
684
+ rb_float_new_inline(double d)
685
+ {
686
+ #if USE_FLONUM
687
+ union {
688
+ double d;
689
+ VALUE v;
690
+ } t;
691
+ int bits;
692
+
693
+ t.d = d;
694
+ bits = (int)((VALUE)(t.v >> 60) & 0x7);
695
+ /* bits contains 3 bits of b62..b60. */
696
+ /* bits - 3 = */
697
+ /* b011 -> b000 */
698
+ /* b100 -> b001 */
699
+
700
+ if (t.v != 0x3000000000000000 /* 1.72723e-77 */ &&
701
+ !((bits-3) & ~0x01)) {
702
+ return (RUBY_BIT_ROTL(t.v, 3) & ~(VALUE)0x01) | 0x02;
703
+ }
704
+ else if (t.v == (VALUE)0) {
705
+ /* +0.0 */
706
+ return 0x8000000000000002;
707
+ }
708
+ /* out of range */
709
+ #endif
710
+ return rb_float_new_in_heap(d);
711
+ }
712
+
713
+ #define rb_float_value(v) rb_float_value_inline(v)
714
+ #define rb_float_new(d) rb_float_new_inline(d)
715
+
716
+ /* object.c */
717
+ VALUE rb_obj_equal(VALUE obj1, VALUE obj2);
718
+
719
+ struct RBasicRaw {
720
+ VALUE flags;
721
+ VALUE klass;
722
+ };
723
+
724
+ #define RBASIC_CLEAR_CLASS(obj) (((struct RBasicRaw *)((VALUE)(obj)))->klass = 0)
725
+ #define RBASIC_SET_CLASS_RAW(obj, cls) (((struct RBasicRaw *)((VALUE)(obj)))->klass = (cls))
726
+ #define RBASIC_SET_CLASS(obj, cls) do { \
727
+ VALUE _obj_ = (obj); \
728
+ RB_OBJ_WRITE(_obj_, &((struct RBasicRaw *)(_obj_))->klass, cls); \
729
+ } while (0)
730
+
731
+ /* parse.y */
732
+ VALUE rb_parser_get_yydebug(VALUE);
733
+ VALUE rb_parser_set_yydebug(VALUE, VALUE);
734
+ int rb_is_const_name(VALUE name);
735
+ int rb_is_class_name(VALUE name);
736
+ int rb_is_global_name(VALUE name);
737
+ int rb_is_instance_name(VALUE name);
738
+ int rb_is_attrset_name(VALUE name);
739
+ int rb_is_local_name(VALUE name);
740
+ int rb_is_method_name(VALUE name);
741
+ int rb_is_junk_name(VALUE name);
742
+ void rb_gc_mark_parser(void);
743
+ void rb_gc_mark_symbols(int full_mark);
744
+ ID rb_make_internal_id(void);
745
+
746
+ /* proc.c */
747
+ VALUE rb_proc_location(VALUE self);
748
+ st_index_t rb_hash_proc(st_index_t hash, VALUE proc);
749
+ int rb_block_arity(void);
750
+
751
+ /* process.c */
752
+ #define RB_MAX_GROUPS (65536)
753
+
754
+ struct rb_execarg {
755
+ int use_shell;
756
+ union {
757
+ struct {
758
+ VALUE shell_script;
759
+ } sh;
760
+ struct {
761
+ VALUE command_name;
762
+ VALUE command_abspath; /* full path string or nil */
763
+ VALUE argv_str;
764
+ VALUE argv_buf;
765
+ } cmd;
766
+ } invoke;
767
+ VALUE redirect_fds;
768
+ VALUE envp_str;
769
+ VALUE envp_buf;
770
+ VALUE dup2_tmpbuf;
771
+ unsigned pgroup_given : 1;
772
+ unsigned umask_given : 1;
773
+ unsigned unsetenv_others_given : 1;
774
+ unsigned unsetenv_others_do : 1;
775
+ unsigned close_others_given : 1;
776
+ unsigned close_others_do : 1;
777
+ unsigned chdir_given : 1;
778
+ unsigned new_pgroup_given : 1;
779
+ unsigned new_pgroup_flag : 1;
780
+ unsigned uid_given : 1;
781
+ unsigned gid_given : 1;
782
+ rb_pid_t pgroup_pgid; /* asis(-1), new pgroup(0), specified pgroup (0<V). */
783
+ VALUE rlimit_limits; /* Qfalse or [[rtype, softlim, hardlim], ...] */
784
+ mode_t umask_mask;
785
+ rb_uid_t uid;
786
+ rb_gid_t gid;
787
+ VALUE fd_dup2;
788
+ VALUE fd_close;
789
+ VALUE fd_open;
790
+ VALUE fd_dup2_child;
791
+ int close_others_maxhint;
792
+ VALUE env_modification; /* Qfalse or [[k1,v1], ...] */
793
+ VALUE chdir_dir;
794
+ };
795
+
796
+ /* argv_str contains extra two elements.
797
+ * The beginning one is for /bin/sh used by exec_with_sh.
798
+ * The last one for terminating NULL used by execve.
799
+ * See rb_exec_fillarg() in process.c. */
800
+ #define ARGVSTR2ARGC(argv_str) (RSTRING_LEN(argv_str) / sizeof(char *) - 2)
801
+ #define ARGVSTR2ARGV(argv_str) ((char **)RSTRING_PTR(argv_str) + 1)
802
+
803
+ rb_pid_t rb_fork_ruby(int *status);
804
+ void rb_last_status_clear(void);
805
+
806
+ /* rational.c */
807
+ VALUE rb_lcm(VALUE x, VALUE y);
808
+ VALUE rb_rational_reciprocal(VALUE x);
809
+
810
+ /* re.c */
811
+ VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline);
812
+ VALUE rb_reg_check_preprocess(VALUE);
813
+
814
+ /* signal.c */
815
+ int rb_get_next_signal(void);
816
+ int rb_sigaltstack_size(void);
817
+
818
+ /* strftime.c */
819
+ #ifdef RUBY_ENCODING_H
820
+ size_t rb_strftime_timespec(char *s, size_t maxsize, const char *format, rb_encoding *enc,
821
+ const struct vtm *vtm, struct timespec *ts, int gmt);
822
+ size_t rb_strftime(char *s, size_t maxsize, const char *format, rb_encoding *enc,
823
+ const struct vtm *vtm, VALUE timev, int gmt);
824
+ #endif
825
+
826
+ /* string.c */
827
+ VALUE rb_fstring(VALUE);
828
+ int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p);
829
+ int rb_str_symname_p(VALUE);
830
+ VALUE rb_str_quote_unprintable(VALUE);
831
+ VALUE rb_id_quote_unprintable(ID);
832
+ #define QUOTE(str) rb_str_quote_unprintable(str)
833
+ #define QUOTE_ID(id) rb_id_quote_unprintable(id)
834
+ void rb_str_fill_terminator(VALUE str, const int termlen);
835
+ VALUE rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg);
836
+ #ifdef RUBY_ENCODING_H
837
+ VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc);
838
+ #endif
839
+ #define STR_NOEMBED FL_USER1
840
+ #define STR_SHARED FL_USER2 /* = ELTS_SHARED */
841
+ #define STR_EMBED_P(str) (!FL_TEST((str), STR_NOEMBED))
842
+ #define STR_SHARED_P(s) FL_ALL((s), STR_NOEMBED|ELTS_SHARED)
843
+ #define is_ascii_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT)
844
+ #define is_broken_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN)
845
+
846
+ /* struct.c */
847
+ VALUE rb_struct_init_copy(VALUE copy, VALUE s);
848
+
849
+ /* time.c */
850
+ struct timeval rb_time_timeval(VALUE);
851
+
852
+ /* thread.c */
853
+ VALUE rb_obj_is_mutex(VALUE obj);
854
+ VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
855
+ void rb_thread_execute_interrupts(VALUE th);
856
+ void rb_clear_trace_func(void);
857
+ VALUE rb_get_coverages(void);
858
+ VALUE rb_thread_shield_new(void);
859
+ VALUE rb_thread_shield_wait(VALUE self);
860
+ VALUE rb_thread_shield_release(VALUE self);
861
+ VALUE rb_thread_shield_destroy(VALUE self);
862
+ void rb_mutex_allow_trap(VALUE self, int val);
863
+ VALUE rb_uninterruptible(VALUE (*b_proc)(ANYARGS), VALUE data);
864
+ VALUE rb_mutex_owned_p(VALUE self);
865
+ void ruby_kill(rb_pid_t pid, int sig);
866
+
867
+ /* thread_pthread.c, thread_win32.c */
868
+ void Init_native_thread(void);
869
+
870
+ /* vm_insnhelper.h */
871
+ rb_serial_t rb_next_class_serial(void);
872
+
873
+ /* vm.c */
874
+ VALUE rb_obj_is_thread(VALUE obj);
875
+ void rb_vm_mark(void *ptr);
876
+ void Init_BareVM(void);
877
+ VALUE rb_vm_top_self(void);
878
+ void rb_thread_recycle_stack_release(VALUE *);
879
+ void rb_vm_change_state(void);
880
+ void rb_vm_inc_const_missing_count(void);
881
+ void rb_thread_mark(void *th);
882
+ const void **rb_vm_get_insns_address_table(void);
883
+ VALUE rb_sourcefilename(void);
884
+ void rb_vm_pop_cfunc_frame(void);
885
+
886
+ /* vm_dump.c */
887
+ void rb_vm_bugreport(void);
888
+ void rb_print_backtrace(void);
889
+
890
+ /* vm_eval.c */
891
+ void Init_vm_eval(void);
892
+ VALUE rb_current_realfilepath(void);
893
+ VALUE rb_check_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE);
894
+ typedef void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE);
895
+ VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv,
896
+ rb_check_funcall_hook *hook, VALUE arg);
897
+ VALUE rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, int *stateptr);
898
+
899
+ /* vm_insnhelper.c */
900
+ VALUE rb_equal_opt(VALUE obj1, VALUE obj2);
901
+ int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *);
902
+ VALUE rb_extract_keywords(VALUE *orighash);
903
+
904
+ /* vm_method.c */
905
+ void Init_eval_method(void);
906
+ int rb_method_defined_by(VALUE obj, ID mid, VALUE (*cfunc)(ANYARGS));
907
+
908
+ /* miniprelude.c, prelude.c */
909
+ void Init_prelude(void);
910
+
911
+ /* vm_backtrace.c */
912
+ void Init_vm_backtrace(void);
913
+ VALUE rb_vm_thread_backtrace(int argc, VALUE *argv, VALUE thval);
914
+ VALUE rb_vm_thread_backtrace_locations(int argc, VALUE *argv, VALUE thval);
915
+
916
+ VALUE rb_make_backtrace(void);
917
+ void rb_backtrace_print_as_bugreport(void);
918
+ int rb_backtrace_p(VALUE obj);
919
+ VALUE rb_backtrace_to_str_ary(VALUE obj);
920
+ VALUE rb_backtrace_to_location_ary(VALUE obj);
921
+ void rb_backtrace_print_to(VALUE output);
922
+ VALUE rb_vm_backtrace_object(void);
923
+
924
+ RUBY_SYMBOL_EXPORT_BEGIN
925
+ const char *rb_objspace_data_type_name(VALUE obj);
926
+
927
+ /* Temporary. This API will be removed (renamed). */
928
+ VALUE rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd);
929
+
930
+ /* bignum.c */
931
+ VALUE rb_big_mul_normal(VALUE x, VALUE y);
932
+ VALUE rb_big_mul_balance(VALUE x, VALUE y);
933
+ VALUE rb_big_mul_karatsuba(VALUE x, VALUE y);
934
+ VALUE rb_big_mul_toom3(VALUE x, VALUE y);
935
+ VALUE rb_big_sq_fast(VALUE x);
936
+ VALUE rb_big_divrem_normal(VALUE x, VALUE y);
937
+ VALUE rb_big2str_poweroftwo(VALUE x, int base);
938
+ VALUE rb_big2str_generic(VALUE x, int base);
939
+ VALUE rb_str2big_poweroftwo(VALUE arg, int base, int badcheck);
940
+ VALUE rb_str2big_normal(VALUE arg, int base, int badcheck);
941
+ VALUE rb_str2big_karatsuba(VALUE arg, int base, int badcheck);
942
+ #if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
943
+ VALUE rb_big_mul_gmp(VALUE x, VALUE y);
944
+ VALUE rb_big_divrem_gmp(VALUE x, VALUE y);
945
+ VALUE rb_big2str_gmp(VALUE x, int base);
946
+ VALUE rb_str2big_gmp(VALUE arg, int base, int badcheck);
947
+ #endif
948
+
949
+ /* error.c */
950
+ int rb_bug_reporter_add(void (*func)(FILE *, void *), void *data);
951
+
952
+ /* file.c */
953
+ #ifdef __APPLE__
954
+ VALUE rb_str_normalize_ospath(const char *ptr, long len);
955
+ #endif
956
+
957
+ /* io.c */
958
+ void rb_maygvl_fd_fix_cloexec(int fd);
959
+
960
+ /* numeric.c */
961
+ VALUE rb_int_positive_pow(long x, unsigned long y);
962
+
963
+ /* process.c */
964
+ int rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen);
965
+ 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);
966
+ VALUE rb_execarg_new(int argc, VALUE *argv, int accept_shell);
967
+ struct rb_execarg *rb_execarg_get(VALUE execarg_obj); /* dangerous. needs GC guard. */
968
+ VALUE rb_execarg_init(int argc, VALUE *argv, int accept_shell, VALUE execarg_obj);
969
+ int rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val);
970
+ void rb_execarg_fixup(VALUE execarg_obj);
971
+ int rb_execarg_run_options(const struct rb_execarg *e, struct rb_execarg *s, char* errmsg, size_t errmsg_buflen);
972
+ VALUE rb_execarg_extract_options(VALUE execarg_obj, VALUE opthash);
973
+ void rb_execarg_setenv(VALUE execarg_obj, VALUE env);
974
+
975
+ /* rational.c */
976
+ VALUE rb_gcd_normal(VALUE self, VALUE other);
977
+ #if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
978
+ VALUE rb_gcd_gmp(VALUE x, VALUE y);
979
+ #endif
980
+
981
+ /* util.c */
982
+ extern const signed char ruby_digit36_to_number_table[];
983
+
984
+ /* variable.c */
985
+ void rb_gc_mark_global_tbl(void);
986
+ void rb_mark_generic_ivar(VALUE);
987
+ void rb_mark_generic_ivar_tbl(void);
988
+
989
+ int rb_st_insert_id_and_value(VALUE obj, st_table *tbl, ID key, VALUE value);
990
+ st_table *rb_st_copy(VALUE obj, struct st_table *orig_tbl);
991
+
992
+ /* gc.c */
993
+ size_t rb_obj_memsize_of(VALUE);
994
+ #define RB_OBJ_GC_FLAGS_MAX 5
995
+ size_t rb_obj_gc_flags(VALUE, ID[], size_t);
996
+
997
+ RUBY_SYMBOL_EXPORT_END
998
+
999
+ #if defined(__cplusplus)
1000
+ #if 0
1001
+ { /* satisfy cc-mode */
1002
+ #endif
1003
+ } /* extern "C" { */
1004
+ #endif
1005
+
1006
+ #endif /* RUBY_INTERNAL_H */