aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--eval.c4
-rw-r--r--eval_error.c4
-rw-r--r--eval_intern.h4
-rw-r--r--include/ruby/intern.h2
-rw-r--r--signal.c4
-rw-r--r--thread.c95
-rw-r--r--version.h4
-rw-r--r--vm_core.h6
9 files changed, 86 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index 4fb2400c27..0f612c213d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+Tue Jun 9 01:07:33 2009 Koichi Sasada <ko1@atdot.net>
+
+ * thread.c: rename functions which require a parameter
+ "rb_thread_t *", the prefix to be rb_threadptr_ instead of
+ rb_thread_.
+
+ * thread.c (rb_thread_add_event_hook(), rb_thread_remove_event_hook):
+ change the parameter type from rb_thread_t * to VALUE.
+
+ * eval.c, eval_error.c, eval_intern.h, signal.c, vm_core.h, vm_eval.c:
+ ditto.
+
+ * include/ruby/intern.h: remove decl of rb_thread_signal_raise() and
+ rb_thread_signal_exit().
+
Mon Jun 8 05:07:41 2009 Koichi Sasada <ko1@atdot.net>
* thread_pthread.c (rb_thread_create_timer_thread): print fatal error
diff --git a/eval.c b/eval.c
index 1d5345f0a4..a877c2b99c 100644
--- a/eval.c
+++ b/eval.c
@@ -341,7 +341,7 @@ rb_longjmp(int tag, volatile VALUE mesg)
const char *file;
volatile int line = 0;
- if (rb_thread_set_raised(th)) {
+ if (rb_threadptr_set_raised(th)) {
th->errinfo = exception_error;
JUMP_TAG(TAG_FATAL);
}
@@ -391,7 +391,7 @@ rb_longjmp(int tag, volatile VALUE mesg)
th->errinfo = mesg;
}
else if (status) {
- rb_thread_reset_raised(th);
+ rb_threadptr_reset_raised(th);
JUMP_TAG(status);
}
}
diff --git a/eval_error.c b/eval_error.c
index ce6bd234f1..85e55ad3c8 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -215,7 +215,7 @@ error_handle(int ex)
int status = EXIT_FAILURE;
rb_thread_t *th = GET_THREAD();
- if (rb_thread_set_raised(th))
+ if (rb_threadptr_set_raised(th))
return EXIT_FAILURE;
switch (ex & TAG_MASK) {
case 0:
@@ -267,6 +267,6 @@ error_handle(int ex)
rb_bug("Unknown longjmp status %d", ex);
break;
}
- rb_thread_reset_raised(th);
+ rb_threadptr_reset_raised(th);
return status;
}
diff --git a/eval_intern.h b/eval_intern.h
index 09ecf44312..573f49751b 100644
--- a/eval_intern.h
+++ b/eval_intern.h
@@ -185,8 +185,8 @@ enum {
RAISED_STACKOVERFLOW = 2,
RAISED_NOMEMORY = 4
};
-int rb_thread_set_raised(rb_thread_t *th);
-int rb_thread_reset_raised(rb_thread_t *th);
+int rb_threadptr_set_raised(rb_thread_t *th);
+int rb_threadptr_reset_raised(rb_thread_t *th);
#define rb_thread_raised_set(th, f) ((th)->raised_flag |= (f))
#define rb_thread_raised_reset(th, f) ((th)->raised_flag &= ~(f))
#define rb_thread_raised_p(th, f) (((th)->raised_flag & (f)) != 0)
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 08229f589d..d35279aa24 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -328,8 +328,6 @@ VALUE rb_thread_wakeup(VALUE);
VALUE rb_thread_run(VALUE);
VALUE rb_thread_kill(VALUE);
VALUE rb_thread_create(VALUE (*)(ANYARGS), void*);
-void rb_thread_signal_raise(void *, int);
-void rb_thread_signal_exit(void *);
int rb_thread_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
int rb_thread_fd_select(int, rb_fdset_t *, rb_fdset_t *, rb_fdset_t *, struct timeval *);
void rb_thread_wait_for(struct timeval);
diff --git a/signal.c b/signal.c
index 7c9dda465d..b1773bc4d5 100644
--- a/signal.c
+++ b/signal.c
@@ -664,12 +664,12 @@ rb_signal_exec(rb_thread_t *th, int sig)
#ifdef SIGUSR2
case SIGUSR2:
#endif
- rb_thread_signal_raise(th, sig);
+ rb_threadptr_signal_raise(th, sig);
break;
}
}
else if (cmd == Qundef) {
- rb_thread_signal_exit(th);
+ rb_threadptr_signal_exit(th);
}
else {
signal_exec(cmd, safe, sig);
diff --git a/thread.c b/thread.c
index d2eeca32e6..573ace640c 100644
--- a/thread.c
+++ b/thread.c
@@ -65,7 +65,7 @@ static void sleep_wait_for_interrupt(rb_thread_t *th, double sleepsec);
static void sleep_forever(rb_thread_t *th, int nodeadlock);
static double timeofday(void);
struct timeval rb_time_interval(VALUE);
-static int rb_thread_dead(rb_thread_t *th);
+static int rb_threadptr_dead(rb_thread_t *th);
static void rb_check_deadlock(rb_vm_t *vm);
@@ -249,7 +249,7 @@ reset_unblock_function(rb_thread_t *th, const struct rb_unblock_callback *old)
}
static void
-rb_thread_interrupt(rb_thread_t *th)
+rb_threadptr_interrupt(rb_thread_t *th)
{
native_mutex_lock(&th->interrupt_lock);
RUBY_VM_SET_INTERRUPT(th);
@@ -272,7 +272,7 @@ terminate_i(st_data_t key, st_data_t val, rb_thread_t *main_thread)
if (th != main_thread) {
thread_debug("terminate_i: %p\n", (void *)th);
- rb_thread_interrupt(th);
+ rb_threadptr_interrupt(th);
th->thrown_errinfo = eTerminateSignal;
th->status = THREAD_TO_KILL;
}
@@ -350,7 +350,7 @@ thread_cleanup_func(void *th_ptr)
}
extern void ruby_error_print(void);
-static VALUE rb_thread_raise(int, VALUE *, rb_thread_t *);
+static VALUE rb_threadptr_raise(rb_thread_t *, int, VALUE *);
void rb_thread_recycle_stack_release(VALUE *);
void
@@ -429,7 +429,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
if (th != main_th) {
if (TYPE(errinfo) == T_OBJECT) {
/* treat with normal error object */
- rb_thread_raise(1, &errinfo, main_th);
+ rb_threadptr_raise(main_th, 1, &errinfo);
}
}
TH_POP_TAG();
@@ -449,7 +449,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
join_th = th->join_list_head;
while (join_th) {
if (join_th == main_th) errinfo = Qnil;
- rb_thread_interrupt(join_th);
+ rb_threadptr_interrupt(join_th);
switch (join_th->status) {
case THREAD_STOPPED: case THREAD_STOPPED_FOREVER:
join_th->status = THREAD_RUNNABLE;
@@ -1180,7 +1180,7 @@ thread_s_pass(VALUE klass)
*/
void
-rb_thread_execute_interrupts(rb_thread_t *th)
+rb_threadptr_execute_interrupts(rb_thread_t *th)
{
if (GET_VM()->main_thread == th) {
while (rb_signal_buff_size() && !th->exec_signal) native_thread_yield();
@@ -1254,18 +1254,18 @@ rb_gc_mark_threads(void)
/*****************************************************/
static void
-rb_thread_ready(rb_thread_t *th)
+rb_threadptr_ready(rb_thread_t *th)
{
- rb_thread_interrupt(th);
+ rb_threadptr_interrupt(th);
}
static VALUE
-rb_thread_raise(int argc, VALUE *argv, rb_thread_t *th)
+rb_threadptr_raise(rb_thread_t *th, int argc, VALUE *argv)
{
VALUE exc;
again:
- if (rb_thread_dead(th)) {
+ if (rb_threadptr_dead(th)) {
return Qnil;
}
@@ -1276,30 +1276,28 @@ rb_thread_raise(int argc, VALUE *argv, rb_thread_t *th)
exc = rb_make_exception(argc, argv);
th->thrown_errinfo = exc;
- rb_thread_ready(th);
+ rb_threadptr_ready(th);
return Qnil;
}
void
-rb_thread_signal_raise(void *thptr, int sig)
+rb_threadptr_signal_raise(rb_thread_t *th, int sig)
{
VALUE argv[2];
- rb_thread_t *th = thptr;
argv[0] = rb_eSignal;
argv[1] = INT2FIX(sig);
- rb_thread_raise(2, argv, th->vm->main_thread);
+ rb_threadptr_raise(th->vm->main_thread, 2, argv);
}
void
-rb_thread_signal_exit(void *thptr)
+rb_threadptr_signal_exit(rb_thread_t *th)
{
VALUE argv[2];
- rb_thread_t *th = thptr;
argv[0] = rb_eSystemExit;
argv[1] = rb_str_new2("exit");
- rb_thread_raise(2, argv, th->vm->main_thread);
+ rb_threadptr_raise(th->vm->main_thread, 2, argv);
}
void
@@ -1311,7 +1309,7 @@ ruby_thread_stack_overflow(rb_thread_t *th)
}
int
-rb_thread_set_raised(rb_thread_t *th)
+rb_threadptr_set_raised(rb_thread_t *th)
{
if (th->raised_flag & RAISED_EXCEPTION) {
return 1;
@@ -1321,7 +1319,7 @@ rb_thread_set_raised(rb_thread_t *th)
}
int
-rb_thread_reset_raised(rb_thread_t *th)
+rb_threadptr_reset_raised(rb_thread_t *th)
{
if (!(th->raised_flag & RAISED_EXCEPTION)) {
return 0;
@@ -1360,7 +1358,7 @@ thread_raise_m(int argc, VALUE *argv, VALUE self)
{
rb_thread_t *th;
GetThreadPtr(self, th);
- rb_thread_raise(argc, argv, th);
+ rb_threadptr_raise(th, argc, argv);
return Qnil;
}
@@ -1396,7 +1394,7 @@ rb_thread_kill(VALUE thread)
thread_debug("rb_thread_kill: %p (%p)\n", (void *)th, (void *)th->thread_id);
- rb_thread_interrupt(th);
+ rb_threadptr_interrupt(th);
th->thrown_errinfo = eKillSignal;
th->status = THREAD_TO_KILL;
@@ -1466,7 +1464,7 @@ rb_thread_wakeup(VALUE thread)
if (th->status == THREAD_KILLED) {
rb_raise(rb_eThreadError, "killed thread");
}
- rb_thread_ready(th);
+ rb_threadptr_ready(th);
if (th->status != THREAD_TO_KILL) {
th->status = THREAD_RUNNABLE;
}
@@ -1748,7 +1746,7 @@ thread_status_name(enum rb_thread_status status)
}
static int
-rb_thread_dead(rb_thread_t *th)
+rb_threadptr_dead(rb_thread_t *th)
{
return th->status == THREAD_KILLED;
}
@@ -1782,7 +1780,7 @@ rb_thread_status(VALUE thread)
rb_thread_t *th;
GetThreadPtr(thread, th);
- if (rb_thread_dead(th)) {
+ if (rb_threadptr_dead(th)) {
if (!NIL_P(th->errinfo) && !FIXNUM_P(th->errinfo)
/* TODO */ ) {
return Qnil;
@@ -1811,7 +1809,7 @@ rb_thread_alive_p(VALUE thread)
rb_thread_t *th;
GetThreadPtr(thread, th);
- if (rb_thread_dead(th))
+ if (rb_threadptr_dead(th))
return Qfalse;
return Qtrue;
}
@@ -1834,7 +1832,7 @@ rb_thread_stop_p(VALUE thread)
rb_thread_t *th;
GetThreadPtr(thread, th);
- if (rb_thread_dead(th))
+ if (rb_threadptr_dead(th))
return Qtrue;
if (th->status == THREAD_STOPPED || th->status == THREAD_STOPPED_FOREVER)
return Qtrue;
@@ -2569,7 +2567,7 @@ timer_thread_function(void *arg)
thread_status_name(prev_status), sig);
mth->exec_signal = sig;
if (mth->status != THREAD_KILLED) mth->status = THREAD_RUNNABLE;
- rb_thread_interrupt(mth);
+ rb_threadptr_interrupt(mth);
mth->status = prev_status;
}
@@ -3474,8 +3472,8 @@ thread_reset_event_flags(rb_thread_t *th)
}
}
-void
-rb_thread_add_event_hook(rb_thread_t *th,
+static void
+rb_threadptr_add_event_hook(rb_thread_t *th,
rb_event_hook_func_t func, rb_event_flag_t events, VALUE data)
{
rb_event_hook_t *hook = alloc_event_hook(func, events, data);
@@ -3484,6 +3482,21 @@ rb_thread_add_event_hook(rb_thread_t *th,
thread_reset_event_flags(th);
}
+static rb_thread_t *
+thval2thread_t(VALUE thval)
+{
+ rb_thread_t *th;
+ GetThreadPtr(thval, th);
+ return th;
+}
+
+void
+rb_thread_add_event_hook(VALUE thval,
+ rb_event_hook_func_t func, rb_event_flag_t events, VALUE data)
+{
+ rb_threadptr_add_event_hook(thval2thread_t(thval), func, events, data);
+}
+
static int
set_threads_event_flags_i(st_data_t key, st_data_t val, st_data_t flag)
{
@@ -3542,8 +3555,8 @@ remove_event_hook(rb_event_hook_t **root, rb_event_hook_func_t func)
return -1;
}
-int
-rb_thread_remove_event_hook(rb_thread_t *th, rb_event_hook_func_t func)
+static int
+rb_threadptr_revmove_event_hook(rb_thread_t *th, rb_event_hook_func_t func)
{
int ret = remove_event_hook(&th->event_hooks, func);
thread_reset_event_flags(th);
@@ -3551,6 +3564,12 @@ rb_thread_remove_event_hook(rb_thread_t *th, rb_event_hook_func_t func)
}
int
+rb_thread_remove_event_hook(VALUE thval, rb_event_hook_func_t func)
+{
+ return rb_threadptr_revmove_event_hook(thval2thread_t(thval), func);
+}
+
+int
rb_remove_event_hook(rb_event_hook_func_t func)
{
rb_vm_t *vm = GET_VM();
@@ -3569,7 +3588,7 @@ clear_trace_func_i(st_data_t key, st_data_t val, st_data_t flag)
{
rb_thread_t *th;
GetThreadPtr((VALUE)key, th);
- rb_thread_remove_event_hook(th, 0);
+ rb_threadptr_revmove_event_hook(th, 0);
return ST_CONTINUE;
}
@@ -3649,7 +3668,7 @@ thread_add_trace_func(rb_thread_t *th, VALUE trace)
rb_raise(rb_eTypeError, "trace_func needs to be Proc");
}
- rb_thread_add_event_hook(th, call_trace_func, RUBY_EVENT_ALL, trace);
+ rb_threadptr_add_event_hook(th, call_trace_func, RUBY_EVENT_ALL, trace);
}
static VALUE
@@ -3666,7 +3685,7 @@ thread_set_trace_func_m(VALUE obj, VALUE trace)
{
rb_thread_t *th;
GetThreadPtr(obj, th);
- rb_thread_remove_event_hook(th, call_trace_func);
+ rb_threadptr_revmove_event_hook(th, call_trace_func);
if (NIL_P(trace)) {
return Qnil;
@@ -3778,7 +3797,7 @@ ruby_suppress_tracing(VALUE (*func)(VALUE, int), VALUE arg, int always)
th->tracing = 1;
}
- raised = rb_thread_reset_raised(th);
+ raised = rb_threadptr_reset_raised(th);
PUSH_TAG();
if ((state = EXEC_TAG()) == 0) {
@@ -3786,7 +3805,7 @@ ruby_suppress_tracing(VALUE (*func)(VALUE, int), VALUE arg, int always)
}
if (raised) {
- rb_thread_set_raised(th);
+ rb_threadptr_set_raised(th);
}
POP_TAG();
@@ -3979,7 +3998,7 @@ rb_check_deadlock(rb_vm_t *vm)
printf("%d %d %p %p\n", vm->living_threads->num_entries, vm->sleeper, GET_THREAD(), vm->main_thread);
st_foreach(vm->living_threads, debug_i, (st_data_t)0);
#endif
- rb_thread_raise(2, argv, vm->main_thread);
+ rb_threadptr_raise(vm->main_thread, 2, argv);
}
}
diff --git a/version.h b/version.h
index 2941fb196a..c978e138b6 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.2"
-#define RUBY_RELEASE_DATE "2009-06-08"
+#define RUBY_RELEASE_DATE "2009-06-09"
#define RUBY_PATCHLEVEL -1
#define RUBY_BRANCH_NAME "trunk"
@@ -8,7 +8,7 @@
#define RUBY_VERSION_TEENY 1
#define RUBY_RELEASE_YEAR 2009
#define RUBY_RELEASE_MONTH 6
-#define RUBY_RELEASE_DAY 8
+#define RUBY_RELEASE_DAY 9
#include "ruby/version.h"
diff --git a/vm_core.h b/vm_core.h
index ed963922ea..ad9183e27e 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -625,11 +625,13 @@ extern rb_vm_t *ruby_current_vm;
#define RUBY_VM_SET_FINALIZER_INTERRUPT(th) ((th)->interrupt_flag |= 0x04)
#define RUBY_VM_INTERRUPTED(th) ((th)->interrupt_flag & 0x02)
-void rb_thread_execute_interrupts(rb_thread_t *);
+void rb_threadptr_signal_raise(rb_thread_t *th, int sig);
+void rb_threadptr_signal_exit(rb_thread_t *th);
+void rb_threadptr_execute_interrupts(rb_thread_t *);
#define RUBY_VM_CHECK_INTS_TH(th) do { \
if (UNLIKELY(th->interrupt_flag)) { \
- rb_thread_execute_interrupts(th); \
+ rb_threadptr_execute_interrupts(th); \
} \
} while (0)