2 #ifndef RUBY_EVAL_INTERN_H
3 #define RUBY_EVAL_INTERN_H
5 #define PASS_PASSED_BLOCK_TH(th) do { \
6 (th)->passed_block = GC_GUARDED_PTR_REF((rb_block_t *)(th)->cfp->lfp[0]); \
7 (th)->cfp->flag |= VM_FRAME_FLAG_PASSED; \
10 #define PASS_PASSED_BLOCK() do { \
11 rb_thread_t * const __th__ = GET_THREAD(); \
12 PASS_PASSED_BLOCK_TH(__th__); \
15 #include "ruby/ruby.h"
16 #include "ruby/node.h"
17 #include "ruby/util.h"
18 #include "ruby/signal.h"
25 #define EXIT_SUCCESS 0
28 #define EXIT_FAILURE 1
38 #include <crt_externs.h>
41 /* Make alloca work the best possible way. */
45 # define alloca __builtin_alloca
55 # ifndef alloca /* predefined by HP cc +Olibcalls */
59 # endif /* HAVE_ALLOCA_H */
62 #ifdef HAVE_STDARG_PROTOTYPES
64 #define va_init_list(a,b) va_start(a,b)
67 #define va_init_list(a,b) va_start(a)
71 char *strrchr(const char *, const char);
78 #ifdef HAVE_NET_SOCKET_H
79 #include <net/socket.h>
83 #include "macruby_private.h"
87 #include "vmsruby_private.h"
90 #define ruby_setjmp(env) RUBY_SETJMP(env)
91 #define ruby_longjmp(env,val) RUBY_LONGJMP(env,val)
93 int _setjmp(), _longjmp();
96 #include <sys/types.h>
104 #ifdef HAVE_SYS_SELECT_H
105 #include <sys/select.h>
109 Solaris sys/select.h switches select to select_large_fdset to support larger
110 file descriptors if FD_SETSIZE is larger than 1024 on 32bit environment.
111 But Ruby doesn't change FD_SETSIZE because fd_set is allocated dynamically.
112 So following definition is required to use select_large_fdset.
114 #ifdef HAVE_SELECT_LARGE_FDSET
115 #define select(n, r, w, e, t) select_large_fdset(n, r, w, e, t)
118 #ifdef HAVE_SYS_PARAM_H
119 #include <sys/param.h>
122 #include <sys/stat.h>
124 #define SAVE_ROOT_JMPBUF(th, stmt) do \
125 if (ruby_setjmp((th)->root_jmpbuf) == 0) { \
132 #define TH_PUSH_TAG(th) do { \
133 rb_thread_t * const _th = th; \
134 struct rb_vm_tag _tag; \
136 _tag.prev = _th->tag; \
139 #define TH_POP_TAG() \
140 _th->tag = _tag.prev; \
143 #define TH_POP_TAG2() \
146 #define PUSH_TAG() TH_PUSH_TAG(GET_THREAD())
147 #define POP_TAG() TH_POP_TAG()
149 #define TH_EXEC_TAG() ruby_setjmp(_th->tag->buf)
154 #define TH_JUMP_TAG(th, st) do { \
155 ruby_longjmp(th->tag->buf,(st)); \
158 #define JUMP_TAG(st) TH_JUMP_TAG(GET_THREAD(), st)
161 RUBY_TAG_RETURN
= 0x1,
162 RUBY_TAG_BREAK
= 0x2,
164 RUBY_TAG_RETRY
= 0x4,
166 RUBY_TAG_RAISE
= 0x6,
167 RUBY_TAG_THROW
= 0x7,
168 RUBY_TAG_FATAL
= 0x8,
171 #define TAG_RETURN RUBY_TAG_RETURN
172 #define TAG_BREAK RUBY_TAG_BREAK
173 #define TAG_NEXT RUBY_TAG_NEXT
174 #define TAG_RETRY RUBY_TAG_RETRY
175 #define TAG_REDO RUBY_TAG_REDO
176 #define TAG_RAISE RUBY_TAG_RAISE
177 #define TAG_THROW RUBY_TAG_THROW
178 #define TAG_FATAL RUBY_TAG_FATAL
179 #define TAG_MASK RUBY_TAG_MASK
181 #define NEW_THROW_OBJECT(val, pt, st) \
182 ((VALUE)NEW_NODE(NODE_LIT, (val), (pt), (st)))
183 #define SET_THROWOBJ_CATCH_POINT(obj, val) \
184 (RNODE((obj))->u2.value = (val))
185 #define SET_THROWOBJ_STATE(obj, val) \
186 (RNODE((obj))->u3.value = (val))
188 #define GET_THROWOBJ_VAL(obj) ((VALUE)RNODE((obj))->u1.value)
189 #define GET_THROWOBJ_CATCH_POINT(obj) ((VALUE*)RNODE((obj))->u2.value)
190 #define GET_THROWOBJ_STATE(obj) ((int)RNODE((obj))->u3.value)
192 #define SCOPE_TEST(f) (vm_cref()->nd_visi & (f))
193 #define SCOPE_CHECK(f) (vm_cref()->nd_visi == (f))
194 #define SCOPE_SET(f) (vm_cref()->nd_visi = (f))
196 #define CHECK_STACK_OVERFLOW(cfp, margin) do \
197 if (((VALUE *)(cfp)->sp) + (margin) + sizeof(rb_control_frame_t) >= ((VALUE *)cfp)) { \
198 rb_exc_raise(sysstack_error); \
202 void rb_thread_cleanup(void);
203 void rb_thread_wait_other_threads(void);
206 RAISED_EXCEPTION
= 1,
207 RAISED_STACKOVERFLOW
= 2,
210 int rb_thread_set_raised(rb_thread_t
*th
);
211 int rb_thread_reset_raised(rb_thread_t
*th
);
212 #define rb_thread_raised_set(th, f) ((th)->raised_flag |= (f))
213 #define rb_thread_raised_reset(th, f) ((th)->raised_flag &= ~(f))
214 #define rb_thread_raised_p(th, f) (((th)->raised_flag & (f)) != 0)
215 #define rb_thread_raised_clear(th) ((th)->raised_flag = 0)
217 VALUE
rb_f_eval(int argc
, VALUE
*argv
, VALUE self
);
218 VALUE
rb_make_exception(int argc
, VALUE
*argv
);
220 NORETURN(void rb_fiber_start(void));
222 NORETURN(void rb_print_undef(VALUE
, ID
, int));
223 NORETURN(void vm_localjump_error(const char *,VALUE
, int));
224 NORETURN(void vm_jump_tag_but_local_jump(int, VALUE
));
226 VALUE
vm_make_jump_tag_but_local_jump(int state
, VALUE val
);
228 rb_control_frame_t
*vm_get_ruby_level_caller_cfp(rb_thread_t
*th
, rb_control_frame_t
*cfp
);
229 VALUE
rb_obj_is_proc(VALUE
);
230 VALUE
rb_vm_call_cfunc(VALUE recv
, VALUE (*func
)(VALUE
), VALUE arg
, const rb_block_t
*blockptr
, VALUE filename
);
231 void rb_thread_terminate_all(void);
232 VALUE
rb_vm_top_self();
233 VALUE
rb_vm_cbase(void);
235 #endif /* RUBY_EVAL_INTERN_H */