(linenum→info "unix/slp.c:2238")

ruby/1.9.0/eval_intern.h

    1: 
    2: #ifndef EVAL_INTERN_H_INCLUDED
    3: #define EVAL_INTERN_H_INCLUDED
    4: 
    5: #define PASS_PASSED_BLOCK() \
    6:   (GET_THREAD()->passed_block = \
    7:    GC_GUARDED_PTR_REF((rb_block_t *)GET_THREAD()->cfp->lfp[0]))
    8: 
    9: #include "ruby/ruby.h"
   10: #include "ruby/node.h"
   11: #include "ruby/util.h"
   12: #include "ruby/signal.h"
   13: #include "vm_core.h"
   14: 
   15: #ifdef HAVE_STDLIB_H
   16: #include <stdlib.h>
   17: #endif
   18: #ifndef EXIT_SUCCESS
   19: #define EXIT_SUCCESS 0
   20: #endif
   21: #ifndef EXIT_FAILURE
   22: #define EXIT_FAILURE 1
   23: #endif
   24: 
   25: #include <stdio.h>
   26: #include <setjmp.h>
   27: 
   28: #include "ruby/st.h"
   29: #include "dln.h"
   30: 
   31: #ifdef __APPLE__
   32: #include <crt_externs.h>
   33: #endif
   34: 
   35: /* Make alloca work the best possible way.  */
   36: #ifdef __GNUC__
   37: # ifndef atarist
   38: #  ifndef alloca
   39: #   define alloca __builtin_alloca
   40: #  endif
   41: # endif /* atarist */
   42: #else
   43: # ifdef HAVE_ALLOCA_H
   44: #  include <alloca.h>
   45: # else
   46: #  ifdef _AIX
   47: #pragma alloca
   48: #  else
   49: #   ifndef alloca               /* predefined by HP cc +Olibcalls */
   50: void *alloca();
   51: #   endif
   52: #  endif /* AIX */
   53: # endif /* HAVE_ALLOCA_H */
   54: #endif /* __GNUC__ */
   55: 
   56: #ifdef HAVE_STDARG_PROTOTYPES
   57: #include <stdarg.h>
   58: #define va_init_list(a,b) va_start(a,b)
   59: #else
   60: #include <varargs.h>
   61: #define va_init_list(a,b) va_start(a)
   62: #endif
   63: 
   64: #ifndef HAVE_STRING_H
   65: char *strrchr(const char *, const char);
   66: #endif
   67: 
   68: #ifdef HAVE_UNISTD_H
   69: #include <unistd.h>
   70: #endif
   71: 
   72: #ifdef __BEOS__
   73: #include <net/socket.h>
   74: #endif
   75: 
   76: #ifdef __MACOS__
   77: #include "macruby_private.h"
   78: #endif
   79: 
   80: #ifdef __VMS
   81: #include "vmsruby_private.h"
   82: #endif
   83: 
   84: #if !defined(setjmp) && defined(HAVE__SETJMP)
   85: #define ruby_setjmp(env) _setjmp(env)
   86: #define ruby_longjmp(env,val) _longjmp(env,val)
   87: #else
   88: #define ruby_setjmp(env) setjmp(env)
   89: #define ruby_longjmp(env,val) longjmp(env,val)
   90: #endif
   91: 
   92: #include <sys/types.h>
   93: #include <signal.h>
   94: #include <errno.h>
   95: 
   96: #if defined(__VMS)
   97: #pragma nostandard
   98: #endif
   99: 
  100: #ifdef HAVE_SYS_SELECT_H
  101: #include <sys/select.h>
  102: #endif
  103: 
  104: /*
  105:   Solaris sys/select.h switches select to select_large_fdset to support larger
  106:   file descriptors if FD_SETSIZE is larger than 1024 on 32bit environment.
  107:   But Ruby doesn't change FD_SETSIZE because fd_set is allocated dynamically.
  108:   So following definition is required to use select_large_fdset.
  109: */
  110: #ifdef HAVE_SELECT_LARGE_FDSET
  111: #define select(n, r, w, e, t) select_large_fdset(n, r, w, e, t)
  112: #endif
  113: 
  114: #ifdef HAVE_SYS_PARAM_H
  115: #include <sys/param.h>
  116: #endif
  117: 
  118: #include <sys/stat.h>
  119: 
  120: #define SAVE_ROOT_JMPBUF(th, stmt) do \
  121:   if (ruby_setjmp((th)->root_jmpbuf) == 0) { \
  122:       stmt; \
  123:   } \
  124:   else { \
  125:       rb_fiber_start(); \
  126:   } while (0)
  127: 
  128: #define TH_PUSH_TAG(th) do { \
  129:   rb_thread_t * const _th = th; \
  130:   struct rb_vm_tag _tag; \
  131:   _tag.tag = 0; \
  132:   _tag.prev = _th->tag; \
  133:   _th->tag = &_tag;
  134: 
  135: #define TH_POP_TAG() \
  136:   _th->tag = _tag.prev; \
  137: } while (0)
  138: 
  139: #define TH_POP_TAG2() \
  140:   _th->tag = _tag.prev
  141: 
  142: #define PUSH_TAG() TH_PUSH_TAG(GET_THREAD())
  143: #define POP_TAG()      TH_POP_TAG()
  144: 
  145: #define TH_EXEC_TAG() \
  146:   (FLUSH_REGISTER_WINDOWS, ruby_setjmp(_th->tag->buf))
  147: 
  148: #define EXEC_TAG() \
  149:   TH_EXEC_TAG()
  150: 
  151: #define TH_JUMP_TAG(th, st) do { \
  152:   ruby_longjmp(th->tag->buf,(st)); \
  153: } while (0)
  154: 
  155: #define JUMP_TAG(st) TH_JUMP_TAG(GET_THREAD(), st)
  156: 
  157: #define TAG_RETURN      0x1
  158: #define TAG_BREAK       0x2
  159: #define TAG_NEXT        0x3
  160: #define TAG_RETRY       0x4
  161: #define TAG_REDO        0x5
  162: #define TAG_RAISE       0x6
  163: #define TAG_THROW       0x7
  164: #define TAG_FATAL       0x8
  165: #define TAG_MASK        0xf
  166: 
  167: #define NEW_THROW_OBJECT(val, pt, st) \
  168:   ((VALUE)NEW_NODE(NODE_LIT, (val), (pt), (st)))
  169: #define SET_THROWOBJ_CATCH_POINT(obj, val) \
  170:   (RNODE((obj))->u2.value = (val))
  171: #define SET_THROWOBJ_STATE(obj, val) \
  172:   (RNODE((obj))->u3.value = (val))
  173: 
  174: #define GET_THROWOBJ_VAL(obj)         ((VALUE)RNODE((obj))->u1.value)
  175: #define GET_THROWOBJ_CATCH_POINT(obj) ((VALUE*)RNODE((obj))->u2.value)
  176: #define GET_THROWOBJ_STATE(obj)       ((int)RNODE((obj))->u3.value)
  177: 
  178: #define SCOPE_TEST(f) \
  179:   (ruby_cref()->nd_visi & (f))
  180: 
  181: #define SCOPE_CHECK(f) \
  182:   (ruby_cref()->nd_visi == (f))
  183: 
  184: #define SCOPE_SET(f)  \
  185: { \
  186:   ruby_cref()->nd_visi = (f); \
  187: }
  188: 
  189: #define CHECK_STACK_OVERFLOW(cfp, margin) do \
  190:   if (((VALUE *)(cfp)->sp) + (margin) + sizeof(rb_control_frame_t) >= ((VALUE *)cfp)) { \
  191:       rb_exc_raise(sysstack_error); \
  192:   } \
  193: while (0)
  194: 
  195: void rb_thread_cleanup(void);
  196: void rb_thread_wait_other_threads(void);
  197: 
  198: int thread_set_raised(rb_thread_t *th);
  199: int thread_reset_raised(rb_thread_t *th);
  200: 
  201: VALUE rb_f_eval(int argc, VALUE *argv, VALUE self);
  202: VALUE rb_make_exception(int argc, VALUE *argv);
  203: 
  204: NORETURN(void rb_fiber_start(void));
  205: 
  206: NORETURN(void rb_raise_jump(VALUE));
  207: NORETURN(void rb_print_undef(VALUE, ID, int));
  208: NORETURN(void vm_localjump_error(const char *, VALUE, int));
  209: NORETURN(void vm_jump_tag_but_local_jump(int, VALUE));
  210: 
  211: NODE *vm_get_cref(rb_thread_t *th, rb_iseq_t *iseq, rb_control_frame_t *cfp);
  212: NODE *vm_cref_push(rb_thread_t *th, VALUE, int);
  213: NODE *vm_set_special_cref(rb_thread_t *th, VALUE *lfp, NODE * cref_stack);
  214: VALUE vm_make_jump_tag_but_local_jump(int state, VALUE val);
  215: 
  216: static rb_control_frame_t *
  217: vm_get_ruby_level_cfp(rb_thread_t *th, rb_control_frame_t *cfp)
  218: {
  219:     while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) {
  220:         if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) {
  221:             return cfp;
  222:         }
  223:         cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
  224:     }
  225:     return 0;
  226: }
  227: 
  228: static inline NODE *
  229: ruby_cref()
  230: {
  231:     rb_thread_t *th = GET_THREAD();
  232:     rb_control_frame_t *cfp = vm_get_ruby_level_cfp(th, th->cfp);
  233:     return vm_get_cref(th, cfp->iseq, cfp);
  234: }
  235: 
  236: VALUE vm_get_cbase(rb_thread_t *th);
  237: VALUE rb_obj_is_proc(VALUE);
  238: void rb_vm_check_redefinition_opt_method(NODE *node);
  239: VALUE rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, rb_block_t *blockptr, VALUE filename);
  240: void rb_thread_terminate_all(void);
  241: void rb_vm_set_eval_stack(rb_thread_t *, VALUE iseq);
  242: VALUE rb_vm_top_self();
  243: 
  244: #define ruby_cbase() vm_get_cbase(GET_THREAD())
  245: 
  246: #endif /* EVAL_INTERN_H_INCLUDED */
Syntax (Markdown)