ruby-changes:11987
From: ko1 <ko1@a...>
Date: Tue, 9 Jun 2009 01:14:24 +0900 (JST)
Subject: [ruby-changes:11987] Ruby:r23651 (trunk): * thread.c: rename functions which require a parameter
ko1 2009-06-09 01:14:06 +0900 (Tue, 09 Jun 2009) New Revision: 23651 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23651 Log: * 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(). Modified files: trunk/ChangeLog trunk/eval.c trunk/eval_error.c trunk/eval_intern.h trunk/include/ruby/intern.h trunk/signal.c trunk/thread.c trunk/version.h trunk/vm_core.h Index: eval_intern.h =================================================================== --- eval_intern.h (revision 23650) +++ eval_intern.h (revision 23651) @@ -185,8 +185,8 @@ 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) Index: include/ruby/intern.h =================================================================== --- include/ruby/intern.h (revision 23650) +++ include/ruby/intern.h (revision 23651) @@ -328,8 +328,6 @@ 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); Index: ChangeLog =================================================================== --- ChangeLog (revision 23650) +++ ChangeLog (revision 23651) @@ -1,3 +1,18 @@ +Tue Jun 9 01:07:33 2009 Koichi Sasada <ko1@a...> + + * 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@a...> * thread_pthread.c (rb_thread_create_timer_thread): print fatal error Index: vm_core.h =================================================================== --- vm_core.h (revision 23650) +++ vm_core.h (revision 23651) @@ -625,11 +625,13 @@ #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) Index: eval_error.c =================================================================== --- eval_error.c (revision 23650) +++ eval_error.c (revision 23651) @@ -215,7 +215,7 @@ 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 @@ rb_bug("Unknown longjmp status %d", ex); break; } - rb_thread_reset_raised(th); + rb_threadptr_reset_raised(th); return status; } Index: thread.c =================================================================== --- thread.c (revision 23650) +++ thread.c (revision 23651) @@ -65,7 +65,7 @@ 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 @@ } 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ */ 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 @@ /*****************************************************/ 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 @@ 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 @@ } 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 @@ } 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 @@ { 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 @@ 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 @@ 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 @@ } 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_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_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_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 @@ 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 @@ } } -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 @@ 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 @@ 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 @@ } 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 @@ { 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 @@ 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 @@ { 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 @@ 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 @@ } if (raised) { - rb_thread_set_raised(th); + rb_threadptr_set_raised(th); } POP_TAG(); @@ -3979,7 +3998,7 @@ 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); } } Index: eval.c =================================================================== --- eval.c (revision 23650) +++ eval.c (revision 23651) @@ -341,7 +341,7 @@ 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 @@ th->errinfo = mesg; } else if (status) { - rb_thread_reset_raised(th); + rb_threadptr_reset_raised(th); JUMP_TAG(status); } } Index: version.h =================================================================== --- version.h (revision 23650) +++ version.h (revision 23651) @@ -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" Index: signal.c =================================================================== --- signal.c (revision 23650) +++ signal.c (revision 23651) @@ -664,12 +664,12 @@ #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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/