ruby-changes:7607
From: ko1 <ko1@a...>
Date: Thu, 4 Sep 2008 21:03:25 +0900 (JST)
Subject: [ruby-changes:7607] Ruby:r19128 (trunk): * thread.c (rb_thread_check_trap_pending): added for compatibility.
ko1 2008-09-04 21:00:24 +0900 (Thu, 04 Sep 2008) New Revision: 19128 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19128 Log: * thread.c (rb_thread_check_trap_pending): added for compatibility. * ext/tk/tcltklib.c, ext/tk/tkutil/tkutil.c: remove ruby/signal.h dependency. Modified files: trunk/ChangeLog trunk/ext/tk/tcltklib.c trunk/ext/tk/tkutil/tkutil.c trunk/thread.c Index: ChangeLog =================================================================== --- ChangeLog (revision 19127) +++ ChangeLog (revision 19128) @@ -1,3 +1,10 @@ +Thu Sep 4 20:57:54 2008 Koichi Sasada <ko1@a...> + + * thread.c (rb_thread_check_trap_pending): added for compatibility. + + * ext/tk/tcltklib.c, ext/tk/tkutil/tkutil.c: remove ruby/signal.h + dependency. + Thu Sep 4 20:30:24 2008 Tanaka Akira <akr@f...> * transcode_data.h (PType): defined unconditionaly. Index: thread.c =================================================================== --- thread.c (revision 19127) +++ thread.c (revision 19128) @@ -890,6 +890,16 @@ RUBY_VM_CHECK_INTS(); } +/* + * Hidden API for tcl/tk wrapper. + * There is no guarantee to perpetuate it. + */ +int +rb_thread_check_trap_pending(void) +{ + return GET_THREAD()->exec_signal != 0; +} + struct timeval rb_time_timeval(); void Index: ext/tk/tcltklib.c =================================================================== --- ext/tk/tcltklib.c (revision 19127) +++ ext/tk/tcltklib.c (revision 19128) @@ -8,11 +8,6 @@ #include "ruby.h" -#ifdef HAVE_RUBY_SIGNAL_H -#include "ruby/signal.h" -#else -#include "rubysig.h" -#endif #ifdef HAVE_RUBY_ENCODING_H #include "ruby/encoding.h" #endif @@ -54,6 +49,9 @@ #define TCL_FINAL_RELEASE 2 #endif +static VALUE rb_thread_critical; /* dummy */ +int rb_thread_check_trap_pending(); + static struct { int major; int minor; @@ -1623,7 +1621,29 @@ } #endif +#define TRAP_CHECK() do { \ + if (trap_check(check_var) == 0) return 0; \ +} while (0) + static int +trap_check(int *check_var) +{ + DUMP1("trap check"); + + if (rb_thread_check_trap_pending()) { + if (check_var != (int*)NULL) { + /* wait command */ + return 0; + } + else { + rb_thread_check_ints(); + } + } + + return 1; +} + +static int lib_eventloop_core(check_root, update_flag, check_var, interp) int check_root; int update_flag; @@ -1755,28 +1775,12 @@ } } - DUMP1("trap check"); - if (rb_trap_pending) { - run_timer_flag = 0; - if (rb_prohibit_interrupt || check_var != (int*)NULL) { - /* pending or on wait command */ - return 0; - } else { - rb_trap_exec(); - } - } + TRAP_CHECK(); - DUMP1("check Root Widget"); + DUMP1("check Root Widget"); if (check_root && tk_stubs_init_p() && Tk_GetNumMainWindows() == 0) { run_timer_flag = 0; - if (rb_trap_pending) { - if (rb_prohibit_interrupt || check_var != (int*)NULL) { - /* pending or on wait command */ - return 0; - } else { - rb_trap_exec(); - } - } + TRAP_CHECK(); return 1; } @@ -1886,16 +1890,7 @@ return 0; } - DUMP1("trap check"); - if (rb_trap_pending) { - run_timer_flag = 0; - if (rb_prohibit_interrupt || check_var != (int*)NULL) { - /* pending or on wait command */ - return 0; - } else { - rb_trap_exec(); - } - } + TRAP_CHECK(); if (check_var != (int*)NULL && !NIL_P(rbtk_pending_exception)) { @@ -1966,28 +1961,12 @@ return 1; } - DUMP1("trap check"); - if (rb_trap_pending) { - run_timer_flag = 0; - if (rb_prohibit_interrupt || check_var != (int*)NULL) { - /* pending or on wait command */ - return 0; - } else { - rb_trap_exec(); - } - } + TRAP_CHECK(); DUMP1("check Root Widget"); if (check_root && tk_stubs_init_p() && Tk_GetNumMainWindows() == 0) { run_timer_flag = 0; - if (rb_trap_pending) { - if (rb_prohibit_interrupt || check_var != (int*)NULL) { - /* pending or on wait command */ - return 0; - } else { - rb_trap_exec(); - } - } + TRAP_CHECK(); return 1; } @@ -2823,7 +2802,6 @@ VALUE (*proc)(); VALUE data; { - int old_trapflag = rb_trap_immediate; int code; #ifdef HAVE_NATIVETHREAD @@ -2834,10 +2812,7 @@ #endif #endif - rb_trap_immediate = 0; code = tcl_protect_core(interp, proc, data); - rb_trap_immediate = old_trapflag; - return code; } @@ -3404,7 +3379,7 @@ } /* trap check */ - if (rb_trap_pending) { + if (rb_thread_check_trap_pending()) { Tcl_Release(interp); return TCL_RETURN; @@ -3770,7 +3745,7 @@ } /* trap check */ - if (rb_trap_pending) { + if (rb_thread_check_trap_pending()) { #if TCL_MAJOR_VERSION >= 8 Tcl_DecrRefCount(objv[1]); #endif @@ -4059,7 +4034,7 @@ } /* trap check */ - if (rb_trap_pending) { + if (rb_thread_check_trap_pending()) { Tcl_Release(interp); return TCL_RETURN; @@ -4119,7 +4094,7 @@ } /* trap check */ - if (rb_trap_pending) { + if (rb_thread_check_trap_pending()) { #if TCL_MAJOR_VERSION >= 8 Tcl_DecrRefCount(objv[2]); #endif @@ -4214,7 +4189,7 @@ } /* trap check */ - if (rb_trap_pending) { + if (rb_thread_check_trap_pending()) { Tcl_Release(interp); return TCL_RETURN; Index: ext/tk/tkutil/tkutil.c =================================================================== --- ext/tk/tkutil/tkutil.c (revision 19127) +++ ext/tk/tkutil/tkutil.c (revision 19128) @@ -11,11 +11,6 @@ #include "ruby.h" -#ifdef HAVE_RUBY_SIGNAL_H -#include "ruby/signal.h" -#else -#include "rubysig.h" -#endif #ifdef HAVE_RUBY_ST_H #include "ruby/st.h" #else @@ -895,15 +890,12 @@ { int idx, size; volatile VALUE dst; - int thr_crit_bup; VALUE old_gc; if (argc < 2) { rb_raise(rb_eArgError, "too few arguments"); } - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; old_gc = rb_gc_disable(); for(size = 0, idx = 2; idx < argc; idx++) { @@ -928,7 +920,6 @@ } if (old_gc == Qfalse) rb_gc_enable(); - rb_thread_critical = thr_crit_bup; return rb_ary_plus(argv[0], dst); } @@ -1599,12 +1590,8 @@ unsigned char type_chr; volatile VALUE dst = rb_ary_new2(vallen); volatile VALUE proc; - int thr_crit_bup; VALUE old_gc; - thr_crit_bup = rb_thread_critical; - rb_thread_critical = Qtrue; - old_gc = rb_gc_disable(); Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO), @@ -1632,7 +1619,6 @@ } if (old_gc == Qfalse) rb_gc_enable(); - rb_thread_critical = thr_crit_bup; return dst; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/