Annotation of OpenXM_contrib/pari-2.2/src/headers/parigen.h, Revision 1.2
1.2 ! noro 1: /* $Id: parigen.h,v 1.11 2002/02/27 22:26:00 karim Exp $
1.1 noro 2:
3: Copyright (C) 2000 The PARI group.
4:
5: This file is part of the PARI/GP package.
6:
7: PARI/GP is free software; you can redistribute it and/or modify it under the
8: terms of the GNU General Public License as published by the Free Software
9: Foundation. It is distributed in the hope that it will be useful, but WITHOUT
10: ANY WARRANTY WHATSOEVER.
11:
12: Check the License for details. You should have received a copy of it, along
13: with the package; see the file 'COPYING'. If not, write to the Free Software
14: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
15:
16: /* This file defines the parameters of the GEN type */
17:
18: typedef long *GEN;
19: typedef int (*QSCOMP)(const void *, const void *);
20:
21: #ifdef ULONG_NOT_DEFINED
22: typedef unsigned long ulong;
23: #endif
24:
25: #ifdef __M68K__
26: # define OLD_CODES
27: #endif
28:
29: #ifdef LONG_IS_64BIT
30: # define TWOPOTBYTES_IN_LONG 3
31: #else
32: # define TWOPOTBYTES_IN_LONG 2
33: #endif
34:
1.2 ! noro 35: #define DEFAULTPREC 2 + (8>>TWOPOTBYTES_IN_LONG)
! 36: #define MEDDEFAULTPREC 2 + (16>>TWOPOTBYTES_IN_LONG)
! 37: #define BIGDEFAULTPREC 2 + (24>>TWOPOTBYTES_IN_LONG)
! 38: #define TWOPOTBITS_IN_LONG (TWOPOTBYTES_IN_LONG+3)
! 39: #define BYTES_IN_LONG (1UL<<TWOPOTBYTES_IN_LONG)
! 40: #define BITS_IN_LONG (1UL<<TWOPOTBITS_IN_LONG)
! 41: #define HIGHBIT (1UL << (BITS_IN_LONG-1))
! 42: #define BITS_IN_HALFULONG (BITS_IN_LONG>>1)
! 43: #define MAXULONG (~0x0UL)
! 44: #define MAXHALFULONG ((1UL<<BITS_IN_HALFULONG) - 1)
! 45: #define LOWMASK (MAXHALFULONG)
! 46: #define HIGHMASK (~LOWMASK)
! 47: #define SMALL_MASK (HIGHBIT>>1)
! 48: /* You may want to change the following 32 to BITS_IN_LONG */
! 49: #define BITS_IN_RANDOM 32
! 50:
! 51: /* Order of bits in codewords:
! 52: * x[0] TYPBITS, CLONEBIT, LGBITS
! 53: * x[1].real SIGNBITS, EXPOBITS
! 54: * int SIGNBITS, LGEFINTBITS
! 55: * ser,pol SIGNBITS, VARNBITS ,LGEFBITS
! 56: * padic VALPBITS, PRECPBITS
! 57: * Length of bitfields are independant and satisfy:
! 58: * TYPnumBITS + LGnumBITS + 1 <= BITS_IN_LONG (optimally =)
! 59: * SIGNnumBITS + EXPOnumBITS <= BITS_IN_LONG
! 60: * SIGNnumBITS + LGnumBITS <= BITS_IN_LONG
! 61: * SIGNnumBITS + LGEFnumBITS + 2 <= BITS_IN_LONG
! 62: * VALPnumbits + 1 <= BITS_IN_LONG */
! 63: #ifdef OLD_CODES
! 64: # define TYPnumBITS 8 /* obsolete (for hard-coded assembler in mp.s) */
! 65: # define SIGNnumBITS 8
! 66: #else
! 67: # define TYPnumBITS 7
! 68: # define SIGNnumBITS 2
! 69: #endif
1.1 noro 70:
1.2 ! noro 71: #ifdef LONG_IS_64BIT
! 72: # define LGnumBITS 32
! 73: # define EXPOnumBITS 48
! 74: # define LGEFnumBITS 46 /* otherwise MAXVARN too large */
! 75: # define VALPnumBITS 32
! 76: #else
! 77: # ifdef OLD_CODES
! 78: # define LGnumBITS 16 /* obsolete */
1.1 noro 79: # else
1.2 ! noro 80: # define LGnumBITS 24
1.1 noro 81: # endif
1.2 ! noro 82: # define EXPOnumBITS 24
! 83: # define LGEFnumBITS 16
! 84: # define VALPnumBITS 16
1.1 noro 85: #endif
86:
1.2 ! noro 87: /* no user serviceable parts below :-) */
! 88: #define VARNnumBITS (BITS_IN_LONG - SIGNnumBITS - LGEFnumBITS)
! 89: #define PRECPSHIFT VALPnumBITS
! 90: #define VARNSHIFT LGEFnumBITS
! 91: #define TYPSHIFT (BITS_IN_LONG - TYPnumBITS)
! 92: #define SIGNSHIFT (LGEFnumBITS+VARNnumBITS)
! 93:
! 94: #define EXPOBITS ((1UL<<EXPOnumBITS)-1)
! 95: #define SIGNBITS (0xffffUL << SIGNSHIFT)
! 96: #define TYPBITS (0xffffUL << TYPSHIFT)
! 97: #define PRECPBITS (~VALPBITS)
! 98: #define LGBITS ((1UL<<LGnumBITS)-1)
! 99: #define LGEFINTBITS LGBITS
! 100: #define LGEFBITS ((1UL<<LGEFnumBITS)-1)
! 101: #define VALPBITS ((1UL<<VALPnumBITS)-1)
! 102: #define VARNBITS (MAXVARN<<VARNSHIFT)
! 103: #define MAXVARN ((1UL<<VARNnumBITS)-1)
! 104: #define HIGHEXPOBIT (1UL<<(EXPOnumBITS-1))
! 105: #define HIGHVALPBIT (1UL<<(VALPnumBITS-1))
! 106: #define CLONEBIT (1UL<<LGnumBITS)
1.1 noro 107:
108: #define evaltyp(x) (((ulong)(x)) << TYPSHIFT)
109: #define evalvarn(x) (((ulong)(x)) << VARNSHIFT)
110: #define evalsigne(x) (((long)(x)) << SIGNSHIFT)
111: #define evalprecp(x) (((long)(x)) << PRECPSHIFT)
1.2 ! noro 112: #define _evalexpo(x) (HIGHEXPOBIT + (x))
! 113: #define _evalvalp(x) (HIGHVALPBIT + (x))
1.1 noro 114: #define evallgefint(x) (x)
1.2 ! noro 115: #define _evallg(x) (x)
! 116: #define _evallgef(x) (x)
1.1 noro 117:
1.2 ! noro 118: #define typ(x) ((((ulong)(x))&1)? (long)t_SMALL: (long)(((ulong) ((GEN) (x))[0]) >> TYPSHIFT))
1.1 noro 119: #define settyp(x,s) (((GEN)(x))[0]=\
120: (((GEN)(x))[0]&(~TYPBITS)) | evaltyp(s))
121: #define smalltos(x) (((long)(x))>>1)
122:
123: #define isclone(x) (((GEN) (x))[0] & CLONEBIT)
124: #define setisclone(x) (((GEN) (x))[0] |= CLONEBIT)
125: #define unsetisclone(x) (((GEN) (x))[0] &= (~CLONEBIT))
126:
1.2 ! noro 127: #define lg(x) ((((ulong)(x))&1)?1L: ((long) (((GEN) (x))[0] & LGBITS)))
1.1 noro 128: #define setlg(x,s) (((GEN)(x))[0]=\
129: (((GEN)(x))[0]&(~LGBITS)) | evallg(s))
130:
131: #define signe(x) (((long) ((GEN) (x))[1]) >> SIGNSHIFT)
132: #define setsigne(x,s) (((GEN)(x))[1]=\
133: (((GEN)(x))[1]&(~SIGNBITS)) | evalsigne(s))
134:
1.2 ! noro 135: #define lgef(x) (((GEN) (x))[1] & LGEFBITS)
1.1 noro 136: #define setlgef(x,s) (((GEN)(x))[1]=\
137: (((GEN)(x))[1]&(~LGEFBITS)) | evallgef(s))
138:
1.2 ! noro 139: #define lgefint(x) (((GEN) (x))[1] & LGEFINTBITS)
1.1 noro 140: #define setlgefint(x,s) (((GEN)(x))[1]=\
141: (((GEN)(x))[1]&(~LGEFINTBITS)) | evallgefint(s))
142:
143: #define expo(x) ((long) ((((GEN) (x))[1] & EXPOBITS) - HIGHEXPOBIT))
144: #define setexpo(x,s) (((GEN)(x))[1]=\
145: (((GEN)(x))[1]&(~EXPOBITS)) | evalexpo(s))
146:
147: #define valp(x) ((long) ((((GEN)(x))[1] & VALPBITS) - HIGHVALPBIT))
148: #define setvalp(x,s) (((GEN)(x))[1]=\
149: (((GEN)(x))[1]&(~VALPBITS)) | evalvalp(s))
150:
151: #define precp(x) ((long) (((ulong) ((GEN) (x))[1]) >> PRECPSHIFT))
152: #define setprecp(x,s) (((GEN)(x))[1]=\
153: (((GEN)(x))[1]&(~PRECPBITS)) | evalprecp(s))
154:
1.2 ! noro 155: #define varn(x) ((((GEN) (x))[1]&VARNBITS) >> VARNSHIFT)
1.1 noro 156: #define setvarn(x,s) (((GEN)(x))[1]=\
157: (((GEN)(x))[1]&(~VARNBITS)) | evalvarn(s))
158:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>