=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/plugin/cmo.c,v retrieving revision 1.11 retrieving revision 1.18 diff -u -p -r1.11 -r1.18 --- OpenXM/src/kan96xx/plugin/cmo.c 2004/03/08 08:24:42 1.11 +++ OpenXM/src/kan96xx/plugin/cmo.c 2020/10/06 11:33:47 1.18 @@ -1,8 +1,9 @@ -/*$OpenXM: OpenXM/src/kan96xx/plugin/cmo.c,v 1.10 2003/12/06 02:35:54 takayama Exp $*/ +/*$OpenXM: OpenXM/src/kan96xx/plugin/cmo.c,v 1.17 2020/10/04 06:10:36 noro Exp $*/ #include #include /* #include */ #include +#include #include "datatype.h" #include "stackm.h" #include "extern.h" @@ -18,6 +19,13 @@ #include "cmotag.htmp" /* static char *cmotagToName(int tag) is defined here. */ +void warningCmo(char *s); +void errorCmo(char *s); +size_t cmoOutGMPCoeff(mpz_srcptr x); // defined in cmo-gmp.c +size_t cmoGetGMPCoeff(MP_INT *x, struct cmoBuffer *cb); +int cmoCheckMathCap(struct object ob, struct object *mathcapObjp); // in oxmisc2.h + + extern int OxVersion; int CmoClientMode = 1; /* This flag is used to translate names for @@ -47,7 +55,7 @@ extern struct ring *CurrentRingp; extern struct ring *SmallRingp; extern int CmoDMSOutputOption; -struct object NullObjectInCmo; +struct object NullObjectInCmo = OINIT; extern int SerialCurrent; extern int DebugCMO; @@ -156,29 +164,30 @@ struct cmoBuffer *cmoOutputToBuf(cmoAction a,void *dat } } -dumpCmoBuf(struct cmoBuffer *cb) +int dumpCmoBuf(struct cmoBuffer *cb) { int i,size, tag; char *s; if (cb->isStream) { printf("cmoBuffer is directed to a stream.\n"); - return; + return 0; } size = cb->pos; s = (char *)(cb->buf); tag = htonl(*((int *) s)); - printf("CMO StandardEncoding: size = %d, size/sizeof(int) = %d, tag=%s \n",size,size/sizeof(int),cmotagToName(tag)); + printf("CMO StandardEncoding: size = %d, size/sizeof(int) = %d, tag=%s \n",size,size/((int)sizeof(int)),cmotagToName(tag)); for (i=0; i>\n"); fflush(stdout); @@ -1157,7 +1170,8 @@ main() { POLY cmoListToPOLY(struct object ob) { int size,i; - struct object ob0,ob1; + struct object ob0 = OINIT; + struct object ob1 = OINIT; POLY f; /* printf("<<");printObject(ob,0,stdout); printf(">>\n"); fflush(stdout); @@ -1196,7 +1210,7 @@ POLY cmoListToPOLY(struct object ob) int Kan_PushBinary(int size,void *data) { struct cmoBuffer cb; - struct object ob; + struct object ob = OINIT; cb.pos = size; cb.rpos = 0; cb.buf = data; @@ -1209,7 +1223,7 @@ int Kan_PushBinary(int size,void *data) void *Kan_PopBinary(int *sizep) { - struct object ob; + struct object ob = OINIT; struct cmoBuffer *cb; ob = KSpop(); ob = cmoObjectToCmo(ob); @@ -1228,8 +1242,8 @@ void *Kan_PopBinary(int *sizep) struct object cmoObjectFromStream(struct object obStream) { struct cmoBuffer cb; - struct object rob; - extern DebugCMO; + struct object rob = OINIT; + extern int DebugCMO; if (obStream.tag != Sfile) { errorCmo("cmoObjectFromStream: Argument must be of type file."); } @@ -1246,7 +1260,7 @@ struct object cmoObjectFromStream(struct object obStre struct object cmoObjectFromStream2(FILE2 *fp2) { struct cmoBuffer cb; - struct object rob; + struct object rob = OINIT; cb.isStream=1; cb.fp = fp2; cmoGetIntFromBuf(CMOINITSTREAM,&cb); rob = cmoCmoToObject00(&cb); @@ -1261,7 +1275,7 @@ struct object cmoObjectFromStream2(FILE2 *fp2) struct object cmoObjectToStream(struct object ob, struct object obStream) { - struct object rob; + struct object rob = OINIT; extern int DebugCMO; if (obStream.tag != Sfile) { errorCmo("cmoObjectToStream: Argument must be of type file."); @@ -1278,7 +1292,7 @@ struct object cmoObjectToStream(struct object ob, stru struct object cmoObjectToStream2(struct object ob, FILE2 *fp2) { - struct object rob; + struct object rob = OINIT; cmoOutputToBuf(CMOINITSTREAM,(void *)fp2,0); if (DebugCMO) { fprintf(stderr,"cmoObjectToStream2: "); @@ -1292,8 +1306,8 @@ struct object cmoObjectToStream2(struct object ob, FIL int Kan_pushCMOFromStream(FILE2 *fp) { - struct object ob; - struct object rob; + struct object ob = OINIT; + struct object rob = OINIT; ob.tag = Sfile; ob.rc.voidp = (void *)fp; ob.lc.str = MAGIC2; rob = cmoObjectFromStream(ob); KSpush(rob); @@ -1302,8 +1316,8 @@ int Kan_pushCMOFromStream(FILE2 *fp) int Kan_popCMOToStream(FILE2 *fp,int serial) { - struct object ob; - struct object sob; + struct object ob = OINIT; + struct object sob = OINIT; sob.tag = Sfile; sob.rc.file = (void *)fp; sob.lc.str = MAGIC2; ob = Kpop(); /*outfp2(fp);*/ /* outfp2 is for debugging. see develop/97feb.. 1999, 1/19*/ @@ -1326,16 +1340,16 @@ int Kan_setMathCapToStream(FILE2 *fp,struct object ob) /* It is declared in oxmisc2.h, too. */ struct object newMathCap(struct mathCap *mathcap){ - struct object rob; - struct object ob1; - struct object ob2; - struct object ob3; - struct object obOx; - struct object obSm; - struct object ob3tmp; + struct object rob = OINIT; + struct object ob1 = OINIT; + struct object ob2 = OINIT; + struct object ob3 = OINIT; + struct object obOx = OINIT; + struct object obSm = OINIT; + struct object ob3tmp = OINIT; struct object *obp; int i,j; - struct object mathinfo; + struct object mathinfo = OINIT; rob = newObjectArray(3); @@ -1379,7 +1393,7 @@ void *KSmathCapByStruct(void) /* Return the math cap of kan/sm1 with cmo.c as a mathcap classObject*/ { struct mathCap *mathcap; - struct object ob; + struct object ob = OINIT; char *s1,*s2; struct object *mathinfo; char *sys; @@ -1436,8 +1450,9 @@ void *KSmathCapByStruct(void) mathcap->cmo[19]= CMO_64BIT_MACHINE_DOUBLE; mathcap->cmo[20]= CMO_ARRAY; mathcap->cmo[21]= CMO_RATIONAL; + mathcap->cmo[22]= CMO_QQ; - mathcap->n = 22 ; /* This is the number of cmo object. You can use + mathcap->n = 23 ; /* This is the number of cmo object. You can use cmo upto 1023. see mathcap.h */ mathcap->ox[0] = OX_DATA; @@ -1457,7 +1472,8 @@ void *KSmathCapByStruct(void) mathcap->sm[10] = SM_dupErrors; mathcap->sm[11] = SM_pushCMOtag; mathcap->sm[12] = SM_executeFunctionWithOptionalArgument; - mathcap->smSize = 13; + mathcap->sm[13] = SM_nop; + mathcap->smSize = 14; return((void *)mathcap); } @@ -1469,11 +1485,11 @@ int cmoOutRawInt(int k) cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); } -warningCmo(char *s) { +void warningCmo(char *s) { fprintf(stderr,"Warning: plugin/cmo.c : %s\n",s); } -errorCmo(char *s) { +void errorCmo(char *s) { fprintf(stderr,"plugin/cmo.c : %s\n",s); errorKan1("%s\n","cmo fatal error. ox servers need SM_control_reset_connection."); /* ErrorPacket is automatically push on the ErrorStack.