[BACK]Return to ox.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / io

Diff for /OpenXM_contrib2/asir2000/io/ox.c between version 1.41 and 1.42

version 1.41, 2018/03/12 02:37:08 version 1.42, 2018/03/29 01:32:53
Line 44 
Line 44 
  * 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.c,v 1.40 2017/08/30 09:40:30 ohara Exp $   * $OpenXM: OpenXM_contrib2/asir2000/io/ox.c,v 1.41 2018/03/12 02:37:08 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
 #include "parse.h"  #include "parse.h"
Line 69  JMP_BUF ox_env;
Line 69  JMP_BUF ox_env;
 MATHCAP my_mathcap;  MATHCAP my_mathcap;
   
 struct oxcap {  struct oxcap {
         unsigned int ox;    unsigned int ox;
         int ncap;    int ncap;
         int *cap;    int *cap;
 };  };
   
 struct mathcap {  struct mathcap {
         LIST mc;    LIST mc;
         unsigned int version;    unsigned int version;
         char *servername;    char *servername;
         int nsmcap;    int nsmcap;
         unsigned int *smcap;    unsigned int *smcap;
         int noxcap;    int noxcap;
         struct oxcap *oxcap;    struct oxcap *oxcap;
   int no_ox_reset;    int no_ox_reset;
 };  };
   
Line 102  HANDLE hStreamNotify,hStreamNotify_Ack;
Line 102  HANDLE hStreamNotify,hStreamNotify_Ack;
   
 void cleanup_events()  void cleanup_events()
 {  {
         /* ox_watch_stream may be waiting for hStreamNotify_Ack to be set */    /* ox_watch_stream may be waiting for hStreamNotify_Ack to be set */
   
         ResetEvent(hStreamNotify);    ResetEvent(hStreamNotify);
         SetEvent(hStreamNotify_Ack);    SetEvent(hStreamNotify_Ack);
 }  }
 #endif  #endif
   
