Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 234 lines (193 sloc) 5.953 kB
8a9993d @nobu * eval_intern.h, insnhelper.h, thread_pthread.h, vm_core.h, vm_opts.h:
nobu authored
1 #ifndef RUBY_EVAL_INTERN_H
2 #define RUBY_EVAL_INTERN_H
a3e1b1c @ko1 * Merge YARV
ko1 authored
3
705b8b4 @shyouhei * vm_core.h: ruby/ruby.h should be included at the very first
shyouhei authored
4 #include "ruby/ruby.h"
8cd252a @ko1 * common.mk: clean up
ko1 authored
5 #include "vm_core.h"
6
9e324fd @ko1 * vm.c, eval_intern.h (PASS_PASSED_BLOCK):
ko1 authored
7 #define PASS_PASSED_BLOCK_TH(th) do { \
8 (th)->passed_block = GC_GUARDED_PTR_REF((rb_block_t *)(th)->cfp->lfp[0]); \
9 (th)->cfp->flag |= VM_FRAME_FLAG_PASSED; \
10 } while (0)
11
12 #define PASS_PASSED_BLOCK() do { \
13 rb_thread_t * const __th__ = GET_THREAD(); \
14 PASS_PASSED_BLOCK_TH(__th__); \
15 } while (0)
a3e1b1c @ko1 * Merge YARV
ko1 authored
16
17 #ifdef HAVE_STDLIB_H
18 #include <stdlib.h>
19 #endif
20 #ifndef EXIT_SUCCESS
21 #define EXIT_SUCCESS 0
22 #endif
23 #ifndef EXIT_FAILURE
24 #define EXIT_FAILURE 1
25 #endif
26
27 #include <stdio.h>
28 #include <setjmp.h>
29
30 #ifdef __APPLE__
31 #include <crt_externs.h>
32 #endif
33
34 /* Make alloca work the best possible way. */
35 #ifdef __GNUC__
36 # ifndef atarist
37 # ifndef alloca
38 # define alloca __builtin_alloca
39 # endif
40 # endif /* atarist */
41 #else
42 # ifdef HAVE_ALLOCA_H
43 # include <alloca.h>
44 # else
45 # ifdef _AIX
46 #pragma alloca
47 # else
48 # ifndef alloca /* predefined by HP cc +Olibcalls */
49 void *alloca();
50 # endif
51 # endif /* AIX */
52 # endif /* HAVE_ALLOCA_H */
53 #endif /* __GNUC__ */
54
55 #ifndef HAVE_STRING_H
3410fd6 * README.EXT.ja, dir.c, eval.c, eval_intern.h, lex.c.src,
matz authored
56 char *strrchr(const char *, const char);
a3e1b1c @ko1 * Merge YARV
ko1 authored
57 #endif
58
59 #ifdef HAVE_UNISTD_H
60 #include <unistd.h>
61 #endif
62
1c22ef1 @nobu * configure.in (shutdown, sched_yield, pthread_attr_setinheritsched):
nobu authored
63 #ifdef HAVE_NET_SOCKET_H
a3e1b1c @ko1 * Merge YARV
ko1 authored
64 #include <net/socket.h>
65 #endif
66
b39676f @nobu * configure.in (RUBY_SETJMP, RUBY_LONGJMP, RUBY_JMP_BUF): prefers
nobu authored
67 #define ruby_setjmp(env) RUBY_SETJMP(env)
c8e22ee @akr * eval_intern.h: parenthesize macro arguments.
akr authored
68 #define ruby_longjmp(env,val) RUBY_LONGJMP((env),(val))
b39676f @nobu * configure.in (RUBY_SETJMP, RUBY_LONGJMP, RUBY_JMP_BUF): prefers
nobu authored
69 #ifdef __CYGWIN__
3589927 @nobu * eval_intern.h (_longjmp): never return. see [ruby-core:23241]
nobu authored
70 # ifndef _setjmp
71 int _setjmp(jmp_buf);
72 # endif
73 # ifndef _longjmp
74 NORETURN(void _longjmp(jmp_buf, int));
75 # endif
a3e1b1c @ko1 * Merge YARV
ko1 authored
76 #endif
77
78 #include <sys/types.h>
79 #include <signal.h>
80 #include <errno.h>
81
82 #ifdef HAVE_SYS_SELECT_H
83 #include <sys/select.h>
84 #endif
85
86 /*
87 Solaris sys/select.h switches select to select_large_fdset to support larger
88 file descriptors if FD_SETSIZE is larger than 1024 on 32bit environment.
89 But Ruby doesn't change FD_SETSIZE because fd_set is allocated dynamically.
90 So following definition is required to use select_large_fdset.
91 */
92 #ifdef HAVE_SELECT_LARGE_FDSET
c8e22ee @akr * eval_intern.h: parenthesize macro arguments.
akr authored
93 #define select(n, r, w, e, t) select_large_fdset((n), (r), (w), (e), (t))
a3e1b1c @ko1 * Merge YARV
ko1 authored
94 #endif
95
96 #ifdef HAVE_SYS_PARAM_H
97 #include <sys/param.h>
98 #endif
99
100 #include <sys/stat.h>
101
57062d9 @ko1 * cont.c: support Fiber. Check test/ruby/test_fiber.rb for detail.
ko1 authored
102 #define SAVE_ROOT_JMPBUF(th, stmt) do \
103 if (ruby_setjmp((th)->root_jmpbuf) == 0) { \
104 stmt; \
105 } \
106 else { \
64ffdb4 @ko1 * cont.c (rb_fiber_start): clear th->tag and check error to fix
ko1 authored
107 rb_fiber_start(); \
57062d9 @ko1 * cont.c: support Fiber. Check test/ruby/test_fiber.rb for detail.
ko1 authored
108 } while (0)
109
a3e1b1c @ko1 * Merge YARV
ko1 authored
110 #define TH_PUSH_TAG(th) do { \
c8e22ee @akr * eval_intern.h: parenthesize macro arguments.
akr authored
111 rb_thread_t * const _th = (th); \
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
112 struct rb_vm_tag _tag; \
a3e1b1c @ko1 * Merge YARV
ko1 authored
113 _tag.tag = 0; \
114 _tag.prev = _th->tag; \
115 _th->tag = &_tag;
116
117 #define TH_POP_TAG() \
118 _th->tag = _tag.prev; \
119 } while (0)
120
121 #define TH_POP_TAG2() \
122 _th->tag = _tag.prev
123
354844b @nobu * eval_intern.h (PUSH_TAG): no argument now.
nobu authored
124 #define PUSH_TAG() TH_PUSH_TAG(GET_THREAD())
a3e1b1c @ko1 * Merge YARV
ko1 authored
125 #define POP_TAG() TH_POP_TAG()
126
1ee96f7 * eval_intern.h (TH_EXEC_TAG): need not to FLUSH_REGISTER_WINDOWS.
matz authored
127 #define TH_EXEC_TAG() ruby_setjmp(_th->tag->buf)
a3e1b1c @ko1 * Merge YARV
ko1 authored
128
129 #define EXEC_TAG() \
130 TH_EXEC_TAG()
131
132 #define TH_JUMP_TAG(th, st) do { \
c8e22ee @akr * eval_intern.h: parenthesize macro arguments.
akr authored
133 ruby_longjmp((th)->tag->buf,(st)); \
a3e1b1c @ko1 * Merge YARV
ko1 authored
134 } while (0)
135
c8e22ee @akr * eval_intern.h: parenthesize macro arguments.
akr authored
136 #define JUMP_TAG(st) TH_JUMP_TAG(GET_THREAD(), (st))
a3e1b1c @ko1 * Merge YARV
ko1 authored
137
2082417 @nobu * eval.c (setup_exception): internal exception should be hidden
nobu authored
138 #define INTERNAL_EXCEPTION_P(exc) FIXNUM_P(exc)
139
9f48c67 @nobu * eval_intern.h (enum ruby_tag_type): enum for debug.
nobu authored
140 enum ruby_tag_type {
141 RUBY_TAG_RETURN = 0x1,
142 RUBY_TAG_BREAK = 0x2,
143 RUBY_TAG_NEXT = 0x3,
144 RUBY_TAG_RETRY = 0x4,
145 RUBY_TAG_REDO = 0x5,
146 RUBY_TAG_RAISE = 0x6,
147 RUBY_TAG_THROW = 0x7,
148 RUBY_TAG_FATAL = 0x8,
149 RUBY_TAG_MASK = 0xf
150 };
151 #define TAG_RETURN RUBY_TAG_RETURN
152 #define TAG_BREAK RUBY_TAG_BREAK
153 #define TAG_NEXT RUBY_TAG_NEXT
154 #define TAG_RETRY RUBY_TAG_RETRY
155 #define TAG_REDO RUBY_TAG_REDO
156 #define TAG_RAISE RUBY_TAG_RAISE
157 #define TAG_THROW RUBY_TAG_THROW
158 #define TAG_FATAL RUBY_TAG_FATAL
159 #define TAG_MASK RUBY_TAG_MASK
a3e1b1c @ko1 * Merge YARV
ko1 authored
160
d5e687b @ko1 * vm.h, eval_intern.h: move some macros to eval_intern.h.
ko1 authored
161 #define NEW_THROW_OBJECT(val, pt, st) \
c8c6fde @ko1 * eval_intern.h: use rb_node_newnode() directly.
ko1 authored
162 ((VALUE)rb_node_newnode(NODE_LIT, (VALUE)(val), (VALUE)(pt), (VALUE)(st)))
d5e687b @ko1 * vm.h, eval_intern.h: move some macros to eval_intern.h.
ko1 authored
163 #define SET_THROWOBJ_CATCH_POINT(obj, val) \
164 (RNODE((obj))->u2.value = (val))
165 #define SET_THROWOBJ_STATE(obj, val) \
166 (RNODE((obj))->u3.value = (val))
167
168 #define GET_THROWOBJ_VAL(obj) ((VALUE)RNODE((obj))->u1.value)
169 #define GET_THROWOBJ_CATCH_POINT(obj) ((VALUE*)RNODE((obj))->u2.value)
170 #define GET_THROWOBJ_STATE(obj) ((int)RNODE((obj))->u3.value)
171
cf23d0f @ko1 * vm.c: add a prefix "rb_" to exposed functions
ko1 authored
172 #define SCOPE_TEST(f) (rb_vm_cref()->nd_visi & (f))
173 #define SCOPE_CHECK(f) (rb_vm_cref()->nd_visi == (f))
174 #define SCOPE_SET(f) (rb_vm_cref()->nd_visi = (f))
ea2dd2e @ko1 * process.c: fix to use rb_status_line_set/get/clear().
ko1 authored
175
67aa07f @ko1 * eval.c (eval): fix to check stack overflow.
ko1 authored
176 #define CHECK_STACK_OVERFLOW(cfp, margin) do \
c8e22ee @akr * eval_intern.h: parenthesize macro arguments.
akr authored
177 if ((VALUE *)((char *)(((VALUE *)(cfp)->sp) + (margin)) + sizeof(rb_control_frame_t)) >= ((VALUE *)(cfp))) { \
67aa07f @ko1 * eval.c (eval): fix to check stack overflow.
ko1 authored
178 rb_exc_raise(sysstack_error); \
179 } \
180 while (0)
181
3410fd6 * README.EXT.ja, dir.c, eval.c, eval_intern.h, lex.c.src,
matz authored
182 void rb_thread_cleanup(void);
183 void rb_thread_wait_other_threads(void);
a3e1b1c @ko1 * Merge YARV
ko1 authored
184
96240c6 @nobu * eval_intern.h (rb_thread_raised_set): use generic flags.
nobu authored
185 enum {
186 RAISED_EXCEPTION = 1,
2de3f18 @mame * eval_intern.h: speficy the values of the enumeration constants
mame authored
187 RAISED_STACKOVERFLOW = 2,
3e69e83 @shyouhei * include/ruby/ruby.h (enum ruby_special_consts): ISO C forbids
shyouhei authored
188 RAISED_NOMEMORY = 4
96240c6 @nobu * eval_intern.h (rb_thread_raised_set): use generic flags.
nobu authored
189 };
79b62da @ko1 * thread.c: rename functions which require a parameter
ko1 authored
190 int rb_threadptr_set_raised(rb_thread_t *th);
191 int rb_threadptr_reset_raised(rb_thread_t *th);
96240c6 @nobu * eval_intern.h (rb_thread_raised_set): use generic flags.
nobu authored
192 #define rb_thread_raised_set(th, f) ((th)->raised_flag |= (f))
193 #define rb_thread_raised_reset(th, f) ((th)->raised_flag &= ~(f))
194 #define rb_thread_raised_p(th, f) (((th)->raised_flag & (f)) != 0)
195 #define rb_thread_raised_clear(th) ((th)->raised_flag = 0)
a3e1b1c @ko1 * Merge YARV
ko1 authored
196
197 VALUE rb_f_eval(int argc, VALUE *argv, VALUE self);
3410fd6 * README.EXT.ja, dir.c, eval.c, eval_intern.h, lex.c.src,
matz authored
198 VALUE rb_make_exception(int argc, VALUE *argv);
a3e1b1c @ko1 * Merge YARV
ko1 authored
199
64ffdb4 @ko1 * cont.c (rb_fiber_start): clear th->tag and check error to fix
ko1 authored
200 NORETURN(void rb_fiber_start(void));
201
3410fd6 * README.EXT.ja, dir.c, eval.c, eval_intern.h, lex.c.src,
matz authored
202 NORETURN(void rb_print_undef(VALUE, ID, int));
cf23d0f @ko1 * vm.c: add a prefix "rb_" to exposed functions
ko1 authored
203 NORETURN(void rb_vm_localjump_error(const char *,VALUE, int));
204 NORETURN(void rb_vm_jump_tag_but_local_jump(int, VALUE));
19bbab6 @nobu * vm_eval.c (method_missing): should not pop cfp if missing method
nobu authored
205 NORETURN(void rb_raise_method_missing(rb_thread_t *th, int argc, VALUE *argv,
206 VALUE obj, int call_status));
a3e1b1c @ko1 * Merge YARV
ko1 authored
207
cf23d0f @ko1 * vm.c: add a prefix "rb_" to exposed functions
ko1 authored
208 VALUE rb_vm_make_jump_tag_but_local_jump(int state, VALUE val);
209 NODE *rb_vm_cref(void);
2db5725 @mame * load.c (rb_load_internal): remove call to rb_realpath_internal
mame authored
210 VALUE rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, const rb_block_t *blockptr, VALUE filename);
589ec2b @nobu * ruby.c (ruby_script): sets also VM toplevel program name.
nobu authored
211 void rb_vm_set_progname(VALUE filename);
44aef0b @ko1 * this commit is a result of refactoring. only renaming functions,
ko1 authored
212 void rb_thread_terminate_all(void);
6b6bf4d @ko1 * blockinlining.c: remove "yarv" prefix.
ko1 authored
213 VALUE rb_vm_top_self();
385f0e8 @ko1 * vm.c, insns.def, eval.c, vm_insnhelper.c: fix CREF handling.
ko1 authored
214 VALUE rb_vm_cbase(void);
204929a @ko1 * include/ruby/signal.h: removed.
ko1 authored
215 void rb_trap_restore_mask(void);
a3e1b1c @ko1 * Merge YARV
ko1 authored
216
f35308b @nobu * eval_intern.h (translit_char): moved from ruby.c.
nobu authored
217 #ifndef CharNext /* defined as CharNext[AW] on Windows. */
c8e22ee @akr * eval_intern.h: parenthesize macro arguments.
akr authored
218 #define CharNext(p) ((p) + mblen((p), RUBY_MBCHAR_MAXSIZE))
f35308b @nobu * eval_intern.h (translit_char): moved from ruby.c.
nobu authored
219 #endif
220
221 #if defined DOSISH || defined __CYGWIN__
222 static inline void
223 translit_char(char *p, int from, int to)
224 {
225 while (*p) {
226 if ((unsigned char)*p == from)
227 *p = to;
228 p = CharNext(p);
229 }
230 }
231 #endif
232
8a9993d @nobu * eval_intern.h, insnhelper.h, thread_pthread.h, vm_core.h, vm_opts.h:
nobu authored
233 #endif /* RUBY_EVAL_INTERN_H */
Something went wrong with that request. Please try again.