=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/io/ox.c,v retrieving revision 1.24 retrieving revision 1.41 diff -u -p -r1.24 -r1.41 --- OpenXM_contrib2/asir2000/io/ox.c 2003/12/11 05:48:04 1.24 +++ OpenXM_contrib2/asir2000/io/ox.c 2018/03/12 02:37:08 1.41 @@ -44,7 +44,7 @@ * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. - * $OpenXM: OpenXM_contrib2/asir2000/io/ox.c,v 1.23 2003/12/10 07:37:40 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/io/ox.c,v 1.40 2017/08/30 09:40:30 ohara Exp $ */ #include "ca.h" #include "parse.h" @@ -82,6 +82,7 @@ struct mathcap { unsigned int *smcap; int noxcap; struct oxcap *oxcap; + int no_ox_reset; }; struct oxcap *my_oxcap; @@ -91,9 +92,12 @@ static struct mathcap *remote_mc; static int remote_mc_len; void mclist_to_mc(LIST mclist,struct mathcap *mc); +Obj asir_pop_one(); +void asir_push_one(Obj); -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) /* XXX : mainly used in engine2000/io.c, but declared here */ +typedef void *HANDLE; HANDLE hStreamNotify,hStreamNotify_Ack; void cleanup_events() @@ -105,9 +109,18 @@ void cleanup_events() } #endif +/* 1 if no_ox_reset, 0 if ox_reset OK, -1 if invalid */ +int no_ox_reset(int s) +{ + if ( remote_mc && s >= 0 && s < remote_mc_len ) + return remote_mc[s].no_ox_reset; + else + return -1; +} + void ox_resetenv(char *s) { -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) cleanup_events(); #endif fprintf(stderr,"%s\n",s); @@ -120,9 +133,10 @@ static int available_cmo[] = { CMO_ZZ, CMO_QQ, CMO_ZERO, CMO_DMS_GENERIC, CMO_DMS_OF_N_VARIABLES, CMO_RING_BY_NAME, CMO_DISTRIBUTED_POLYNOMIAL, + CMO_RATIONAL, CMO_RECURSIVE_POLYNOMIAL, CMO_UNIVARIATE_POLYNOMIAL, CMO_INDETERMINATE, - CMO_TREE, + CMO_TREE, CMO_BIGFLOAT32, CMO_COMPLEX, 0 }; @@ -144,7 +158,7 @@ static int ox_asir_available_sm[] = { SM_executeStringByLocalParserInBatchMode, SM_executeFunction, SM_shutdown, SM_pops, SM_mathcap, SM_setMathcap, SM_nop, - SM_beginBlock, SM_endBlock, + SM_beginBlock, SM_endBlock, SM_executeFunctionSync, SM_set_rank_102, SM_tcp_accept_102, SM_tcp_connect_102, SM_reset_102, SM_bcast_102, SM_reduce_102, 0 @@ -296,6 +310,7 @@ void mclist_to_mc(LIST mclist,struct mathcap *mc) [o2,[n21,n22,...]], ... ] + (optional)[s1,s2,...] (no_ox_reset) ] */ n = BDY(mclist); @@ -328,6 +343,15 @@ void mclist_to_mc(LIST mclist,struct mathcap *mc) for ( t = cap, ptr = mc->oxcap[j].cap, i = 0; i < l; t = NEXT(t), i++ ) ptr[i] = BDY((USINT)BDY(t)); } + /* check of no_ox_reset */ + mc->no_ox_reset = 0; + n = BDY(mclist); + if ( length(n) >= 4 ) { + t = BDY((LIST)ARG3(n)); + for ( ; t; t = NEXT(t) ) + if ( !strcmp(BDY((STRING)BDY(t)),"no_ox_reset") ) + mc->no_ox_reset = 1; + } } int check_sm_by_mc(int s,unsigned int smtag) @@ -392,7 +416,7 @@ void end_critical() { critical_when_signal = 0; if ( ox_usr1_sent ) { ox_usr1_sent = 0; -#if !defined(VISUAL) +#if !defined(VISUAL) && !defined(__MINGW32__) ox_usr1_handler(SIGUSR1); #else ox_usr1_handler(0); @@ -403,24 +427,32 @@ void end_critical() { } } -extern FUNC registered_handler; +extern NODE user_int_handler; +extern int caught_intr,in_gc; void ox_usr1_handler(int sig) { -#if !defined(VISUAL) - signal(SIGUSR1,ox_usr1_handler); + NODE t; + +#if !defined(VISUAL) && !defined(__MINGW32__) + set_signal_for_restart(SIGUSR1,ox_usr1_handler); #endif if ( critical_when_signal ) { fprintf(stderr,"usr1 : critical\n"); ox_usr1_sent = 1; + } else if ( in_gc ) { + fprintf(stderr,"usr1 : in_gc\n"); + caught_intr = 2; } else { ox_flushing = 1; - if ( registered_handler ) { + if ( user_int_handler ) { fprintf(stderr, - "usr1 : calling the registered exception handler..."); - bevalf(registered_handler,0); + "usr1 : calling the registered exception handlers..."); + for ( t = user_int_handler; t; t = NEXT(t) ) + bevalf((FUNC)BDY(t),0); fprintf(stderr, "done.\n"); } + LEAVE_SIGNAL_CS_ALL; ox_resetenv("usr1 : return to toplevel by SIGUSR1"); } } @@ -458,6 +490,11 @@ void wait_for_data(int s) { return; } + +void wait_for_data_102(int rank) +{ + return; +} #else int ox_data_is_available(int s) { @@ -470,7 +507,7 @@ void wait_for_data(int s) int sock; if ( !FP_DATA_IS_AVAILABLE(iofp[s].in) ) { -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) sock = iofp[s].in->fildes; FD_ZERO(&r); FD_SET((unsigned int)sock,&r); @@ -490,7 +527,7 @@ void wait_for_data_102(int rank) int sock; if ( !FP_DATA_IS_AVAILABLE(iofp_102[rank].in) ) { -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) sock = iofp_102[rank].in->fildes; FD_ZERO(&r); FD_SET((unsigned int)sock,&r); @@ -508,9 +545,11 @@ void wait_for_data_102(int rank) void ox_send_data(int s,pointer p) { ERR err; + Obj p0; + p0 = (Obj)p; if ( ox_check && !ox_check_cmo(s,(Obj)p) ) { - create_error(&err,ox_serial,"ox_send_data : Mathcap violation"); + create_error(&err,ox_serial,"ox_send_data : Mathcap violation",0); p = (pointer)err; } begin_critical(); @@ -863,7 +902,7 @@ int ox_check_cmo(int s, Obj obj) return check_by_mc(s,OX_DATA,CMO_ZZ); else return check_by_mc(s,OX_DATA,CMO_QQ); - case N_R: + case N_R: case N_B: case N_C: return 1; default: return 0; @@ -876,6 +915,8 @@ int ox_check_cmo(int s, Obj obj) return 1; case O_QUOTE: /* XXX */ return 1; + case O_MAT: /* MAT is sent as a list */ + return 1; default: return 0; } @@ -924,7 +965,7 @@ void ox_flush_stream(int s) { if ( ox_batch ) return; -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) if ( _fileno(&iofp[s].out->fp) < 0 ) cflush(iofp[s].out); else @@ -938,7 +979,7 @@ void ox_flush_stream(int s) void ox_flush_stream_force(int s) { -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) if ( _fileno(&iofp[s].out->fp) < 0 ) cflush(iofp[s].out); else @@ -959,7 +1000,7 @@ void ox_flush_stream_102(int rank) void ox_flush_stream_force_102(int rank) { if ( iofp_102[rank].out ) -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) cflush(iofp_102[rank].out); #elif MPI cflush(iofp_102[rank].out);