version 1.5, 2000/02/01 02:38:58 |
version 1.10, 2015/09/14 07:56:20 |
|
|
/*$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.9 2005/07/03 11:08:54 ohara Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
|
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
/* #include <netinet/in.h> */ |
/* #include <netinet/in.h> */ |
|
#include <limits.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "stackm.h" |
#include "stackm.h" |
#include "extern.h" |
#include "extern.h" |
|
|
#include "kclass.h" |
#include "kclass.h" |
|
|
#include "gmp.h" |
#include "gmp.h" |
#include "gmp-impl.h" |
#include "gmp-impl.h" |
|
|
|
|
#include "file2.h" |
#include "file2.h" |
#include "cmo.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; |
extern int OxVersion; |
size_t cmoOutGMPCoeff_old(mpz_srcptr x); |
size_t cmoOutGMPCoeff_old(mpz_srcptr x); |
size_t cmoOutGMPCoeff_new(mpz_srcptr x); |
size_t cmoOutGMPCoeff_new(mpz_srcptr x); |
Line 166 cmoOutGMPCoeff_new(mpz_srcptr x) |
|
Line 173 cmoOutGMPCoeff_new(mpz_srcptr x) |
|
tmp[0] = htonl(CMO_ZZ); |
tmp[0] = htonl(CMO_ZZ); |
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); |
cmoOutputToBuf(CMOPUT,tmp,sizeof(cmoint)); |
|
|
if (BITS_PER_CHAR != 8) { |
if (CHAR_BIT != 8) { |
fprintf(stderr,"BITS_PER_CHAR = %d\n",BITS_PER_CHAR); |
fprintf(stderr,"CHAR_BIT = %d\n",CHAR_BIT); |
fprintf(stderr,"cmo-gmp.c does not work on this CPU.\n"); |
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); |
exit(10); |
} |
} |
|
|
Line 195 cmoOutGMPCoeff_new(mpz_srcptr x) |
|
Line 201 cmoOutGMPCoeff_new(mpz_srcptr x) |
|
outRawInt32(((unsigned long)xp[s])&(unsigned long)0xffffffff); |
outRawInt32(((unsigned long)xp[s])&(unsigned long)0xffffffff); |
outRawInt32(((unsigned long)xp[s])>>32); |
outRawInt32(((unsigned long)xp[s])>>32); |
} |
} |
if ( !(xsize&1) ) { |
if ( !(xsize&1) ) { |
outRawInt32(((unsigned long)xp[s])&(unsigned long)0xffffffff); |
outRawInt32(((unsigned long)xp[s])&(unsigned long)0xffffffff); |
outRawInt32(((unsigned long)xp[s])>>32); |
outRawInt32(((unsigned long)xp[s])>>32); |
} else |
} else |
outRawInt32(((unsigned long)xp[s])&(unsigned long)0xffffffff); |
outRawInt32(((unsigned long)xp[s])&(unsigned long)0xffffffff); |
return ( ABS (xsize) ); |
return ( ABS (xsize) ); |
} |
} |
|
|
Line 215 cmoGetGMPCoeff_new(MP_INT *x, struct cmoBuffer *cb) |
|
Line 221 cmoGetGMPCoeff_new(MP_INT *x, struct cmoBuffer *cb) |
|
mp_size_t in_bytesize; |
mp_size_t in_bytesize; |
int neg_flag; |
int neg_flag; |
|
|
if (BITS_PER_CHAR != 8) { |
if (CHAR_BIT != 8) { |
fprintf(stderr,"BITS_PER_CHAR = %d\n",BITS_PER_CHAR); |
fprintf(stderr,"CHAR_BIT = %d\n",CHAR_BIT); |
fprintf(stderr,"cmo-gmp.c does not work on this CPU.\n"); |
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); |
exit(10); |
} |
} |
|
|
Line 231 cmoGetGMPCoeff_new(MP_INT *x, struct cmoBuffer *cb) |
|
Line 236 cmoGetGMPCoeff_new(MP_INT *x, struct cmoBuffer *cb) |
|
if (xsize == 0) |
if (xsize == 0) |
{ |
{ |
x->_mp_size = 0; |
x->_mp_size = 0; |
return 1; /* we've read 4 bytes */ |
return 1; /* we've read 4 bytes */ |
} |
} |
|
|
xsize0 = (xsize+1)/2; |
xsize0 = (xsize+1)/2; |
Line 241 cmoGetGMPCoeff_new(MP_INT *x, struct cmoBuffer *cb) |
|
Line 246 cmoGetGMPCoeff_new(MP_INT *x, struct cmoBuffer *cb) |
|
|
|
for (i=0; i<xsize0-1; i++) { |
for (i=0; i<xsize0-1; i++) { |
xp[i] = ((unsigned long)getRawInt32(cb)) |
xp[i] = ((unsigned long)getRawInt32(cb)) |
|(((unsigned long)getRawInt32(cb))<<32); |
|(((unsigned long)getRawInt32(cb))<<32); |
} |
} |
if ( !(xsize&1) ) |
if ( !(xsize&1) ) |
xp[i] = ((unsigned long)getRawInt32(cb)) |
xp[i] = ((unsigned long)getRawInt32(cb)) |
|(((unsigned long)getRawInt32(cb))<<32); |
|(((unsigned long)getRawInt32(cb))<<32); |
else |
else |
xp[i] = (unsigned long)getRawInt32(cb); |
xp[i] = (unsigned long)getRawInt32(cb); |
|
|
Line 274 cmoOutGMPCoeff_new(mpz_srcptr x) |
|
Line 279 cmoOutGMPCoeff_new(mpz_srcptr x) |
|
fprintf(stderr,"Read the GMP source code and rewrite cmo-gmp.c.\n"); |
fprintf(stderr,"Read the GMP source code and rewrite cmo-gmp.c.\n"); |
exit(10); |
exit(10); |
} |
} |
if (BITS_PER_CHAR != 8) { |
if (CHAR_BIT != 8) { |
fprintf(stderr,"BITS_PER_CHAR = %d\n",BITS_PER_CHAR); |
fprintf(stderr,"CHAR_BIT = %d\n",CHAR_BIT); |
fprintf(stderr,"cmo-gmp.c does not work on this CPU.\n"); |
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); |
exit(10); |
} |
} |
|
|
Line 320 cmoGetGMPCoeff_new(MP_INT *x, struct cmoBuffer *cb) |
|
Line 324 cmoGetGMPCoeff_new(MP_INT *x, struct cmoBuffer *cb) |
|
fprintf(stderr,"Read the GMP source code and rewrite cmo-gmp.c.\n"); |
fprintf(stderr,"Read the GMP source code and rewrite cmo-gmp.c.\n"); |
exit(10); |
exit(10); |
} |
} |
if (BITS_PER_CHAR != 8) { |
if (CHAR_BIT != 8) { |
fprintf(stderr,"BITS_PER_CHAR = %d\n",BITS_PER_CHAR); |
fprintf(stderr,"CHAR_BIT = %d\n",CHAR_BIT); |
fprintf(stderr,"cmo-gmp.c does not work on this CPU.\n"); |
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); |
exit(10); |
} |
} |
|
|
Line 336 cmoGetGMPCoeff_new(MP_INT *x, struct cmoBuffer *cb) |
|
Line 339 cmoGetGMPCoeff_new(MP_INT *x, struct cmoBuffer *cb) |
|
if (xsize == 0) |
if (xsize == 0) |
{ |
{ |
x->_mp_size = 0; |
x->_mp_size = 0; |
return 1; /* we've read 4 bytes */ |
return 1; /* we've read 4 bytes */ |
} |
} |
|
|
if (x->_mp_alloc < xsize) |
if (x->_mp_alloc < xsize) |