aboutsummaryrefslogtreecommitdiffstats
path: root/node.h
diff options
context:
space:
mode:
authorwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-23 21:29:47 +0000
committerwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-23 21:29:47 +0000
commitdcb6131f78704196e749125c8877e63061180542 (patch)
treed4622329f0af807a8aed99679a848c6f6e6a8dad /node.h
parent9911bca1e2774c959993093814c46f05b3c8b7ff (diff)
downloadruby-dcb6131f78704196e749125c8877e63061180542.tar.gz
* eval.c (rb_thread_save_context, rb_thread_restore_context):
sandbox hook to save and restore sandbox state. * eval.c (thread_no_ensure): added THREAD_NO_ENSURE thread flag. * eval.c (rb_thread_kill_bang): Thread#kill! uses the above flag to circumvent ensure, in order to prevent endless loops. contributed by MenTaLguY. [ruby-core:08768] * eval.c (rb_thread_kill): fix Thread#kill docs, which returns the thread object in all cases. * node.h: expose the rb_jmpbuf_t and rb_thread_t structs, along with the thread flags. used by the sandbox extension. * ruby.h: extern rb_eThreadError, so sandbox can swap it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'node.h')
-rw-r--r--node.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/node.h b/node.h
index 46332ca7bf..c08ad33d1b 100644
--- a/node.h
+++ b/node.h
@@ -393,6 +393,99 @@ typedef void (*rb_event_hook_func_t)(rb_event_t,NODE*,VALUE,ID,VALUE);
void rb_add_event_hook(rb_event_hook_func_t,rb_event_t);
int rb_remove_event_hook(rb_event_hook_func_t);
+#if defined(HAVE_GETCONTEXT) && defined(HAVE_SETCONTEXT)
+#include <ucontext.h>
+#define USE_CONTEXT
+#endif
+#include <setjmp.h>
+#include "st.h"
+
+#ifdef USE_CONTEXT
+typedef struct {
+ ucontext_t context;
+ volatile int status;
+} rb_jmpbuf_t[1];
+#else
+typedef jmp_buf rb_jmpbuf_t;
+#endif
+
+enum thread_status {
+ THREAD_TO_KILL,
+ THREAD_RUNNABLE,
+ THREAD_STOPPED,
+ THREAD_KILLED,
+};
+
+typedef struct thread * rb_thread_t;
+
+struct thread {
+ struct thread *next, *prev;
+ rb_jmpbuf_t context;
+#ifdef SAVE_WIN32_EXCEPTION_LIST
+ DWORD win32_exception_list;
+#endif
+
+ VALUE result;
+
+ long stk_len;
+ long stk_max;
+ VALUE *stk_ptr;
+ VALUE *stk_pos;
+#ifdef __ia64
+ long bstr_len;
+ long bstr_max;
+ VALUE *bstr_ptr;
+ VALUE *bstr_pos;
+#endif
+
+ struct FRAME *frame;
+ struct SCOPE *scope;
+ struct RVarmap *dyna_vars;
+ struct BLOCK *block;
+ struct iter *iter;
+ struct tag *tag;
+ VALUE wrapper;
+ NODE *cref;
+ struct ruby_env *anchor;
+
+ int flags; /* misc. states (rb_trap_immediate/raised) */
+
+ NODE *node;
+
+ int tracing;
+ VALUE errinfo;
+ VALUE last_status;
+ VALUE last_line;
+ VALUE last_match;
+
+ int safe;
+
+ enum thread_status status;
+ int wait_for;
+ int fd;
+ rb_fdset_t readfds;
+ rb_fdset_t writefds;
+ rb_fdset_t exceptfds;
+ int select_value;
+ double delay;
+ rb_thread_t join;
+
+ int abort;
+ int priority;
+ VALUE thgroup;
+
+ st_table *locals;
+
+ VALUE thread;
+
+ VALUE sandbox;
+};
+
+extern VALUE (*ruby_sandbox_save)(struct thread *);
+extern VALUE (*ruby_sandbox_restore)(struct thread *);
+extern rb_thread_t curr_thread;
+extern rb_thread_t main_thread;
+
#if defined(__cplusplus)
} /* extern "C" { */
#endif