Line 121  int no_ox_reset(int s)
Line 121  int no_ox_reset(int s)
 void ox_resetenv(char *s)  void ox_resetenv(char *s)
 {  {
 #if defined(VISUAL) || defined(__MINGW32__)  #if defined(VISUAL) || defined(__MINGW32__)
         cleanup_events();    cleanup_events();
 #endif  #endif
         fprintf(stderr,"%s\n",s);    fprintf(stderr,"%s\n",s);
         LONGJMP(ox_env,1);    LONGJMP(ox_env,1);
 }  }
   
 static int available_cmo[] = {  static int available_cmo[] = {
         CMO_NULL, CMO_INT32, CMO_DATUM, CMO_STRING, CMO_MATHCAP,    CMO_NULL, CMO_INT32, CMO_DATUM, CMO_STRING, CMO_MATHCAP,
         CMO_ERROR, CMO_ERROR2, CMO_LIST, CMO_MONOMIAL32,    CMO_ERROR, CMO_ERROR2, CMO_LIST, CMO_MONOMIAL32,
         CMO_ZZ, CMO_QQ, CMO_ZERO,    CMO_ZZ, CMO_QQ, CMO_ZERO,
         CMO_DMS_GENERIC, CMO_DMS_OF_N_VARIABLES,    CMO_DMS_GENERIC, CMO_DMS_OF_N_VARIABLES,
         CMO_RING_BY_NAME, CMO_DISTRIBUTED_POLYNOMIAL,    CMO_RING_BY_NAME, CMO_DISTRIBUTED_POLYNOMIAL,
     CMO_RATIONAL,      CMO_RATIONAL,
         CMO_RECURSIVE_POLYNOMIAL, CMO_UNIVARIATE_POLYNOMIAL,    CMO_RECURSIVE_POLYNOMIAL, CMO_UNIVARIATE_POLYNOMIAL,
         CMO_INDETERMINATE,    CMO_INDETERMINATE,
         CMO_TREE, CMO_BIGFLOAT32, CMO_COMPLEX,    CMO_TREE, CMO_BIGFLOAT32, CMO_COMPLEX,
         0    0
 };  };
   
 static int asir_available_sm[] = {  static int asir_available_sm[] = {
         SM_dupErrors, SM_getsp, SM_popSerializedLocalObject,    SM_dupErrors, SM_getsp, SM_popSerializedLocalObject,
         SM_popCMO, SM_popString, SM_pushCMOtag, SM_setName,    SM_popCMO, SM_popString, SM_pushCMOtag, SM_setName,
         SM_evalName, SM_executeStringByLocalParser,    SM_evalName, SM_executeStringByLocalParser,
         SM_executeStringByLocalParserInBatchMode,    SM_executeStringByLocalParserInBatchMode,
         SM_executeFunction, SM_shutdown, SM_pops,    SM_executeFunction, SM_shutdown, SM_pops,
         SM_mathcap, SM_setMathcap, SM_nop,    SM_mathcap, SM_setMathcap, SM_nop,
         SM_beginBlock, SM_endBlock,    SM_beginBlock, SM_endBlock,
         0    0
 };  };
   
 static int ox_asir_available_sm[] = {  static int ox_asir_available_sm[] = {
         SM_dupErrors, SM_getsp, SM_popSerializedLocalObject,    SM_dupErrors, SM_getsp, SM_popSerializedLocalObject,
         SM_popCMO, SM_popString, SM_pushCMOtag, SM_setName,    SM_popCMO, SM_popString, SM_pushCMOtag, SM_setName,
         SM_evalName, SM_executeStringByLocalParser,    SM_evalName, SM_executeStringByLocalParser,
         SM_executeStringByLocalParserInBatchMode,    SM_executeStringByLocalParserInBatchMode,
         SM_executeFunction, SM_shutdown, SM_pops,    SM_executeFunction, SM_shutdown, SM_pops,
         SM_mathcap, SM_setMathcap, SM_nop,    SM_mathcap, SM_setMathcap, SM_nop,
         SM_beginBlock, SM_endBlock,  SM_executeFunctionSync,    SM_beginBlock, SM_endBlock,  SM_executeFunctionSync,
         SM_set_rank_102, SM_tcp_accept_102, SM_tcp_connect_102, SM_reset_102,    SM_set_rank_102, SM_tcp_accept_102, SM_tcp_connect_102, SM_reset_102,
         SM_bcast_102, SM_reduce_102,    SM_bcast_102, SM_reduce_102,
         0    0
 };  };
   
 static int ox_plot_available_sm[] = {  static int ox_plot_available_sm[] = {
         SM_dupErrors, SM_getsp, SM_popSerializedLocalObject,    SM_dupErrors, SM_getsp, SM_popSerializedLocalObject,
         SM_popCMO, SM_popString, SM_setName,    SM_popCMO, SM_popString, SM_setName,
         SM_evalName, SM_executeStringByLocalParser,    SM_evalName, SM_executeStringByLocalParser,
         SM_executeFunction, SM_shutdown, SM_pops,    SM_executeFunction, SM_shutdown, SM_pops,
         SM_mathcap, SM_setMathcap, SM_nop,    SM_mathcap, SM_setMathcap, SM_nop,
         0    0
 };  };
   
 /*  /*
         mathcap =    mathcap =
                 [      [
                         version list,        version list,
                         SMlist,        SMlist,
                         [        [
                                 [OX tag,CMO tag list],          [OX tag,CMO tag list],
                                 [OX tag,CMO tag list],          [OX tag,CMO tag list],
                                 ...          ...
                         ]        ]
                 ]      ]
 */  */
   
 void create_my_mathcap(char *system)  void create_my_mathcap(char *system)
 {  {
         NODE n,n0;    NODE n,n0;
         int i,k;    int i,k;
         STRING str;    STRING str;
         LIST sname,smlist,oxlist,cmolist,asirlist,oxasir,r;    LIST sname,smlist,oxlist,cmolist,asirlist,oxasir,r;
         USINT tag,t,t1;    USINT tag,t,t1;
   
         if ( my_mathcap )    if ( my_mathcap )
                 return;      return;
         /* version */    /* version */
         MKSTR(str,system);    MKSTR(str,system);
         MKUSINT(t,OX_VERSION);    MKUSINT(t,OX_VERSION);
         n0 = mknode(2,t,str); MKLIST(sname,n0);    n0 = mknode(2,t,str); MKLIST(sname,n0);
   
         /* sm tag */    /* sm tag */
         n0 = 0;    n0 = 0;
         if ( !strcmp(system,"asir") ) {    if ( !strcmp(system,"asir") ) {
                 for ( i = 0; k = asir_available_sm[i]; i++ ) {      for ( i = 0; k = asir_available_sm[i]; i++ ) {
                         NEXTNODE(n0,n); MKUSINT(t,k); BDY(n) = (pointer)t;        NEXTNODE(n0,n); MKUSINT(t,k); BDY(n) = (pointer)t;
                 }      }
         } else if ( !strcmp(system,"ox_asir") ) {    } else if ( !strcmp(system,"ox_asir") ) {
                 for ( i = 0; k = ox_asir_available_sm[i]; i++ ) {      for ( i = 0; k = ox_asir_available_sm[i]; i++ ) {
                         NEXTNODE(n0,n); MKUSINT(t,k); BDY(n) = (pointer)t;        NEXTNODE(n0,n); MKUSINT(t,k); BDY(n) = (pointer)t;
                 }      }
                 NEXT(n) = 0;      NEXT(n) = 0;
         } else if ( !strcmp(system,"ox_plot") ) {    } else if ( !strcmp(system,"ox_plot") ) {
                 for ( i = 0; k = ox_plot_available_sm[i]; i++ ) {      for ( i = 0; k = ox_plot_available_sm[i]; i++ ) {
                         NEXTNODE(n0,n); MKUSINT(t,k); BDY(n) = (pointer)t;        NEXTNODE(n0,n); MKUSINT(t,k); BDY(n) = (pointer)t;
                 }      }
                 NEXT(n) = 0;      NEXT(n) = 0;
         }    }
         MKLIST(smlist,n0);    MKLIST(smlist,n0);
   
         /* creation of [OX_DATA,CMO list] */    /* creation of [OX_DATA,CMO list] */
         /* ox tag */    /* ox tag */
         MKUSINT(tag,OX_DATA);    MKUSINT(tag,OX_DATA);
         /* cmo tag */    /* cmo tag */
         for ( n0 = 0, i = 0; k = available_cmo[i]; i++ ) {    for ( n0 = 0, i = 0; k = available_cmo[i]; i++ ) {
                 NEXTNODE(n0,n); MKUSINT(t,k); BDY(n) = (pointer)t;      NEXTNODE(n0,n); MKUSINT(t,k); BDY(n) = (pointer)t;
         }    }
         NEXT(n) = 0; MKLIST(cmolist,n0);    NEXT(n) = 0; MKLIST(cmolist,n0);
         /* [ox tag, cmo list] */    /* [ox tag, cmo list] */
         n0 = mknode(2,tag,cmolist);    n0 = mknode(2,tag,cmolist);
         MKLIST(oxlist,n0);    MKLIST(oxlist,n0);
   
         /* creation of [OX_LOCAL_OBJECT_ASIR,ASIR tag] */    /* creation of [OX_LOCAL_OBJECT_ASIR,ASIR tag] */
         /* ox tag */    /* ox tag */
         MKUSINT(tag,OX_LOCAL_OBJECT_ASIR);    MKUSINT(tag,OX_LOCAL_OBJECT_ASIR);
         /* local tag */    /* local tag */
         MKUSINT(t,ASIR_VL);    MKUSINT(t,ASIR_VL);
         MKUSINT(t1,ASIR_OBJ);    MKUSINT(t1,ASIR_OBJ);
         n0 = mknode(2,t,t1); MKLIST(cmolist,n0);    n0 = mknode(2,t,t1); MKLIST(cmolist,n0);
         /* [ox tag, local list] */    /* [ox tag, local list] */
         n0 = mknode(2,tag,cmolist);    n0 = mknode(2,tag,cmolist);
          MKLIST(asirlist,n0);     MKLIST(asirlist,n0);
   
         /* [oxlist,asirlist] */    /* [oxlist,asirlist] */
         n0 = mknode(2,oxlist,asirlist); MKLIST(oxasir,n0);    n0 = mknode(2,oxlist,asirlist); MKLIST(oxasir,n0);
   
         /* [version,sm,oxasir] */    /* [version,sm,oxasir] */
         n0 = mknode(3,sname,smlist,oxasir); MKLIST(r,n0);    n0 = mknode(3,sname,smlist,oxasir); MKLIST(r,n0);
   
         MKMATHCAP(my_mathcap,r);    MKMATHCAP(my_mathcap,r);
         mclist_to_mc(r,&my_mc);    mclist_to_mc(r,&my_mc);
         my_oxcap = my_mc.oxcap;    my_oxcap = my_mc.oxcap;
 }  }
   
 void store_remote_mathcap(int s,MATHCAP mc)  void store_remote_mathcap(int s,MATHCAP mc)
 {  {
         if ( !remote_mc ) {    if ( !remote_mc ) {
                  remote_mc_len = 16;       remote_mc_len = 16;
                  remote_mc = (struct mathcap *)       remote_mc = (struct mathcap *)
                         CALLOC(remote_mc_len,sizeof(struct mathcap));         CALLOC(remote_mc_len,sizeof(struct mathcap));
         }    }
         if ( s >= remote_mc_len ) {    if ( s >= remote_mc_len ) {
                 remote_mc_len *= 2;      remote_mc_len *= 2;
                 remote_mc = (struct mathcap *)REALLOC(remote_mc,      remote_mc = (struct mathcap *)REALLOC(remote_mc,
                         remote_mc_len*sizeof(struct mathcap));        remote_mc_len*sizeof(struct mathcap));
         }    }
         mclist_to_mc(BDY(mc),&remote_mc[s]);    mclist_to_mc(BDY(mc),&remote_mc[s]);
 }  }
   
 /*  /*
         mathcap =    mathcap =
                 [      [
                         version list,        version list,
                         SMlist,        SMlist,
                         [        [
                                 [OX tag,CMO tag list],          [OX tag,CMO tag list],
                                 [OX tag,CMO tag list],          [OX tag,CMO tag list],
                                 ...          ...
                         ]        ]
                 ]      ]
   
     ===>      ===>
   
         mathcap    mathcap
                 | version | &servername | nsmcap |      &smcap | noxcap | &oxcap |      | version | &servername | nsmcap |   &smcap | noxcap | &oxcap |
         smcap    smcap
                 | SM_xxx | SM_yyy | ... |      | SM_xxx | SM_yyy | ... |
         oxcap    oxcap
                 | oxcap[0] | oxcap[1] | ... |      | oxcap[0] | oxcap[1] | ... |
         oxcap[i]    oxcap[i]
                 | ox | ncap | &cap |      | ox | ncap | &cap |
         cap    cap
                 | CMO_xxx | CMO_yyy | ... |      | CMO_xxx | CMO_yyy | ... |
 */  */
   
 void mclist_to_mc(LIST mclist,struct mathcap *mc)  void mclist_to_mc(LIST mclist,struct mathcap *mc)
 {  {
         int l,i,j;    int l,i,j;
         NODE n,t,oxcmo,cap;    NODE n,t,oxcmo,cap;
         int *ptr;    int *ptr;
   
         /*    /*
                 [      [
                         [ version,servername ]        [ version,servername ]
                         [sm1,sm2,...],        [sm1,sm2,...],
                         [        [
                                 [o1,[n11,n12,...]],          [o1,[n11,n12,...]],
                                 [o2,[n21,n22,...]],          [o2,[n21,n22,...]],
                                 ...          ...
                         ]        ]
       (optional)[s1,s2,...] (no_ox_reset)        (optional)[s1,s2,...] (no_ox_reset)
                 ]         ]
         */    */
         n = BDY(mclist);    n = BDY(mclist);
         mc->mc = mclist;    mc->mc = mclist;
         mc->version = BDY((USINT)BDY(BDY((LIST)BDY(n))));    mc->version = BDY((USINT)BDY(BDY((LIST)BDY(n))));
         mc->servername = BDY((STRING)BDY(NEXT(BDY((LIST)BDY(n)))));    mc->servername = BDY((STRING)BDY(NEXT(BDY((LIST)BDY(n)))));
   
         /* smcap */    /* smcap */
         n = NEXT(n);    n = NEXT(n);
         t = BDY((LIST)BDY(n));    t = BDY((LIST)BDY(n));
         mc->nsmcap = length(t);    mc->nsmcap = length(t);
         mc->smcap = (int *)MALLOC_ATOMIC(mc->nsmcap*sizeof(int));    mc->smcap = (int *)MALLOC_ATOMIC(mc->nsmcap*sizeof(int));
         for ( j = 0, ptr = mc->smcap; j < mc->nsmcap; j++, t = NEXT(t) )    for ( j = 0, ptr = mc->smcap; j < mc->nsmcap; j++, t = NEXT(t) )
                 ptr[j] = BDY((USINT)BDY(t));      ptr[j] = BDY((USINT)BDY(t));
   
         n = NEXT(n);    n = NEXT(n);
         n = BDY((LIST)BDY(n));    n = BDY((LIST)BDY(n));
         /* n -> BDY([[OX1,CMOlist1], [OX2,CMOlist2], ...]) */    /* n -> BDY([[OX1,CMOlist1], [OX2,CMOlist2], ...]) */
         mc->noxcap = length(n);    mc->noxcap = length(n);
         mc->oxcap = (struct oxcap *)MALLOC(mc->noxcap*sizeof(struct oxcap));    mc->oxcap = (struct oxcap *)MALLOC(mc->noxcap*sizeof(struct oxcap));
         for ( j = 0; j < mc->noxcap; j++, n = NEXT(n) ) {    for ( j = 0; j < mc->noxcap; j++, n = NEXT(n) ) {
                 oxcmo = BDY((LIST)BDY(n));      oxcmo = BDY((LIST)BDY(n));
                 /* oxcmo = BDY([OXj,CMOlistj]) */      /* oxcmo = BDY([OXj,CMOlistj]) */
                 mc->oxcap[j].ox = BDY((USINT)BDY(oxcmo));      mc->oxcap[j].ox = BDY((USINT)BDY(oxcmo));
                 cap = BDY((LIST)BDY(NEXT(oxcmo)));      cap = BDY((LIST)BDY(NEXT(oxcmo)));
                 /* cap ->BDY(CMOlistj) */      /* cap ->BDY(CMOlistj) */
                 l = length(cap);      l = length(cap);
                 mc->oxcap[j].ncap = l;      mc->oxcap[j].ncap = l;
                 mc->oxcap[j].cap = (unsigned int *)CALLOC(l+1,sizeof(unsigned int));      mc->oxcap[j].cap = (unsigned int *)CALLOC(l+1,sizeof(unsigned int));
                 for ( t = cap, ptr = mc->oxcap[j].cap, i = 0; i < l; t = NEXT(t), i++ )      for ( t = cap, ptr = mc->oxcap[j].cap, i = 0; i < l; t = NEXT(t), i++ )
                         ptr[i] = BDY((USINT)BDY(t));        ptr[i] = BDY((USINT)BDY(t));
         }    }
   /* check of no_ox_reset */    /* check of no_ox_reset */
   mc->no_ox_reset = 0;    mc->no_ox_reset = 0;
         n = BDY(mclist);    n = BDY(mclist);
   if ( length(n) >= 4 ) {    if ( length(n) >= 4 ) {
           t = BDY((LIST)ARG3(n));      t = BDY((LIST)ARG3(n));
     for ( ; t; t = NEXT(t) )      for ( ; t; t = NEXT(t) )
       if ( !strcmp(BDY((STRING)BDY(t)),"no_ox_reset") )        if ( !strcmp(BDY((STRING)BDY(t)),"no_ox_reset") )
         mc->no_ox_reset = 1;          mc->no_ox_reset = 1;
Line 356  void mclist_to_mc(LIST mclist,struct mathcap *mc)
Line 356  void mclist_to_mc(LIST mclist,struct mathcap *mc)
   
 int check_sm_by_mc(int s,unsigned int smtag)  int check_sm_by_mc(int s,unsigned int smtag)
 {  {
         struct mathcap *rmc;    struct mathcap *rmc;
         int nsmcap,i;    int nsmcap,i;
         unsigned int *smcap;    unsigned int *smcap;
   
         /* XXX : return 1 if remote_mc is not available. */    /* XXX : return 1 if remote_mc is not available. */
         if ( !remote_mc )    if ( !remote_mc )
                 return 1;      return 1;
         rmc = &remote_mc[s];    rmc = &remote_mc[s];
         nsmcap = rmc->nsmcap;    nsmcap = rmc->nsmcap;
         smcap = rmc->smcap;    smcap = rmc->smcap;
         if ( !smcap )    if ( !smcap )
                 return 1;      return 1;
         for ( i = 0; i < nsmcap; i++ )    for ( i = 0; i < nsmcap; i++ )
                 if ( smcap[i] == smtag )      if ( smcap[i] == smtag )
                         break;        break;
         if ( i == nsmcap )    if ( i == nsmcap )
                 return 0;      return 0;
         else    else
                 return 1;      return 1;
 }  }
   
 int check_by_mc(int s,unsigned int oxtag,unsigned int cmotag)  int check_by_mc(int s,unsigned int oxtag,unsigned int cmotag)
 {  {
         struct mathcap *rmc;    struct mathcap *rmc;
         int noxcap,ncap,i,j;    int noxcap,ncap,i,j;
         struct oxcap *oxcap;    struct oxcap *oxcap;
         unsigned int *cap;    unsigned int *cap;
   
         /* XXX : return 1 if remote_mc is not available. */    /* XXX : return 1 if remote_mc is not available. */
         if ( !remote_mc )    if ( !remote_mc )
                 return 1;      return 1;
         rmc = &remote_mc[s];    rmc = &remote_mc[s];
         noxcap = rmc->noxcap;    noxcap = rmc->noxcap;
         oxcap = rmc->oxcap;    oxcap = rmc->oxcap;
         if ( !oxcap )    if ( !oxcap )
                 return 1;      return 1;
         for ( i = 0; i < noxcap; i++ )    for ( i = 0; i < noxcap; i++ )
                 if ( oxcap[i].ox == oxtag )      if ( oxcap[i].ox == oxtag )
                         break;        break;
         if ( i == noxcap )    if ( i == noxcap )
                 return 0;      return 0;
         ncap = oxcap[i].ncap;    ncap = oxcap[i].ncap;
         cap = oxcap[i].cap;    cap = oxcap[i].cap;
         for ( j = 0; j < ncap; j++ )    for ( j = 0; j < ncap; j++ )
                 if ( cap[j] == cmotag )      if ( cap[j] == cmotag )
                         break;        break;
         if ( j == ncap )    if ( j == ncap )
                 return 0;      return 0;
         else    else
                 return 1;      return 1;
 }  }
   
 void begin_critical() {  void begin_critical() {
         critical_when_signal = 1;    critical_when_signal = 1;
 }  }
   
 void end_critical() {  void end_critical() {
         critical_when_signal = 0;    critical_when_signal = 0;
         if ( ox_usr1_sent ) {    if ( ox_usr1_sent ) {
                 ox_usr1_sent = 0;      ox_usr1_sent = 0;
 #if !defined(VISUAL) && !defined(__MINGW32__)  #if !defined(VISUAL) && !defined(__MINGW32__)
         ox_usr1_handler(SIGUSR1);    ox_usr1_handler(SIGUSR1);
 #else  #else
         ox_usr1_handler(0);    ox_usr1_handler(0);
 #endif  #endif
         }    }
         if ( ox_int_received ) {    if ( ox_int_received ) {
                 ox_int_received = 0; int_handler(SIGINT);      ox_int_received = 0; int_handler(SIGINT);
         }    }
 }  }
   
 extern NODE user_int_handler;  extern NODE user_int_handler;
Line 432  extern int caught_intr,in_gc;
Line 432  extern int caught_intr,in_gc;
   
 void ox_usr1_handler(int sig)  void ox_usr1_handler(int sig)
 {  {
         NODE t;    NODE t;
   
 #if !defined(VISUAL) && !defined(__MINGW32__)  #if !defined(VISUAL) && !defined(__MINGW32__)
         set_signal_for_restart(SIGUSR1,ox_usr1_handler);    set_signal_for_restart(SIGUSR1,ox_usr1_handler);
 #endif  #endif
         if ( critical_when_signal ) {    if ( critical_when_signal ) {
                 fprintf(stderr,"usr1 : critical\n");      fprintf(stderr,"usr1 : critical\n");
                 ox_usr1_sent = 1;      ox_usr1_sent = 1;
     } else if ( in_gc ) {      } else if ( in_gc ) {
                 fprintf(stderr,"usr1 : in_gc\n");      fprintf(stderr,"usr1 : in_gc\n");
                 caught_intr = 2;      caught_intr = 2;
         } else {    } else {
                 ox_flushing = 1;      ox_flushing = 1;
                 if ( user_int_handler ) {      if ( user_int_handler ) {
                         fprintf(stderr,        fprintf(stderr,
                                 "usr1 : calling the registered exception handlers...");          "usr1 : calling the registered exception handlers...");
                         for ( t = user_int_handler; t; t = NEXT(t) )        for ( t = user_int_handler; t; t = NEXT(t) )
                                 bevalf((FUNC)BDY(t),0);          bevalf((FUNC)BDY(t),0);
                         fprintf(stderr, "done.\n");        fprintf(stderr, "done.\n");
                 }      }
                 LEAVE_SIGNAL_CS_ALL;      LEAVE_SIGNAL_CS_ALL;
                 ox_resetenv("usr1 : return to toplevel by SIGUSR1");      ox_resetenv("usr1 : return to toplevel by SIGUSR1");
         }    }
 }  }
   
 void clear_readbuffer()  void clear_readbuffer()
 {  {
 #if defined(linux)  #if defined(linux)
         iofp[0].in->_IO_read_ptr = iofp[0].in->_IO_read_end;    iofp[0].in->_IO_read_ptr = iofp[0].in->_IO_read_end;
 #elif defined(__FreeBSD__)  #elif defined(__FreeBSD__)
         fpurge(iofp[0].in);    fpurge(iofp[0].in);
 #endif  #endif
 /*  /*
         sock = fileno(iofp[0].in);    sock = fileno(iofp[0].in);
         interval.tv_sec = (int)0;    interval.tv_sec = (int)0;
         interval.tv_usec = (int)0;    interval.tv_usec = (int)0;
   
         FD_ZERO(&r); FD_ZERO(&w); FD_ZERO(&e);    FD_ZERO(&r); FD_ZERO(&w); FD_ZERO(&e);
         FD_SET(sock,&r);    FD_SET(sock,&r);
         while ( 1 ) {    while ( 1 ) {
                 n = select(FD_SETSIZE,&r,&w,&e,&interval);      n = select(FD_SETSIZE,&r,&w,&e,&interval);
                 if ( !n )      if ( !n )
                         break;        break;
                 read(sock,&c,1);      read(sock,&c,1);
         }    }
 */  */
 }  }
   
 #if MPI  #if MPI
 int ox_data_is_available(int s)  int ox_data_is_available(int s)
 {  {
         return 1;    return 1;
 }  }
   
 void wait_for_data(int s)  void wait_for_data(int s)
 {  {
         return;    return;
 }  }
   
 void wait_for_data_102(int rank)  void wait_for_data_102(int rank)
 {  {
         return;    return;
 }  }
 #else  #else
 int ox_data_is_available(int s)  int ox_data_is_available(int s)
 {  {
         return FP_DATA_IS_AVAILABLE(iofp[s].in);    return FP_DATA_IS_AVAILABLE(iofp[s].in);
 }  }
   
 void wait_for_data(int s)  void wait_for_data(int s)
 {  {
         fd_set r;    fd_set r;
         int sock;    int sock;
   
         if ( !FP_DATA_IS_AVAILABLE(iofp[s].in) ) {    if ( !FP_DATA_IS_AVAILABLE(iofp[s].in) ) {
 #if defined(VISUAL) || defined(__MINGW32__)  #if defined(VISUAL) || defined(__MINGW32__)
                 sock = iofp[s].in->fildes;      sock = iofp[s].in->fildes;
                 FD_ZERO(&r);      FD_ZERO(&r);
                 FD_SET((unsigned int)sock,&r);      FD_SET((unsigned int)sock,&r);
                 select(0,&r,NULL,NULL,NULL);      select(0,&r,NULL,NULL,NULL);
 #else  #else
                 sock = fileno(iofp[s].in);      sock = fileno(iofp[s].in);
                 FD_ZERO(&r);      FD_ZERO(&r);
                 FD_SET(sock,&r);      FD_SET(sock,&r);
                 select(FD_SETSIZE,&r,NULL,NULL,NULL);      select(FD_SETSIZE,&r,NULL,NULL,NULL);
 #endif  #endif
         }    }
 }  }
   
 void wait_for_data_102(int rank)  void wait_for_data_102(int rank)
 {  {
         fd_set r;    fd_set r;
         int sock;    int sock;
   
         if ( !FP_DATA_IS_AVAILABLE(iofp_102[rank].in) ) {    if ( !FP_DATA_IS_AVAILABLE(iofp_102[rank].in) ) {
 #if defined(VISUAL) || defined(__MINGW32__)  #if defined(VISUAL) || defined(__MINGW32__)
                 sock = iofp_102[rank].in->fildes;      sock = iofp_102[rank].in->fildes;
                 FD_ZERO(&r);      FD_ZERO(&r);
                 FD_SET((unsigned int)sock,&r);      FD_SET((unsigned int)sock,&r);
                 select(0,&r,NULL,NULL,NULL);      select(0,&r,NULL,NULL,NULL);
 #else  #else
                 sock = fileno(iofp_102[rank].in);      sock = fileno(iofp_102[rank].in);
                 FD_ZERO(&r);      FD_ZERO(&r);
                 FD_SET(sock,&r);      FD_SET(sock,&r);
                 select(FD_SETSIZE,&r,NULL,NULL,NULL);      select(FD_SETSIZE,&r,NULL,NULL,NULL);
 #endif  #endif
         }    }
 }  }
 #endif  #endif
   
 void ox_send_data(int s,pointer p)  void ox_send_data(int s,pointer p)
 {  {
         ERR err;    ERR err;
     Obj p0;      Obj p0;
   
     p0 = (Obj)p;      p0 = (Obj)p;
         if ( ox_check && !ox_check_cmo(s,(Obj)p) ) {    if ( ox_check && !ox_check_cmo(s,(Obj)p) ) {
                 create_error(&err,ox_serial,"ox_send_data : Mathcap violation",0);      create_error(&err,ox_serial,"ox_send_data : Mathcap violation",0);
                 p = (pointer)err;      p = (pointer)err;
         }    }
         begin_critical();    begin_critical();
         ox_write_int(s,OX_DATA);    ox_write_int(s,OX_DATA);
         ox_write_int(s,ox_serial++);    ox_write_int(s,ox_serial++);
         ox_write_cmo(s,p);    ox_write_cmo(s,p);
         ox_flush_stream(s);    ox_flush_stream(s);
         end_critical();    end_critical();
 }  }
   
 void ox_send_data_102(int rank,pointer p)  void ox_send_data_102(int rank,pointer p)
 {  {
         ERR err;    ERR err;
   
         begin_critical();    begin_critical();
         ox_write_int_102(rank,OX_DATA);    ox_write_int_102(rank,OX_DATA);
         ox_write_int_102(rank,ox_serial++);    ox_write_int_102(rank,ox_serial++);
         ox_write_cmo_102(rank,p);    ox_write_cmo_102(rank,p);
         ox_flush_stream_102(rank);    ox_flush_stream_102(rank);
         end_critical();    end_critical();
 }  }
   
 void ox_bcast_102(int root)  void ox_bcast_102(int root)
 {  {
         Obj data;    Obj data;
         int r,mask,id,src,dst;    int r,mask,id,src,dst;
   
         r = myrank_102-root;    r = myrank_102-root;
         if ( r == 0 )    if ( r == 0 )
                 data = (Obj)asir_pop_one();      data = (Obj)asir_pop_one();
   
         if ( r < 0 ) r += nserver_102;    if ( r < 0 ) r += nserver_102;
         for ( mask = 1; mask < nserver_102; mask <<= 1 )    for ( mask = 1; mask < nserver_102; mask <<= 1 )
                 if ( r&mask ) {      if ( r&mask ) {
                         src = myrank_102-mask;        src = myrank_102-mask;
                         if ( src < 0 ) src += nserver_102;        if ( src < 0 ) src += nserver_102;
                         ox_recv_102(src,&id,&data);        ox_recv_102(src,&id,&data);
                         break;        break;
                 }      }
         for ( mask >>= 1; mask > 0; mask >>= 1 )    for ( mask >>= 1; mask > 0; mask >>= 1 )
                 if ( (r+mask) < nserver_102 ) {      if ( (r+mask) < nserver_102 ) {
                         dst = myrank_102+mask;        dst = myrank_102+mask;
                         if ( dst >= nserver_102 ) dst -= nserver_102;        if ( dst >= nserver_102 ) dst -= nserver_102;
                         ox_send_data_102(dst,data);        ox_send_data_102(dst,data);
                 }      }
         asir_push_one(data);    asir_push_one(data);
 }  }
   
 /* func : an arithmetic funcion func(vl,a,b,*c) */  /* func : an arithmetic funcion func(vl,a,b,*c) */
   
 void ox_reduce_102(int root,void (*func)())  void ox_reduce_102(int root,void (*func)())
 {  {
         Obj data,data0,t;    Obj data,data0,t;
         int r,mask,id,src,dst;    int r,mask,id,src,dst;
   
         r = myrank_102-root;    r = myrank_102-root;
         if ( r < 0 ) r += nserver_102;    if ( r < 0 ) r += nserver_102;
         data = (Obj)asir_pop_one();    data = (Obj)asir_pop_one();
         for ( mask = 1; mask < nserver_102; mask <<= 1 )    for ( mask = 1; mask < nserver_102; mask <<= 1 )
                 if ( r&mask ) {      if ( r&mask ) {
                         dst = (r-mask)+root;        dst = (r-mask)+root;
                         if ( dst >= nserver_102 ) dst -= nserver_102;        if ( dst >= nserver_102 ) dst -= nserver_102;
                         ox_send_data_102(dst,data);        ox_send_data_102(dst,data);
                         break;        break;
                 } else {      } else {
                         src = r+mask;        src = r+mask;
                         if ( src < nserver_102 ) {        if ( src < nserver_102 ) {
                                 src += root;          src += root;
                                 if ( src >= nserver_102 ) src -= nserver_102;          if ( src >= nserver_102 ) src -= nserver_102;
                                 ox_recv_102(src,&id,&data0);          ox_recv_102(src,&id,&data0);
                                 (*func)(CO,data,data0,&t); data = t;          (*func)(CO,data,data0,&t); data = t;
                         }        }
                 }      }
         asir_push_one(r?0:data);    asir_push_one(r?0:data);
 }  }
   
 void ox_send_cmd(int s,int id)  void ox_send_cmd(int s,int id)
 {  {
         if ( ox_check && !check_sm_by_mc(s,id) )    if ( ox_check && !check_sm_by_mc(s,id) )
                 error("ox_send_cmd : Mathcap violation");      error("ox_send_cmd : Mathcap violation");
         begin_critical();    begin_critical();
         ox_write_int(s,OX_COMMAND);    ox_write_int(s,OX_COMMAND);
         ox_write_int(s,ox_serial++);    ox_write_int(s,ox_serial++);
         ox_write_int(s,id);    ox_write_int(s,id);
         ox_flush_stream(s);    ox_flush_stream(s);
         end_critical();    end_critical();
 }  }
   
 void ox_send_sync(int s)  void ox_send_sync(int s)
 {  {
         begin_critical();    begin_critical();
         ox_write_int(s,OX_SYNC_BALL);    ox_write_int(s,OX_SYNC_BALL);
         ox_write_int(s,ox_serial++);    ox_write_int(s,ox_serial++);
         ox_flush_stream(s);    ox_flush_stream(s);
         end_critical();    end_critical();
 }  }
   
 void ox_send_sync_102(int rank)  void ox_send_sync_102(int rank)
 {  {
         begin_critical();    begin_critical();
         ox_write_int_102(rank,OX_SYNC_BALL);    ox_write_int_102(rank,OX_SYNC_BALL);
         ox_write_int_102(rank,ox_serial++);    ox_write_int_102(rank,ox_serial++);
         ox_flush_stream_102(rank);    ox_flush_stream_102(rank);
         end_critical();    end_critical();
 }  }
   
 void ox_send_local_data(int s,Obj p)  void ox_send_local_data(int s,Obj p)
 {  {
         begin_critical();    begin_critical();
         ox_write_int(s,OX_LOCAL_OBJECT_ASIR);    ox_write_int(s,OX_LOCAL_OBJECT_ASIR);
         ox_write_int(s,ox_serial++);    ox_write_int(s,ox_serial++);
         ox_write_int(s,ASIR_OBJ);    ox_write_int(s,ASIR_OBJ);
         saveobj((FILE *)iofp[s].out,p);    saveobj((FILE *)iofp[s].out,p);
         ox_flush_stream(s);    ox_flush_stream(s);
         end_critical();    end_critical();
 }  }
   
 void ox_send_local_data_102(int rank,Obj p)  void ox_send_local_data_102(int rank,Obj p)
 {  {
         begin_critical();    begin_critical();
         ox_write_int_102(rank,OX_LOCAL_OBJECT_ASIR);    ox_write_int_102(rank,OX_LOCAL_OBJECT_ASIR);
         ox_write_int_102(rank,ox_serial++);    ox_write_int_102(rank,ox_serial++);
         ox_write_int_102(rank,ASIR_OBJ);    ox_write_int_102(rank,ASIR_OBJ);
         saveobj((FILE *)iofp_102[rank].out,p);    saveobj((FILE *)iofp_102[rank].out,p);
         ox_flush_stream_102(rank);    ox_flush_stream_102(rank);
         end_critical();    end_critical();
 }  }
   
 void ox_send_local_ring(int s,VL vl)  void ox_send_local_ring(int s,VL vl)
 {  {
         begin_critical();    begin_critical();
         ox_write_int(s,OX_LOCAL_OBJECT_ASIR);    ox_write_int(s,OX_LOCAL_OBJECT_ASIR);
         ox_write_int(s,ox_serial++);    ox_write_int(s,ox_serial++);
         ox_write_int(s,ASIR_VL);    ox_write_int(s,ASIR_VL);
         savevl((FILE *)iofp[s].out,vl);    savevl((FILE *)iofp[s].out,vl);
         ox_flush_stream(s);    ox_flush_stream(s);
         end_critical();    end_critical();
 }  }
   
 void ox_send_local_ring_102(int rank,VL vl)  void ox_send_local_ring_102(int rank,VL vl)
 {  {
         begin_critical();    begin_critical();
         ox_write_int_102(rank,OX_LOCAL_OBJECT_ASIR);    ox_write_int_102(rank,OX_LOCAL_OBJECT_ASIR);
         ox_write_int_102(rank,ox_serial++);    ox_write_int_102(rank,ox_serial++);
         ox_write_int_102(rank,ASIR_VL);    ox_write_int_102(rank,ASIR_VL);
         savevl((FILE *)iofp_102[rank].out,vl);    savevl((FILE *)iofp_102[rank].out,vl);
         ox_flush_stream_102(rank);    ox_flush_stream_102(rank);
         end_critical();    end_critical();
 }  }
   
 unsigned int ox_recv(int s, int *id, Obj *p)  unsigned int ox_recv(int s, int *id, Obj *p)
 {  {
         unsigned int cmd,serial;    unsigned int cmd,serial;
         USINT ui;    USINT ui;
   
         wait_for_data(s);    wait_for_data(s);
         begin_critical();    begin_critical();
         ox_read_int(s,id);    ox_read_int(s,id);
         ox_read_int(s,&serial);    ox_read_int(s,&serial);
         switch ( *id ) {    switch ( *id ) {
                 case OX_COMMAND:      case OX_COMMAND:
                         ox_read_int(s,&cmd);        ox_read_int(s,&cmd);
                         MKUSINT(ui,cmd);        MKUSINT(ui,cmd);
                         *p = (Obj)ui;        *p = (Obj)ui;
                         break;        break;
                 case OX_DATA:      case OX_DATA:
                         ox_read_cmo(s,p);        ox_read_cmo(s,p);
                         break;        break;
                 case OX_LOCAL_OBJECT_ASIR:      case OX_LOCAL_OBJECT_ASIR:
                         ox_read_local(s,p);        ox_read_local(s,p);
                         break;        break;
                 default:      default:
                         *p = 0;        *p = 0;
                         break;        break;
         }    }
         end_critical();    end_critical();
         return serial;    return serial;
 }  }
   
 unsigned int ox_recv_102(int rank, int *id, Obj *p)  unsigned int ox_recv_102(int rank, int *id, Obj *p)
 {  {
         unsigned int cmd,serial;    unsigned int cmd,serial;
         USINT ui;    USINT ui;
   
         wait_for_data_102(rank);    wait_for_data_102(rank);
         begin_critical();    begin_critical();
         ox_read_int_102(rank,id);    ox_read_int_102(rank,id);
         ox_read_int_102(rank,&serial);    ox_read_int_102(rank,&serial);
         switch ( *id ) {    switch ( *id ) {
                 case OX_COMMAND:      case OX_COMMAND:
                         ox_read_int_102(rank,&cmd);        ox_read_int_102(rank,&cmd);
                         MKUSINT(ui,cmd);        MKUSINT(ui,cmd);
                         *p = (Obj)ui;        *p = (Obj)ui;
                         break;        break;
                 case OX_DATA:      case OX_DATA:
                         ox_read_cmo_102(rank,p);        ox_read_cmo_102(rank,p);
                         break;        break;
                 case OX_LOCAL_OBJECT_ASIR:      case OX_LOCAL_OBJECT_ASIR:
                         ox_read_local_102(rank,p);        ox_read_local_102(rank,p);
                         break;        break;
                 default:      default:
                         *p = 0;        *p = 0;
                         break;        break;
         }    }
         end_critical();    end_critical();
         return serial;    return serial;
 }  }
   
 void ox_get_result(int s,Obj *rp)  void ox_get_result(int s,Obj *rp)
 {  {
         int id;    int id;
         Obj obj,r;    Obj obj,r;
         int level;    int level;
   
         level = 0;    level = 0;
         r = 0;    r = 0;
         do {    do {
                 ox_recv(s,&id,&obj);      ox_recv(s,&id,&obj);
                 if ( id == OX_COMMAND ) {      if ( id == OX_COMMAND ) {
                         switch ( ((USINT)obj)->body ) {        switch ( ((USINT)obj)->body ) {
                                 case SM_beginBlock:          case SM_beginBlock:
                                         level++;            level++;
                                         break;            break;
                                 case SM_endBlock:          case SM_endBlock:
                                         level--;            level--;
                         }        }
                 } else      } else
                         r = obj;        r = obj;
         } while ( level );    } while ( level );
         *rp = r;    *rp = r;
 }  }
   
 void ox_read_int(int s, int *n)  void ox_read_int(int s, int *n)
 {  {
         ox_need_conv = iofp[s].conv;    ox_need_conv = iofp[s].conv;
         read_int((FILE *)iofp[s].in,n);    read_int((FILE *)iofp[s].in,n);
 }  }
   
 void ox_read_int_102(int rank, int *n)  void ox_read_int_102(int rank, int *n)
 {  {
         ox_need_conv = iofp_102[rank].conv;    ox_need_conv = iofp_102[rank].conv;
         read_int((FILE *)iofp_102[rank].in,n);    read_int((FILE *)iofp_102[rank].in,n);
 }  }
   
 void ox_read_cmo(int s, Obj *rp)  void ox_read_cmo(int s, Obj *rp)
 {  {
         ox_need_conv = iofp[s].conv;    ox_need_conv = iofp[s].conv;
         read_cmo((FILE *)iofp[s].in,rp);    read_cmo((FILE *)iofp[s].in,rp);
 }  }
   
 void ox_read_cmo_102(int rank, Obj *rp)  void ox_read_cmo_102(int rank, Obj *rp)
 {  {
         ox_need_conv = iofp_102[rank].conv;    ox_need_conv = iofp_102[rank].conv;
         read_cmo((FILE *)iofp_102[rank].in,rp);    read_cmo((FILE *)iofp_102[rank].in,rp);
 }  }
   
   
 void ox_read_local(int s, Obj *rp)  void ox_read_local(int s, Obj *rp)
 {  {
         int id;    int id;
   
         ox_need_conv = iofp[s].conv;    ox_need_conv = iofp[s].conv;
         read_int((FILE *)iofp[s].in,&id);    read_int((FILE *)iofp[s].in,&id);
         switch ( id ) {    switch ( id ) {
                 case ASIR_VL:      case ASIR_VL:
                         loadvl((FILE *)iofp[s].in);        loadvl((FILE *)iofp[s].in);
                         *rp = VOIDobj;        *rp = VOIDobj;
                         break;        break;
                 case ASIR_OBJ:      case ASIR_OBJ:
                         loadobj((FILE *)iofp[s].in,rp);        loadobj((FILE *)iofp[s].in,rp);
                         break;        break;
                 default:      default:
                         error("ox_read_local : unsupported id");        error("ox_read_local : unsupported id");
                         break;        break;
         }    }
 }  }
   
 void ox_read_local_102(int rank, Obj *rp)  void ox_read_local_102(int rank, Obj *rp)
 {  {
         int id;    int id;
   
         ox_need_conv = iofp_102[rank].conv;    ox_need_conv = iofp_102[rank].conv;
         read_int((FILE *)iofp_102[rank].in,&id);    read_int((FILE *)iofp_102[rank].in,&id);
         switch ( id ) {    switch ( id ) {
                 case ASIR_VL:      case ASIR_VL:
                         loadvl((FILE *)iofp_102[rank].in);        loadvl((FILE *)iofp_102[rank].in);
                         *rp = VOIDobj;        *rp = VOIDobj;
                         break;        break;
                 case ASIR_OBJ:      case ASIR_OBJ:
                         loadobj((FILE *)iofp_102[rank].in,rp);        loadobj((FILE *)iofp_102[rank].in,rp);
                         break;        break;
                 default:      default:
                         error("ox_read_local_102 : unsupported id");        error("ox_read_local_102 : unsupported id");
                         break;        break;
         }    }
 }  }
   
 void ox_write_int(int s, int n)  void ox_write_int(int s, int n)
 {  {
         ox_need_conv = iofp[s].conv;    ox_need_conv = iofp[s].conv;
         write_int((FILE *)iofp[s].out,&n);    write_int((FILE *)iofp[s].out,&n);
 }  }
   
 void ox_write_int_102(int rank, int n)  void ox_write_int_102(int rank, int n)
 {  {
         ox_need_conv = iofp_102[rank].conv;    ox_need_conv = iofp_102[rank].conv;
         write_int((FILE *)iofp_102[rank].out,&n);    write_int((FILE *)iofp_102[rank].out,&n);
 }  }
   
 void ox_write_cmo(int s, Obj obj)  void ox_write_cmo(int s, Obj obj)
 {  {
         ox_need_conv = iofp[s].conv;    ox_need_conv = iofp[s].conv;
         write_cmo((FILE *)iofp[s].out,obj);    write_cmo((FILE *)iofp[s].out,obj);
 }  }
   
 void ox_write_cmo_102(int rank, Obj obj)  void ox_write_cmo_102(int rank, Obj obj)
 {  {
         ox_need_conv = iofp_102[rank].conv;    ox_need_conv = iofp_102[rank].conv;
         write_cmo((FILE *)iofp_102[rank].out,obj);    write_cmo((FILE *)iofp_102[rank].out,obj);
 }  }
   
 int ox_check_cmo(int s, Obj obj)  int ox_check_cmo(int s, Obj obj)
 {  {
         NODE m;    NODE m;
   
         if ( !obj )    if ( !obj )
                 return 1;      return 1;
         switch ( OID(obj) ) {    switch ( OID(obj) ) {
                 case O_MATHCAP: case O_STR: case O_ERR: case O_USINT: case O_VOID:      case O_MATHCAP: case O_STR: case O_ERR: case O_USINT: case O_VOID:
                 case O_BYTEARRAY:      case O_BYTEARRAY:
                         return 1;        return 1;
                 case O_P:      case O_P:
                         if ( !check_by_mc(s,OX_DATA,CMO_RECURSIVE_POLYNOMIAL) )        if ( !check_by_mc(s,OX_DATA,CMO_RECURSIVE_POLYNOMIAL) )
                                 return 0;          return 0;
                         else        else
                                 return ox_check_cmo_p(s,(P)obj);          return ox_check_cmo_p(s,(P)obj);
                 case O_R:      case O_R:
                         if ( !check_by_mc(s,OX_DATA,CMO_RATIONAL) )        if ( !check_by_mc(s,OX_DATA,CMO_RATIONAL) )
                                 return 0;          return 0;
                         else if ( !check_by_mc(s,OX_DATA,CMO_RECURSIVE_POLYNOMIAL) )        else if ( !check_by_mc(s,OX_DATA,CMO_RECURSIVE_POLYNOMIAL) )
                                 return 0;          return 0;
                         else        else
                                 return ox_check_cmo_p(s,NM((R)obj)) && ox_check_cmo_p(s,DN((R)obj));          return ox_check_cmo_p(s,NM((R)obj)) && ox_check_cmo_p(s,DN((R)obj));
                 case O_DP:      case O_DP:
                         return ox_check_cmo_dp(s,(DP)obj);        return ox_check_cmo_dp(s,(DP)obj);
                 case O_N:      case O_N:
                         switch ( NID((Num)obj) ) {        switch ( NID((Num)obj) ) {
                                 case N_Q:          case N_Q:
                                         if ( INT((Q)obj) )            if ( INT((Q)obj) )
                                                 return check_by_mc(s,OX_DATA,CMO_ZZ);              return check_by_mc(s,OX_DATA,CMO_ZZ);
                                         else            else
                                                 return check_by_mc(s,OX_DATA,CMO_QQ);              return check_by_mc(s,OX_DATA,CMO_QQ);
                                 case N_R: case N_B: case N_C:          case N_R: case N_B: case N_C:
                                         return 1;            return 1;
                                 default:          default:
                                         return 0;            return 0;
                         }        }
                         break;        break;
                 case O_LIST:      case O_LIST:
                         for ( m = BDY((LIST)obj); m; m = NEXT(m) )        for ( m = BDY((LIST)obj); m; m = NEXT(m) )
                                 if ( !ox_check_cmo(s,(BDY(m))) )          if ( !ox_check_cmo(s,(BDY(m))) )
                                         return 0;            return 0;
                         return 1;        return 1;
                 case O_QUOTE: /* XXX */      case O_QUOTE: /* XXX */
                         return 1;        return 1;
     case O_MAT: /* MAT is sent as a list */      case O_MAT: /* MAT is sent as a list */
                         return 1;        return 1;
                 default:      default:
                         return 0;        return 0;
         }    }
 }  }
   
 void ox_get_serverinfo(int s, LIST *rp)  void ox_get_serverinfo(int s, LIST *rp)
 {  {
         if ( remote_mc )    if ( remote_mc )
                 *rp = remote_mc[s].mc;      *rp = remote_mc[s].mc;
         else {    else {
                 MKLIST(*rp,0);      MKLIST(*rp,0);
         }    }
 }  }
   
 char *ox_get_servername(int s)  char *ox_get_servername(int s)
 {  {
         return (remote_mc && remote_mc[s].servername)?remote_mc[s].servername:0;    return (remote_mc && remote_mc[s].servername)?remote_mc[s].servername:0;
 }  }
   
   
 int ox_check_cmo_p(int s, P p)  int ox_check_cmo_p(int s, P p)
 {  {
         DCP dc;    DCP dc;
   
         if ( NUM(p) )    if ( NUM(p) )
                 return ox_check_cmo(s,(Obj)p);      return ox_check_cmo(s,(Obj)p);
         else {    else {
                 for ( dc = DC(p); dc; dc = NEXT(dc) )      for ( dc = DC(p); dc; dc = NEXT(dc) )
                         if ( !ox_check_cmo_p(s,COEF(dc)) )        if ( !ox_check_cmo_p(s,COEF(dc)) )
                                 return 0;          return 0;
                 return 1;      return 1;
         }    }
 }  }
   
 int ox_check_cmo_dp(int s, DP p)  int ox_check_cmo_dp(int s, DP p)
 {  {
         MP m;    MP m;
   
         for ( m = BDY(p); m; m = NEXT(m) )    for ( m = BDY(p); m; m = NEXT(m) )
                 if ( !ox_check_cmo(s,(Obj)m->c) )      if ( !ox_check_cmo(s,(Obj)m->c) )
                         return 0;        return 0;
         return 1;    return 1;
 }  }
   
 void ox_flush_stream(int s)  void ox_flush_stream(int s)
 {  {
         if ( ox_batch )    if ( ox_batch )
                 return;      return;
 #if defined(VISUAL) || defined(__MINGW32__)  #if defined(VISUAL) || defined(__MINGW32__)
         if ( _fileno(&iofp[s].out->fp) < 0 )    if ( _fileno(&iofp[s].out->fp) < 0 )
                 cflush(iofp[s].out);      cflush(iofp[s].out);
         else    else
 #elif MPI  #elif MPI
         if ( (char)fileno(&iofp[s].out->fp) < 0 )    if ( (char)fileno(&iofp[s].out->fp) < 0 )
                 cflush(iofp[s].out);      cflush(iofp[s].out);
         else    else
 #endif  #endif
         fflush((FILE *)iofp[s].out);    fflush((FILE *)iofp[s].out);
 }  }
   
 void ox_flush_stream_force(int s)  void ox_flush_stream_force(int s)
 {  {
 #if defined(VISUAL) || defined(__MINGW32__)  #if defined(VISUAL) || defined(__MINGW32__)
         if ( _fileno(&iofp[s].out->fp) < 0 )    if ( _fileno(&iofp[s].out->fp) < 0 )
                 cflush(iofp[s].out);      cflush(iofp[s].out);
         else    else
 #elif MPI  #elif MPI
         if ( (char)fileno(&iofp[s].out->fp) < 0 )    if ( (char)fileno(&iofp[s].out->fp) < 0 )
                 cflush(iofp[s].out);      cflush(iofp[s].out);
         else    else
 #endif  #endif
         fflush((FILE *)iofp[s].out);    fflush((FILE *)iofp[s].out);
 }  }
   
 void ox_flush_stream_102(int rank)  void ox_flush_stream_102(int rank)
 {  {
         if ( !ox_batch )    if ( !ox_batch )
                 ox_flush_stream_force_102(rank);      ox_flush_stream_force_102(rank);
 }  }
   
 void ox_flush_stream_force_102(int rank)  void ox_flush_stream_force_102(int rank)
 {  {
         if ( iofp_102[rank].out )    if ( iofp_102[rank].out )
 #if defined(VISUAL) || defined(__MINGW32__)  #if defined(VISUAL) || defined(__MINGW32__)
                 cflush(iofp_102[rank].out);      cflush(iofp_102[rank].out);
 #elif MPI  #elif MPI
                 cflush(iofp_102[rank].out);      cflush(iofp_102[rank].out);
 #else  #else
                 fflush(iofp_102[rank].out);      fflush(iofp_102[rank].out);
 #endif  #endif
 }  }

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.42

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>