=================================================================== RCS file: /home/cvs/OpenXM_contrib/pari-2.2/src/headers/Attic/parigen.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -r1.1 -r1.2 --- OpenXM_contrib/pari-2.2/src/headers/Attic/parigen.h 2001/10/02 11:17:07 1.1 +++ OpenXM_contrib/pari-2.2/src/headers/Attic/parigen.h 2002/09/11 07:26:58 1.2 @@ -1,4 +1,4 @@ -/* $Id: parigen.h,v 1.1 2001/10/02 11:17:07 noro Exp $ +/* $Id: parigen.h,v 1.2 2002/09/11 07:26:58 noro Exp $ Copyright (C) 2000 The PARI group. @@ -27,118 +27,95 @@ typedef int (*QSCOMP)(const void *, const void *); #endif #ifdef LONG_IS_64BIT -# define MAXULONG (0xffffffffffffffffUL) -# define MAXHALFULONG (0x00000000ffffffffUL) -# define HIGHBIT (0x8000000000000000UL) -# define HIGHMASK (0xffffffff00000000UL) -# define LOWMASK (0x00000000ffffffffUL) -# define SMALL_MASK (0x4000000000000000UL) - -# define DEFAULTPREC 3 -# define MEDDEFAULTPREC 4 -# define BIGDEFAULTPREC 5 # define TWOPOTBYTES_IN_LONG 3 -# define TWOPOTBITS_IN_LONG 6 -# define BYTES_IN_LONG 8 -# define BITS_IN_LONG 64 -# define BITS_IN_HALFULONG 32 -/* For a 64-bit random generator, change the following 32 to 64 */ -# define BITS_IN_RANDOM 32 - #else - -# define MAXULONG (0xffffffffUL) -# define MAXHALFULONG (0x0000ffffUL) -# define HIGHBIT (0x80000000UL) -# define HIGHMASK (0xffff0000UL) -# define LOWMASK (0x0000ffffUL) -# define SMALL_MASK (0x40000000UL) - -# define DEFAULTPREC 4 -# define MEDDEFAULTPREC 6 -# define BIGDEFAULTPREC 8 # define TWOPOTBYTES_IN_LONG 2 -# define TWOPOTBITS_IN_LONG 5 -# define BYTES_IN_LONG 4 -# define BITS_IN_LONG 32 -# define BITS_IN_HALFULONG 16 -# define BITS_IN_RANDOM 32 #endif -#ifndef LONG_IS_64BIT -/* second codeword x[1], for types: INT,REAL,PADIC,POL,SER */ -# define EXPOBITS (0x00ffffffUL) -# define HIGHEXPOBIT (0x00800000L) -# define LGEFBITS (0x0000ffffUL) -# define VALPBITS (0x0000ffffUL) /* used only for type PADIC */ -# define HIGHVALPBIT (0x00008000L) /* used only for type PADIC, SER */ -# define PRECPBITS (0xffff0000UL) /* used only for type PADIC */ -# define PRECPSHIFT 16 -# define VARNSHIFT 16 +#define DEFAULTPREC 2 + (8>>TWOPOTBYTES_IN_LONG) +#define MEDDEFAULTPREC 2 + (16>>TWOPOTBYTES_IN_LONG) +#define BIGDEFAULTPREC 2 + (24>>TWOPOTBYTES_IN_LONG) +#define TWOPOTBITS_IN_LONG (TWOPOTBYTES_IN_LONG+3) +#define BYTES_IN_LONG (1UL<>1) +#define MAXULONG (~0x0UL) +#define MAXHALFULONG ((1UL<>1) +/* You may want to change the following 32 to BITS_IN_LONG */ +#define BITS_IN_RANDOM 32 -# ifndef OLD_CODES -# define SIGNBITS (0xc0000000UL) -# define VARNBITS (0x3fff0000UL) -# define LGEFINTBITS (0x00ffffffUL) -# define SIGNSHIFT 30 -# define MAXVARN 16383 -# else -# define SIGNBITS (0xff000000UL) -# define VARNBITS (0x00ff0000UL) -# define LGEFINTBITS (0x0000ffffUL) -# define SIGNSHIFT 24 -# define MAXVARN 255 -# endif +/* Order of bits in codewords: + * x[0] TYPBITS, CLONEBIT, LGBITS + * x[1].real SIGNBITS, EXPOBITS + * int SIGNBITS, LGEFINTBITS + * ser,pol SIGNBITS, VARNBITS ,LGEFBITS + * padic VALPBITS, PRECPBITS + * Length of bitfields are independant and satisfy: + * TYPnumBITS + LGnumBITS + 1 <= BITS_IN_LONG (optimally =) + * SIGNnumBITS + EXPOnumBITS <= BITS_IN_LONG + * SIGNnumBITS + LGnumBITS <= BITS_IN_LONG + * SIGNnumBITS + LGEFnumBITS + 2 <= BITS_IN_LONG + * VALPnumbits + 1 <= BITS_IN_LONG */ +#ifdef OLD_CODES +# define TYPnumBITS 8 /* obsolete (for hard-coded assembler in mp.s) */ +# define SIGNnumBITS 8 +#else +# define TYPnumBITS 7 +# define SIGNnumBITS 2 +#endif -/* first codeword x[0] */ -# ifndef OLD_CODES -# define TYPBITS (0xfe000000UL) -# define CLONEBIT (0x01000000UL) -# define LGBITS (0x00ffffffUL) -# define TYPSHIFT 25 +#ifdef LONG_IS_64BIT +# define LGnumBITS 32 +# define EXPOnumBITS 48 +# define LGEFnumBITS 46 /* otherwise MAXVARN too large */ +# define VALPnumBITS 32 +#else +# ifdef OLD_CODES +# define LGnumBITS 16 /* obsolete */ # else -# define TYPBITS (0xff000000UL) -# define CLONEBIT (0x00010000UL) -# define LGBITS (0x0000ffffUL) -# define TYPSHIFT 24 +# define LGnumBITS 24 # endif +# define EXPOnumBITS 24 +# define LGEFnumBITS 16 +# define VALPnumBITS 16 #endif -#ifdef LONG_IS_64BIT -/* first codeword x[0] */ -# define TYPBITS (0xffff000000000000UL) -# define CLONEBIT (0x0000000100000000UL) -# define LGBITS (0x00000000ffffffffUL) -# define TYPSHIFT 48 +/* no user serviceable parts below :-) */ +#define VARNnumBITS (BITS_IN_LONG - SIGNnumBITS - LGEFnumBITS) +#define PRECPSHIFT VALPnumBITS +#define VARNSHIFT LGEFnumBITS +#define TYPSHIFT (BITS_IN_LONG - TYPnumBITS) +#define SIGNSHIFT (LGEFnumBITS+VARNnumBITS) -/* second codeword x[1] */ -# define SIGNBITS (0xffff000000000000UL) -# define VARNBITS (0x0000ffff00000000UL) -# define LGEFBITS (0x00000000ffffffffUL) -# define SIGNSHIFT 48 -# define MAXVARN 65535 +#define EXPOBITS ((1UL<> TYPSHIFT)) +#define typ(x) ((((ulong)(x))&1)? (long)t_SMALL: (long)(((ulong) ((GEN) (x))[0]) >> TYPSHIFT)) #define settyp(x,s) (((GEN)(x))[0]=\ (((GEN)(x))[0]&(~TYPBITS)) | evaltyp(s)) #define smalltos(x) (((long)(x))>>1) @@ -147,7 +124,7 @@ typedef int (*QSCOMP)(const void *, const void *); #define setisclone(x) (((GEN) (x))[0] |= CLONEBIT) #define unsetisclone(x) (((GEN) (x))[0] &= (~CLONEBIT)) -#define lg(x) ((((long)(x))&1)?1: ((long) (((GEN) (x))[0] & LGBITS))) +#define lg(x) ((((ulong)(x))&1)?1L: ((long) (((GEN) (x))[0] & LGBITS))) #define setlg(x,s) (((GEN)(x))[0]=\ (((GEN)(x))[0]&(~LGBITS)) | evallg(s)) @@ -155,11 +132,11 @@ typedef int (*QSCOMP)(const void *, const void *); #define setsigne(x,s) (((GEN)(x))[1]=\ (((GEN)(x))[1]&(~SIGNBITS)) | evalsigne(s)) -#define lgef(x) ((long) (((GEN) (x))[1] & LGEFBITS)) +#define lgef(x) (((GEN) (x))[1] & LGEFBITS) #define setlgef(x,s) (((GEN)(x))[1]=\ (((GEN)(x))[1]&(~LGEFBITS)) | evallgef(s)) -#define lgefint(x) ((long) (((GEN) (x))[1] & LGEFINTBITS)) +#define lgefint(x) (((GEN) (x))[1] & LGEFINTBITS) #define setlgefint(x,s) (((GEN)(x))[1]=\ (((GEN)(x))[1]&(~LGEFINTBITS)) | evallgefint(s)) @@ -175,7 +152,7 @@ typedef int (*QSCOMP)(const void *, const void *); #define setprecp(x,s) (((GEN)(x))[1]=\ (((GEN)(x))[1]&(~PRECPBITS)) | evalprecp(s)) -#define varn(x) ((long) ((((GEN) (x))[1]&VARNBITS) >> VARNSHIFT)) +#define varn(x) ((((GEN) (x))[1]&VARNBITS) >> VARNSHIFT) #define setvarn(x,s) (((GEN)(x))[1]=\ (((GEN)(x))[1]&(~VARNBITS)) | evalvarn(s))