=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/io/ox_asir.c,v retrieving revision 1.64 retrieving revision 1.68 diff -u -p -r1.64 -r1.68 --- OpenXM_contrib2/asir2000/io/ox_asir.c 2006/09/26 05:35:26 1.64 +++ OpenXM_contrib2/asir2000/io/ox_asir.c 2010/12/12 07:38:00 1.68 @@ -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_asir.c,v 1.63 2006/06/21 09:46:06 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/io/ox_asir.c,v 1.67 2010/04/23 04:44:52 noro Exp $ */ #include "ca.h" #include "parse.h" @@ -108,6 +108,7 @@ char *name_of_id(int); static void asir_do_cmd(int,unsigned int); static void asir_executeFunction(int); +static void asir_executeFunctionSync(int); #if defined(MPI) /* XXX : currently MPI version supports only a homogeneous cluster. */ @@ -121,7 +122,7 @@ void ox_mpi_master_init() { /* ordering information is not exchanged */ /* idx should be equal to i */ idx = get_iofp(i,0,0); - register_server(0,idx,idx); + register_server(0,idx,idx,-1); } } @@ -134,7 +135,7 @@ void ox_mpi_slave_init() { /* ordering information is not exchanged */ /* idx should be equal to i */ idx = get_iofp(i,0,0); - register_server(0,idx,idx); + register_server(0,idx,idx,-1); } asir_OperandStackSize = BUFSIZ; asir_OperandStack = (Obj *)CALLOC(asir_OperandStackSize,sizeof(Obj)); @@ -258,6 +259,9 @@ static void asir_do_cmd(int cmd,unsigned int serial) case SM_executeFunction: asir_executeFunction(serial); break; + case SM_executeFunctionSync: + asir_executeFunctionSync(serial); + break; case SM_shutdown: asir_terminate(2); break; @@ -388,6 +392,9 @@ char *name_of_cmd(int cmd) case SM_reduce_102: return "SM_reduce_102"; break; + case SM_executeFunctionSync: + return "SM_executeFunctionSync"; + break; default: return "Unknown cmd"; break; @@ -603,6 +610,8 @@ void print_to_wfep(Obj obj) asir_popString(); } +extern int wfep_mode; + void asir_popString() { Obj val; @@ -613,7 +622,10 @@ void asir_popString() val = asir_pop_one(); if ( !val ) buf = "0"; - else { + else if ( wfep_mode && OID(val) == O_ERR ) { + /* XXX : for wfep */ + ox_send_data(0,val); return; + } else { l = estimate_length(CO,val); buf = (char *)ALLOCA(l+1); soutput_init(buf); @@ -795,6 +807,7 @@ static void asir_executeFunction(int serial) #if 0 } #endif + printf("executeFunction done\n"); asir_push_one(result); return; @@ -804,6 +817,84 @@ error: asir_push_one(result); } +static void asir_executeFunctionSync(int serial) +{ + char *func; + int argc,i; + FUNC f; + Obj result=0; + NODE n,n1; + STRING fname; + char *path; + ERR err; + Obj arg; + static char buf[BUFSIZ]; + + arg = asir_pop_one(); + if ( !arg || OID(arg) != O_STR ) { + sprintf(buf,"executeFunction : invalid function name"); + goto error; + } else + func = ((STRING)arg)->body; + + arg = asir_pop_one(); + if ( !arg || OID(arg) != O_USINT ) { + sprintf(buf,"executeFunction : invalid argc"); + goto error; + } else + argc = (int)(((USINT)arg)->body); + + for ( n = 0; argc; argc-- ) { + NEXTNODE(n,n1); + BDY(n1) = (pointer)asir_pop_one(); + } + if ( n ) + NEXT(n1) = 0; + + ox_send_data(0,ONE); + +#if 0 + if ( !strcmp(func,"load") ) { + fname = (STRING)BDY(n); + if ( OID(fname) == O_STR ) { + searchasirpath(BDY(fname),&path); + if ( path ) { + if ( do_message ) + fprintf(stderr,"loading %s\n",path); + execasirfile(path); + } else + if ( do_message ) + fprintf(stderr,"load : %s not found in the search path\n",BDY(fname)); + } + result = 0; + } else { +#endif + searchf(noargsysf,func,&f); + if ( !f ) + searchf(sysf,func,&f); + if ( !f ) + searchf(ubinf,func,&f); + if ( !f ) + searchf(usrf,func,&f); + if ( !f ) { + sprintf(buf,"executeFunction : the function %s not found",func); + goto error; + } else { + result = (Obj)bevalf(f,n); + } +#if 0 + } +#endif + printf("executeFunctionSync done\n"); + ox_send_data(0,result); + return; + +error: + create_error(&err,serial,buf,0); + result = (Obj)err; + ox_send_data(0,result); +} + void asir_end_flush() { ox_flushing = 0; @@ -900,6 +991,7 @@ void ox_asir_init(int argc,char **argv,char *servernam pf_init(); sysf_init(); parif_init(); + order_init(); #if defined(VISUAL) init_socket(); #endif @@ -989,7 +1081,7 @@ void ox_io_init() { read_char(iofp[0].in,&rc); iofp[0].conv = c == rc ? 0 : 1; /* XXX; for raw I/O */ - register_server(0,0,0); + register_server(0,0,0,-1); } #if !defined(VISUAL)