version 1.61, 2006/02/13 10:07:19 |
version 1.71, 2013/06/13 18:42:11 |
|
|
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* $OpenXM: OpenXM_contrib2/asir2000/io/ox_asir.c,v 1.60 2006/02/11 09:10:16 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/io/ox_asir.c,v 1.70 2011/01/13 08:00:07 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 108 char *name_of_id(int); |
|
Line 108 char *name_of_id(int); |
|
|
|
static void asir_do_cmd(int,unsigned int); |
static void asir_do_cmd(int,unsigned int); |
static void asir_executeFunction(int); |
static void asir_executeFunction(int); |
|
static void asir_executeFunctionSync(int); |
|
|
#if defined(MPI) |
#if defined(MPI) |
/* XXX : currently MPI version supports only a homogeneous cluster. */ |
/* XXX : currently MPI version supports only a homogeneous cluster. */ |
Line 121 void ox_mpi_master_init() { |
|
Line 122 void ox_mpi_master_init() { |
|
/* ordering information is not exchanged */ |
/* ordering information is not exchanged */ |
/* idx should be equal to i */ |
/* idx should be equal to i */ |
idx = get_iofp(i,0,0); |
idx = get_iofp(i,0,0); |
register_server(0,idx,idx); |
register_server(0,idx,idx,-1); |
} |
} |
} |
} |
|
|
Line 134 void ox_mpi_slave_init() { |
|
Line 135 void ox_mpi_slave_init() { |
|
/* ordering information is not exchanged */ |
/* ordering information is not exchanged */ |
/* idx should be equal to i */ |
/* idx should be equal to i */ |
idx = get_iofp(i,0,0); |
idx = get_iofp(i,0,0); |
register_server(0,idx,idx); |
register_server(0,idx,idx,-1); |
} |
} |
asir_OperandStackSize = BUFSIZ; |
asir_OperandStackSize = BUFSIZ; |
asir_OperandStack = (Obj *)CALLOC(asir_OperandStackSize,sizeof(Obj)); |
asir_OperandStack = (Obj *)CALLOC(asir_OperandStackSize,sizeof(Obj)); |
Line 191 void ox_main(int argc,char **argv) { |
|
Line 192 void ox_main(int argc,char **argv) { |
|
asir_push_one((Obj)err); |
asir_push_one((Obj)err); |
while ( NEXT(asir_infile) ) |
while ( NEXT(asir_infile) ) |
closecurrentinput(); |
closecurrentinput(); |
|
resetpvs(); |
} |
} |
break; |
break; |
} |
} |
Line 257 static void asir_do_cmd(int cmd,unsigned int serial) |
|
Line 259 static void asir_do_cmd(int cmd,unsigned int serial) |
|
case SM_executeFunction: |
case SM_executeFunction: |
asir_executeFunction(serial); |
asir_executeFunction(serial); |
break; |
break; |
|
case SM_executeFunctionSync: |
|
asir_executeFunctionSync(serial); |
|
break; |
case SM_shutdown: |
case SM_shutdown: |
asir_terminate(2); |
asir_terminate(2); |
break; |
break; |
Line 387 char *name_of_cmd(int cmd) |
|
Line 392 char *name_of_cmd(int cmd) |
|
case SM_reduce_102: |
case SM_reduce_102: |
return "SM_reduce_102"; |
return "SM_reduce_102"; |
break; |
break; |
|
case SM_executeFunctionSync: |
|
return "SM_executeFunctionSync"; |
|
break; |
default: |
default: |
return "Unknown cmd"; |
return "Unknown cmd"; |
break; |
break; |
Line 596 void asir_pushCMOtag(unsigned int serial) |
|
Line 604 void asir_pushCMOtag(unsigned int serial) |
|
} |
} |
} |
} |
|
|
|
void print_to_wfep(Obj obj) |
|
{ |
|
asir_push_one(obj); |
|
asir_popString(); |
|
} |
|
|
|
extern int wfep_mode; |
|
|
void asir_popString() |
void asir_popString() |
{ |
{ |
Obj val; |
Obj val; |
Line 606 void asir_popString() |
|
Line 622 void asir_popString() |
|
val = asir_pop_one(); |
val = asir_pop_one(); |
if ( !val ) |
if ( !val ) |
buf = "0"; |
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); |
l = estimate_length(CO,val); |
buf = (char *)ALLOCA(l+1); |
buf = (char *)ALLOCA(l+1); |
soutput_init(buf); |
soutput_init(buf); |
Line 627 void asir_pops() |
|
Line 646 void asir_pops() |
|
void asir_setName(unsigned int serial) |
void asir_setName(unsigned int serial) |
{ |
{ |
char *name; |
char *name; |
int l,n; |
size_t l,n; |
char *dummy = "=0;"; |
char *dummy = "=0;"; |
SNODE snode; |
SNODE snode; |
ERR err; |
ERR err; |
Line 649 void asir_setName(unsigned int serial) |
|
Line 668 void asir_setName(unsigned int serial) |
|
void asir_evalName(unsigned int serial) |
void asir_evalName(unsigned int serial) |
{ |
{ |
char *name; |
char *name; |
int l,n; |
size_t l,n; |
SNODE snode; |
SNODE snode; |
ERR err; |
ERR err; |
pointer val; |
pointer val; |
Line 703 int asir_executeString() |
|
Line 722 int asir_executeString() |
|
#else |
#else |
parse_strp = cmd; |
parse_strp = cmd; |
#endif |
#endif |
|
asir_infile->ln = 1; |
if ( mainparse(&snode) ) { |
if ( mainparse(&snode) ) { |
return -1; |
return -1; |
} |
} |
Line 773 static void asir_executeFunction(int serial) |
|
Line 793 static void asir_executeFunction(int serial) |
|
#endif |
#endif |
searchf(noargsysf,func,&f); |
searchf(noargsysf,func,&f); |
if ( !f ) |
if ( !f ) |
searchf(sysf,func,&f); |
gen_searchf_searchonly(func,&f); |
if ( !f ) |
|
searchf(ubinf,func,&f); |
|
if ( !f ) |
|
searchf(usrf,func,&f); |
|
if ( !f ) { |
if ( !f ) { |
sprintf(buf,"executeFunction : the function %s not found",func); |
sprintf(buf,"executeFunction : the function %s not found",func); |
goto error; |
goto error; |
Line 787 static void asir_executeFunction(int serial) |
|
Line 803 static void asir_executeFunction(int serial) |
|
#if 0 |
#if 0 |
} |
} |
#endif |
#endif |
|
printf("executeFunction done\n"); |
asir_push_one(result); |
asir_push_one(result); |
return; |
return; |
|
|
|
|
asir_push_one(result); |
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 ) |
|
gen_searchf_searchonly(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() |
void asir_end_flush() |
{ |
{ |
ox_flushing = 0; |
ox_flushing = 0; |
Line 892 void ox_asir_init(int argc,char **argv,char *servernam |
|
Line 983 void ox_asir_init(int argc,char **argv,char *servernam |
|
pf_init(); |
pf_init(); |
sysf_init(); |
sysf_init(); |
parif_init(); |
parif_init(); |
|
order_init(); |
#if defined(VISUAL) |
#if defined(VISUAL) |
init_socket(); |
init_socket(); |
#endif |
#endif |
Line 981 void ox_io_init() { |
|
Line 1073 void ox_io_init() { |
|
read_char(iofp[0].in,&rc); |
read_char(iofp[0].in,&rc); |
iofp[0].conv = c == rc ? 0 : 1; |
iofp[0].conv = c == rc ? 0 : 1; |
/* XXX; for raw I/O */ |
/* XXX; for raw I/O */ |
register_server(0,0,0); |
register_server(0,0,0,-1); |
} |
} |
|
|
#if !defined(VISUAL) |
#if !defined(VISUAL) |