=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/plugin/cmo-gmp.c,v retrieving revision 1.5 retrieving revision 1.11 diff -u -p -r1.5 -r1.11 --- OpenXM/src/kan96xx/plugin/cmo-gmp.c 2000/02/01 02:38:58 1.5 +++ OpenXM/src/kan96xx/plugin/cmo-gmp.c 2020/10/06 11:33:47 1.11 @@ -1,7 +1,10 @@ -/*$OpenXM: OpenXM/src/kan96xx/plugin/cmo-gmp.c,v 1.4 1999/11/27 13:24:41 takayama Exp $ */ +/*$OpenXM: OpenXM/src/kan96xx/plugin/cmo-gmp.c,v 1.10 2015/09/14 07:56:20 takayama Exp $ */ #include +#include #include /* #include */ +#include +#include #include "datatype.h" #include "stackm.h" #include "extern.h" @@ -10,24 +13,31 @@ #include "kclass.h" #include "gmp.h" -#include "gmp-impl.h" +#include "gmp-impl.h" #include "file2.h" #include "cmo.h" +/* for gmp6.0.0 */ +#ifndef BYTES_PER_MP_LIMB +#define BYTES_PER_MP_LIMB SIZEOF_MP_LIMB_T +#endif + extern int OxVersion; size_t cmoOutGMPCoeff_old(mpz_srcptr x); size_t cmoOutGMPCoeff_new(mpz_srcptr x); -size_t -cmoOutGMPCoeff(mpz_srcptr x) { +size_t cmoGetGMPCoeff_old(MP_INT *x, struct cmoBuffer *cb); +size_t cmoGetGMPCoeff_new(MP_INT *x, struct cmoBuffer *cb); + +size_t cmoOutGMPCoeff(mpz_srcptr x) { if (OxVersion >= 199907170) return(cmoOutGMPCoeff_new(x)); else return(cmoOutGMPCoeff_old(x)); } -cmoGetGMPCoeff(MP_INT *x, struct cmoBuffer *cb) { +size_t cmoGetGMPCoeff(MP_INT *x, struct cmoBuffer *cb) { if (OxVersion >= 199907170) return(cmoGetGMPCoeff_new(x,cb)); else @@ -64,18 +74,18 @@ static int myfputc(int i) { tmp[0] = i; cmoOutputToBuf(CMOPUT,tmp,1); } -static outRawInt32(int k) +static void outRawInt32(int k) { int tmp[1]; tmp[0] = htonl((int) k); cmoOutputToBuf(CMOPUT,tmp,4); } -size_t -cmoOutGMPCoeff_old(mpz_srcptr x) +size_t cmoOutGMPCoeff_old(mpz_srcptr x) { fprintf(stderr,"cmoOutGMPCoeff_old is no longer supported.\n"); exit(10); + return 0; } @@ -141,18 +151,18 @@ static int getRawInt32(struct cmoBuffer *cb) } #endif -cmoGetGMPCoeff_old(MP_INT *x, struct cmoBuffer *cb) +size_t cmoGetGMPCoeff_old(MP_INT *x, struct cmoBuffer *cb) { fprintf(stderr,"cmoGetGMPCoeff_old is no longer supported.\n"); exit(10); + return 0; } /*****************************************************/ /***** new version for CMO_ZZ *********************/ /*****************************************************/ #if BYTES_PER_MP_LIMB == 8 -size_t -cmoOutGMPCoeff_new(mpz_srcptr x) +size_t cmoOutGMPCoeff_new(mpz_srcptr x) { int i; mp_size_t s; @@ -166,10 +176,9 @@ cmoOutGMPCoeff_new(mpz_srcptr x) tmp[0] = htonl(CMO_ZZ); cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); - if (BITS_PER_CHAR != 8) { - fprintf(stderr,"BITS_PER_CHAR = %d\n",BITS_PER_CHAR); + if (CHAR_BIT != 8) { + fprintf(stderr,"CHAR_BIT = %d\n",CHAR_BIT); fprintf(stderr,"cmo-gmp.c does not work on this CPU.\n"); - fprintf(stderr,"Read the GMP source code and rewrite cmo-gmp.c.\n"); exit(10); } @@ -195,15 +204,15 @@ cmoOutGMPCoeff_new(mpz_srcptr x) outRawInt32(((unsigned long)xp[s])&(unsigned long)0xffffffff); outRawInt32(((unsigned long)xp[s])>>32); } - if ( !(xsize&1) ) { - outRawInt32(((unsigned long)xp[s])&(unsigned long)0xffffffff); - outRawInt32(((unsigned long)xp[s])>>32); - } else - outRawInt32(((unsigned long)xp[s])&(unsigned long)0xffffffff); + if ( !(xsize&1) ) { + outRawInt32(((unsigned long)xp[s])&(unsigned long)0xffffffff); + outRawInt32(((unsigned long)xp[s])>>32); + } else + outRawInt32(((unsigned long)xp[s])&(unsigned long)0xffffffff); return ( ABS (xsize) ); } -cmoGetGMPCoeff_new(MP_INT *x, struct cmoBuffer *cb) +size_t cmoGetGMPCoeff_new(MP_INT *x, struct cmoBuffer *cb) { int i; mp_size_t s; @@ -215,10 +224,9 @@ cmoGetGMPCoeff_new(MP_INT *x, struct cmoBuffer *cb) mp_size_t in_bytesize; int neg_flag; - if (BITS_PER_CHAR != 8) { - fprintf(stderr,"BITS_PER_CHAR = %d\n",BITS_PER_CHAR); + if (CHAR_BIT != 8) { + fprintf(stderr,"CHAR_BIT = %d\n",CHAR_BIT); fprintf(stderr,"cmo-gmp.c does not work on this CPU.\n"); - fprintf(stderr,"Read the GMP source code and rewrite cmo-gmp.c.\n"); exit(10); } @@ -231,7 +239,7 @@ cmoGetGMPCoeff_new(MP_INT *x, struct cmoBuffer *cb) if (xsize == 0) { x->_mp_size = 0; - return 1; /* we've read 4 bytes */ + return 1; /* we've read 4 bytes */ } xsize0 = (xsize+1)/2; @@ -241,11 +249,11 @@ cmoGetGMPCoeff_new(MP_INT *x, struct cmoBuffer *cb) for (i=0; i_mp_size = 0; - return 1; /* we've read 4 bytes */ + return 1; /* we've read 4 bytes */ } if (x->_mp_alloc < xsize)