FORM  4.2
structs.h
Go to the documentation of this file.
1 
17 /* #[ License : */
18 /*
19  * Copyright (C) 1984-2017 J.A.M. Vermaseren
20  * When using this file you are requested to refer to the publication
21  * J.A.M.Vermaseren "New features of FORM" math-ph/0010025
22  * This is considered a matter of courtesy as the development was paid
23  * for by FOM the Dutch physics granting agency and we would like to
24  * be able to track its scientific use to convince FOM of its value
25  * for the community.
26  *
27  * This file is part of FORM.
28  *
29  * FORM is free software: you can redistribute it and/or modify it under the
30  * terms of the GNU General Public License as published by the Free Software
31  * Foundation, either version 3 of the License, or (at your option) any later
32  * version.
33  *
34  * FORM is distributed in the hope that it will be useful, but WITHOUT ANY
35  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
36  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
37  * details.
38  *
39  * You should have received a copy of the GNU General Public License along
40  * with FORM. If not, see <http://www.gnu.org/licenses/>.
41  */
42 /* #] License : */
43 
44 #ifndef __STRUCTS__
45 
46 #define __STRUCTS__
47 #ifdef _MSC_VER
48 #include <wchar.h> /* off_t */
49 #endif
50 /*
51  #[ sav&store :
52 */
53 
58 typedef struct PoSiTiOn {
59  off_t p1;
60 } POSITION;
61 
62 /* Next are the index structs for stored and saved expressions */
63 
74 typedef struct {
75  UBYTE headermark[8];
77  UBYTE lenWORD;
78  UBYTE lenLONG;
79  UBYTE lenPOS;
80  UBYTE lenPOINTER;
81  UBYTE endianness[16];
82  UBYTE sSym;
83  UBYTE sInd;
84  UBYTE sVec;
85  UBYTE sFun;
86  UBYTE maxpower[16];
87  UBYTE wildoffset[16];
88  UBYTE revision;
89  UBYTE reserved[512-8-4-16-4-16-16-1];
90 } STOREHEADER;
91 
92 STATIC_ASSERT(sizeof(STOREHEADER) == 512);
93 
99 typedef struct InDeXeNtRy {
104  WORD nsymbols;
105  WORD nindices;
106  WORD nvectors;
107  WORD nfunctions;
108  WORD size;
109  SBYTE name[MAXENAME+1];
110  PADPOSITION(0,1,0,5,MAXENAME+1);
111 } INDEXENTRY;
112 
118 #define INFILEINDEX ((512-2*sizeof(POSITION))/sizeof(INDEXENTRY))
119 
123 #define EMPTYININDEX (512-2*sizeof(POSITION)-INFILEINDEX*sizeof(INDEXENTRY))
124 
137 typedef struct FiLeInDeX {
142 } FILEINDEX;
143 
144 STATIC_ASSERT(sizeof(FILEINDEX) == 512);
145 
150 typedef struct FiLeDaTa {
151  FILEINDEX Index;
152  POSITION Fill;
153  POSITION Position;
154  WORD Handle;
155  WORD dirtyflag;
156  PADPOSITION(0,0,0,2,0);
157 } FILEDATA;
158 
165 typedef struct VaRrEnUm {
166  WORD *start;
167  WORD *lo;
168  WORD *hi;
169 } VARRENUM;
170 
177 typedef struct ReNuMbEr {
178  POSITION startposition;
179  /* First stage renumbering */
184  /* Second stage renumbering */
185  WORD *symnum;
186  WORD *indnum;
187  WORD *vecnum;
188  WORD *funnum;
189  PADPOSITION(4,0,0,0,sizeof(VARRENUM)*4);
190 } *RENUMBER;
191 
192 /*
193  #] sav&store :
194  #[ Variables :
195 */
196 
204 typedef struct {
205  void *lijst;
206  char *message;
207  int num;
208  int maxnum;
209  int size;
210  int numglobal;
211  int numtemp;
212  int numclear;
213  PADPOINTER(0,6,0,0);
214 } LIST;
215 
221 typedef struct {
222  char *name;
223  TFUN func;
224  int type;
225  int flags;
226 } KEYWORD;
227 
234 typedef struct NaMeNode {
235  LONG name;
236  WORD parent;
237  WORD left;
238  WORD right;
239  WORD balance;
240  WORD type;
241  WORD number;
242  PADLONG(0,6,0);
243 } NAMENODE;
244 
252 typedef struct NaMeTree {
255  UBYTE *namebuffer;
258  LONG nodesize;
259  LONG nodefill;
260  LONG namesize;
261  LONG namefill;
262  LONG oldnamefill;
263  LONG oldnodefill;
269  WORD headnode;
270  PADPOINTER(10,0,1,0);
271 } NAMETREE;
272 
281 typedef struct tree {
282  int parent;
283  int left;
284  int right;
285  int value;
286  int blnce;
287  int usage;
288 } COMPTREE;
289 
294 typedef struct MiNmAx {
295  WORD mini;
296  WORD maxi;
297  WORD size;
298 } MINMAX;
299 
304 typedef struct BrAcKeTiNdEx { /* For indexing brackets in local expressions */
305  POSITION start; /* Place where bracket starts - start of expr */
306  POSITION next; /* Place of next indexed bracket in expr */
307  LONG bracket; /* Offset of position in bracketbuffer */
308  LONG termsinbracket;
309  PADPOSITION(0,2,0,0,0);
310 } BRACKETINDEX;
311 
316 typedef struct BrAcKeTiNfO {
319  LONG bracketbuffersize;
320  LONG indexbuffersize;
321  LONG bracketfill;
322  LONG indexfill;
323  WORD SortType;
324  PADPOINTER(4,0,1,0);
325 } BRACKETINFO;
326 
337 typedef struct TaBlEs {
339 #ifdef WITHPTHREADS
340  WORD **prototype;
341  WORD **pattern;
342 #else
343  WORD *prototype;
344  WORD *pattern;
345 #endif
347  WORD *flags;
349  UBYTE *argtail;
351  struct TaBlEs *spare;
352  WORD *buffers;
353  LONG totind;
354  LONG reserved;
355  LONG defined;
356  LONG mdefined;
358  int numind;
359  int bounds;
360  int strict;
361  int sparse;
362  int numtree;
363  int rootnum;
365  WORD bufnum;
366  WORD bufferssize;
367  WORD buffersfill;
368  WORD tablenum;
369  WORD mode;
370  WORD numdummies;
371  PADPOINTER(4,8,6,0);
372 } *TABLES;
373 
378 typedef struct ExPrEsSiOn {
379  POSITION onfile;
380  POSITION prototype;
381  POSITION size;
382  RENUMBER renum; /* For Renumbering of global stored expressions */
383  BRACKETINFO *bracketinfo;
384  BRACKETINFO *newbracketinfo;
385  WORD *renumlists;
387  WORD *inmem; /* If in memory like e.g. a polynomial */
388  LONG counter;
389  LONG name;
390  WORD hidelevel;
391  WORD vflags; /* Various flags */
392  WORD printflag;
393  WORD status;
394  WORD replace;
395  WORD node;
396  WORD whichbuffer;
397  WORD namesize;
398  WORD compression;
399  WORD numdummies;
400  WORD numfactors;
401  WORD sizeprototype;
402 #ifdef PARALLELCODE
403  WORD partodo; /* Whether to be done in parallel mode */
404  PADPOSITION(5,2,0,13,0);
405 #else
406  PADPOSITION(5,2,0,12,0);
407 #endif
408 } *EXPRESSIONS;
409 
414 typedef struct SyMbOl { /* Don't change unless altering .sav too */
415  LONG name; /* Location in names buffer */
416  WORD minpower; /* Minimum power admissible */
417  WORD maxpower; /* Maximum power admissible */
418  WORD complex; /* Properties wrt complex conjugation */
419  WORD number; /* Number when stored in file */
420  WORD flags; /* Used to indicate usage when storing */
421  WORD node;
422  WORD namesize;
423  WORD dimension; /* For dimensionality checks */
424  PADLONG(0,8,0);
425 } *SYMBOLS;
426 
431 typedef struct InDeX { /* Don't change unless altering .sav too */
432  LONG name; /* Location in names buffer */
433  WORD type; /* Regular or dummy */
434  WORD dimension; /* Value of d_(n,n) or -number of symbol */
435  WORD number; /* Number when stored in file */
436  WORD flags; /* Used to indicate usage when storing */
437  WORD nmin4; /* Used for n-4 if dimension < 0 */
438  WORD node;
439  WORD namesize;
440  PADLONG(0,7,0);
441 } *INDICES;
442 
447 typedef struct VeCtOr { /* Don't change unless altering .sav too */
448  LONG name; /* Location in names buffer */
449  WORD complex; /* Properties under complex conjugation */
450  WORD number; /* Number when stored in file */
451  WORD flags; /* Used to indicate usage when storing */
452  WORD node;
453  WORD namesize;
454  WORD dimension; /* For dimensionality checks */
455  PADLONG(0,6,0);
456 } *VECTORS;
457 
463 typedef struct FuNcTiOn { /* Don't change unless altering .sav too */
465  LONG symminfo;
466  LONG name;
467  WORD commute;
468  WORD complex;
469  WORD number;
470  WORD flags;
471  WORD spec;
472  WORD symmetric;
473  WORD node;
474  WORD namesize;
475  WORD dimension; /* For dimensionality checks */
476  WORD maxnumargs;
477  WORD minnumargs;
478  PADPOINTER(2,0,11,0);
479 } *FUNCTIONS;
480 
485 typedef struct SeTs {
486  LONG name; /* Location in names buffer */
487  WORD type; /* Symbol, vector, index or function */
488  WORD first; /* First element in setstore */
489  WORD last; /* Last element in setstore (excluding) */
490  WORD node;
491  WORD namesize;
492  WORD dimension; /* For dimensionality checks */
493  PADLONG(0,6,0);
494 } *SETS;
495 
500 typedef struct DuBiOuS { /* Undeclared objects. Just for compiler. */
501  LONG name; /* Location in names buffer */
502  WORD node;
503  WORD dummy;
504  PADLONG(0,2,0);
505 } *DUBIOUSV;
506 
507 typedef struct FaCdOlLaR {
508  WORD *where; /* A pointer(!) to the content */
509  LONG size;
510  WORD type; /* Type can be DOLNUMBER or DOLTERMS */
511  WORD value; /* in case it is a (short) number */
512  PADPOINTER(1,0,2,0);
513 } FACDOLLAR;
514 
515 typedef struct DoLlArS {
516  WORD *where; /* A pointer(!) to the object */
517  FACDOLLAR *factors; /* an array of factors. nfactors elements */
518 #ifdef WITHPTHREADS
519  pthread_mutex_t pthreadslockread;
520  pthread_mutex_t pthreadslockwrite;
521 #endif
522  LONG size; /* The number of words */
523  LONG name;
524  WORD type;
525  WORD node;
526  WORD index;
527  WORD zero;
528  WORD numdummies;
529  WORD nfactors;
530 #ifdef WITHPTHREADS
531  PADPOINTER(2,0,6,sizeof(pthread_mutex_t)*2);
532 #else
533  PADPOINTER(2,0,6,0);
534 #endif
535 } *DOLLARS;
536 
541 typedef struct MoDoPtDoLlArS {
542 #ifdef WITHPTHREADS
543  DOLLARS dstruct; /* If local dollar: list of DOLLARS for each thread */
544 #endif
545  WORD number;
546  WORD type;
547 #ifdef WITHPTHREADS
548  PADPOINTER(0,0,2,0);
549 #endif
550 } MODOPTDOLLAR;
551 
556 typedef struct fixedset {
557  char *name;
558  char *description;
559  int type;
560  int dimension;
561 } FIXEDSET;
562 
567 typedef struct TaBlEbAsEsUbInDeX {
568  POSITION where;
569  LONG size;
570  PADPOSITION(0,1,0,0,0);
572 
577 typedef struct TaBlEbAsE {
578  POSITION fillpoint;
579  POSITION current;
580  UBYTE *name;
581  int *tablenumbers; /* Number of each table */
582  TABLEBASESUBINDEX *subindex; /* For each table */
583  int numtables;
584  PADPOSITION(3,0,1,0,0);
585 } TABLEBASE;
586 
593 typedef struct {
594  WORD *location;
595  int numargs;
596  int numfunnies;
597  int numwildcards;
598  int symmet;
599  int tensor;
600  int commute;
601  PADPOINTER(0,6,0,0);
602 } FUN_INFO;
603 
604 /*
605  #] Variables :
606  #[ Files :
607 */
608 
620 typedef struct FiLe {
621  POSITION POposition; /* File position */
622  POSITION filesize; /* Because SEEK_END is unsafe on IBM */
623  WORD *PObuffer; /* Address of the intermediate buffer */
624  WORD *POstop; /* End of the buffer */
625  WORD *POfill; /* Fill position of the buffer */
626  WORD *POfull; /* Full buffer when only cached */
627 #ifdef WITHPTHREADS
628  WORD *wPObuffer; /* Address of the intermediate worker buffer */
629  WORD *wPOstop; /* End of the worker buffer */
630  WORD *wPOfill; /* Fill position of the worker buffer */
631  WORD *wPOfull; /* Full buffer when only worker cached */
632 #endif
633  char *name; /* name of the file */
634 #ifdef WITHZLIB
635  z_streamp zsp; /* The pointer to the stream struct for gzip */
636  Bytef *ziobuffer; /* The output buffer for compression */
637 #endif
638  ULONG numblocks; /* Number of blocks in file */
639  ULONG inbuffer; /* Block in the buffer */
640  LONG POsize; /* size of the buffer */
641 #ifdef WITHZLIB
642  LONG ziosize; /* size of the zoutbuffer */
643 #endif
644 #ifdef WITHPTHREADS
645  LONG wPOsize; /* size of the worker buffer */
646  pthread_mutex_t pthreadslock;
647 #endif
648  int handle;
649  int active; /* File is open or closed. Not used. */
650 #ifdef WITHPTHREADS
651 #ifdef WITHZLIB
652  PADPOSITION(11,5,2,0,sizeof(pthread_mutex_t));
653 #else
654  PADPOSITION(9,4,2,0,sizeof(pthread_mutex_t));
655 #endif
656 #else
657 #ifdef WITHZLIB
658  PADPOSITION(7,4,2,0,0);
659 #else
660  PADPOSITION(5,3,2,0,0);
661 #endif
662 #endif
663 } FILEHANDLE;
664 
674 typedef struct StreaM {
675  off_t fileposition;
676  off_t linenumber;
677  off_t prevline;
678  UBYTE *buffer;
679  UBYTE *pointer;
680  UBYTE *top;
681  UBYTE *FoldName;
682  UBYTE *name;
683  UBYTE *pname;
685  LONG buffersize;
686  LONG bufferposition;
687  LONG inbuffer;
688  int previous;
689  int handle;
690  int type;
691  int prevars;
692  int previousNoShowInput;
693  int eqnum;
694  int afterwards;
695  int olddelay;
696  int oldnoshowinput;
697  UBYTE isnextchar;
698  UBYTE nextchar[2];
699  UBYTE reserved;
700  PADPOSITION(6,3,9,0,4);
701 } STREAM;
702 
703 typedef struct SpecTatoR {
704  POSITION position; /* The place where we will be writing */
705  POSITION readpos; /* The place from which we read */
706  FILEHANDLE *fh;
707  char *name; /* We identify the spectator by the name of the expression */
708  WORD exprnumber; /* During running we use the number. */
709  WORD flags; /* local, global? */
710  PADPOSITION(2,0,0,2,0);
711 } SPECTATOR;
712 
713 /*
714  #] Files :
715  #[ Traces :
716 */
717 
727 typedef struct TrAcEs { /* For computing 4 dimensional traces */
728  WORD *accu; /* NUMBER * 2 */
729  WORD *accup;
730  WORD *termp;
731  WORD *perm; /* number */
732  WORD *inlist; /* number */
733  WORD *nt3; /* number/2 */
734  WORD *nt4; /* number/2 */
735  WORD *j3; /* number*2 */
736  WORD *j4; /* number*2 */
737  WORD *e3; /* number*2 */
738  WORD *e4; /* number */
739  WORD *eers; /* number/2 */
740  WORD *mepf; /* number/2 */
741  WORD *mdel; /* number/2 */
742  WORD *pepf; /* number*2 */
743  WORD *pdel; /* number*3/2 */
744  WORD sgn;
745  WORD stap;
746  WORD step1,kstep,mdum;
747  WORD gamm,ad,a3,a4,lc3,lc4;
748  WORD sign1,sign2,gamma5,num,level,factor,allsign;
749  WORD finalstep;
750  PADPOINTER(0,0,19,0);
751 } TRACES;
752 
760 typedef struct TrAcEn { /* For computing n dimensional traces */
761  WORD *accu; /* NUMBER */
762  WORD *accup;
763  WORD *termp;
764  WORD *perm; /* number */
765  WORD *inlist; /* number */
766  WORD sgn,num,level,factor,allsign;
767  PADPOINTER(0,0,5,0);
768 } *TRACEN;
769 
770 /*
771  #] Traces :
772  #[ Preprocessor :
773 */
774 
779 typedef struct pReVaR {
780  UBYTE *name;
781  UBYTE *value;
782  UBYTE *argnames;
783  int nargs;
784  int wildarg;
785  PADPOINTER(0,2,0,0);
786 } PREVAR;
787 
792 typedef struct {
793  WORD *buffer;
794  int oldcompiletype;
795  int oldparallelflag;
796  int oldnumpotmoddollars;
797  WORD size;
798  WORD numdollars;
799  WORD oldcbuf;
800  WORD oldrbuf;
801  WORD inscbuf;
802  WORD oldcnumlhs;
803  PADPOINTER(0,3,6,0);
804 } INSIDEINFO;
805 
811 typedef struct {
812  UBYTE *buffer;
813  LONG size;
814  PADPOINTER(1,0,0,0);
815 } PRELOAD;
816 
821 typedef struct {
822  PRELOAD p;
823  UBYTE *name;
824  int loadmode;
825  PADPOINTER(0,1,0,0);
826 } PROCEDURE;
827 
835 typedef struct DoLoOp {
837  UBYTE *name;
838  UBYTE *vars; /* for {} or name of expression */
839  UBYTE *contents;
840  UBYTE *dollarname;
841  LONG startlinenumber;
842  LONG firstnum;
843  LONG lastnum;
844  LONG incnum;
845  int type;
846  int NoShowInput;
847  int errorsinloop;
848  int firstloopcall;
849  WORD firstdollar; /* When >= 0 we have to get the value from a dollar */
850  WORD lastdollar; /* When >= 0 we have to get the value from a dollar */
851  WORD incdollar; /* When >= 0 we have to get the value from a dollar */
852  WORD NumPreTypes;
853  WORD PreIfLevel;
854  WORD PreSwitchLevel;
855  PADPOINTER(4,4,6,0);
856 } DOLOOP;
857 
865 struct bit_field { /* Assume 8 bits per byte */
866  UBYTE bit_0 : 1;
867  UBYTE bit_1 : 1;
868  UBYTE bit_2 : 1;
869  UBYTE bit_3 : 1;
870  UBYTE bit_4 : 1;
871  UBYTE bit_5 : 1;
872  UBYTE bit_6 : 1;
873  UBYTE bit_7 : 1;
874 /*
875  UINT bit_0 : 1;
876  UINT bit_1 : 1;
877  UINT bit_2 : 1;
878  UINT bit_3 : 1;
879  UINT bit_4 : 1;
880  UINT bit_5 : 1;
881  UINT bit_6 : 1;
882  UINT bit_7 : 1;
883 */
884 };
885 
890 typedef struct bit_field set_of_char[32];
891 
896 typedef struct bit_field *one_byte;
897 
902 typedef struct {
903  WORD newlogonly;
904  WORD newhandle;
905  WORD oldhandle;
906  WORD oldlogonly;
907  WORD oldprinttype;
908  WORD oldsilent;
909 } HANDLERS;
910 
911 /*
912  #] Preprocessor :
913  #[ Varia :
914 */
915 
921 typedef struct CbUf {
922  WORD *Buffer;
923  WORD *Top;
924  WORD *Pointer;
925  WORD **lhs;
926  WORD **rhs;
927  LONG *CanCommu;
928  LONG *NumTerms;
929  WORD *numdum;
930  WORD *dimension;
932  LONG BufferSize;
933  int numlhs;
934  int numrhs;
935  int maxlhs;
936  int maxrhs;
937  int mnumlhs;
938  int mnumrhs;
939  int numtree;
940  int rootnum;
941  int MaxTreeSize;
942  PADPOINTER(1,9,0,0);
943 } CBUF;
944 
952 typedef struct ChAnNeL {
953  char *name;
954  int handle;
955  PADPOINTER(0,1,0,0);
956 } CHANNEL;
957 
967 typedef struct {
968  UBYTE *parameter;
969  int type;
970  int flags;
971  LONG value;
973 
982 typedef struct NeStInG {
983  WORD *termsize;
984  WORD *funsize;
985  WORD *argsize;
986 } *NESTING;
987 
994 typedef struct StOrEcAcHe {
995  POSITION position;
996  POSITION toppos;
997  struct StOrEcAcHe *next;
998  WORD buffer[2];
999  PADPOSITION(1,0,0,2,0);
1000 } *STORECACHE;
1001 
1007 typedef struct PeRmUtE {
1008  WORD *objects;
1009  WORD sign;
1010  WORD n;
1011  WORD cycle[MAXMATCH];
1012  PADPOINTER(0,0,MAXMATCH+2,0);
1013 } PERM;
1014 
1019 typedef struct PeRmUtEp {
1020  WORD **objects;
1021  WORD sign;
1022  WORD n;
1023  WORD cycle[MAXMATCH];
1024  PADPOINTER(0,0,MAXMATCH+2,0);
1025 } PERMP;
1026 
1032 typedef struct DiStRiBuTe {
1033  WORD *obj1;
1034  WORD *obj2;
1035  WORD *out;
1036  WORD sign;
1037  WORD n1;
1038  WORD n2;
1039  WORD n;
1040  WORD cycle[MAXMATCH];
1041  PADPOINTER(0,0,(MAXMATCH+4),0);
1042 } DISTRIBUTE;
1043 
1049 typedef struct PaRtI {
1050  WORD *psize; /* the sizes of the partitions */
1051  WORD *args; /* the offsets of the arguments to be partitioned */
1052  WORD *nargs; /* argument numbers (different number = different argument) */
1053  WORD *nfun; /* the functions into which the partitions go */
1054  WORD numargs; /* the number of arguments to be partitioned */
1055  WORD numpart; /* the number of partitions */
1056  WORD where; /* offset of the function in the term */
1057  PADPOINTER(0,0,3,0);
1058 } PARTI;
1059 
1069 typedef struct sOrT {
1070  FILEHANDLE file; /* The own sort file */
1071  POSITION SizeInFile[3]; /* Sizes in the various files */
1072  WORD *lBuffer; /* The large buffer */
1073  WORD *lTop; /* End of the large buffer */
1074  WORD *lFill; /* The filling point of the large buffer */
1075  WORD *used; /* auxiliary during actual sort */
1076  WORD *sBuffer; /* The small buffer */
1077  WORD *sTop; /* End of the small buffer */
1078  WORD *sTop2; /* End of the extension of the small buffer */
1079  WORD *sHalf; /* Halfway point in the extension */
1080  WORD *sFill; /* Filling point in the small buffer */
1081  WORD **sPointer; /* Pointers to terms in the small buffer */
1082  WORD **PoinFill; /* Filling point for pointers to the sm.buf */
1083  WORD **SplitScratch; /* Excess pointer space for the merge sort */
1084  WORD *cBuffer; /* Compress buffer (if it exists) */
1085  WORD **Patches; /* Positions of patches in large buffer */
1086  WORD **pStop; /* Ends of patches in the large buffer */
1087  WORD **poina; /* auxiliary during actual sort */
1088  WORD **poin2a; /* auxiliary during actual sort */
1089  WORD *ktoi; /* auxiliary during actual sort */
1090  WORD *tree; /* auxiliary during actual sort */
1091 #ifdef WITHZLIB
1092  WORD *fpcompressed; /* is output filepatch compressed? */
1093  WORD *fpincompressed; /* is input filepatch compressed? */
1094  z_streamp zsparray; /* the array of zstreams for decompression */
1095 #endif
1096  POSITION *fPatches; /* Positions of output file patches */
1097  POSITION *inPatches; /* Positions of input file patches */
1098  POSITION *fPatchesStop; /* Positions of output file patches */
1099  POSITION *iPatches; /* Input file patches, Points to fPatches or inPatches */
1100  FILEHANDLE *f; /* The actual output file */
1101  FILEHANDLE **ff; /* Handles for a staged sort */
1102  LONG sTerms; /* Terms in small buffer */
1103  LONG LargeSize; /* Size of large buffer (in words) */
1104  LONG SmallSize; /* Size of small buffer (in words) */
1105  LONG SmallEsize; /* Size of small + extension (in words) */
1106  LONG TermsInSmall; /* Maximum number of terms in small buffer */
1107  LONG Terms2InSmall; /* with extension for polyfuns etc. */
1108  LONG GenTerms; /* Number of generated terms */
1109  LONG TermsLeft; /* Number of terms still in existence */
1110  LONG GenSpace; /* Amount of space of generated terms */
1111  LONG SpaceLeft; /* Space needed for still existing terms */
1112  LONG putinsize; /* Size of buffer in putin */
1113  LONG ninterms; /* Which input term ? */
1114  int MaxPatches; /* Maximum number of patches in large buffer */
1115  int MaxFpatches; /* Maximum number of patches in one filesort */
1116  int type; /* Main, function or sub(routine) */
1117  int lPatch; /* Number of patches in the large buffer */
1118  int fPatchN1; /* Number of patches in input file */
1119  int PolyWise; /* Is there a polyfun and if so, where? */
1120  int PolyFlag; /* */
1121  int cBufferSize; /* Size of the compress buffer */
1122  int maxtermsize; /* Keeps track for buffer allocations */
1123  int newmaxtermsize; /* Auxiliary for maxtermsize */
1124  int outputmode; /* Tells where the output is going */
1125  int stagelevel; /* In case we have a 'staged' sort */
1126  WORD fPatchN; /* Number of patches on file (output) */
1127  WORD inNum; /* Number of patches on file (input) */
1128  WORD stage4; /* Are we using stage4? */
1129 #ifdef WITHZLIB
1130  PADPOSITION(28,12,12,3,0);
1131 #else
1132  PADPOSITION(25,12,12,3,0);
1133 #endif
1134 } SORTING;
1135 
1136 #ifdef WITHPTHREADS
1137 
1143 typedef struct SoRtBlOcK {
1144  pthread_mutex_t *MasterBlockLock;
1145  WORD **MasterStart;
1146  WORD **MasterFill;
1147  WORD **MasterStop;
1148  int MasterNumBlocks;
1149  int MasterBlock;
1150  int FillBlock;
1151  PADPOINTER(0,3,0,0);
1152 } SORTBLOCK;
1153 #endif
1154 
1155 #ifdef DEBUGGER
1156 typedef struct DeBuGgInG {
1157  int eflag;
1158  int printflag;
1159  int logfileflag;
1160  int stdoutflag;
1161 } DEBUGSTR;
1162 #endif
1163 
1164 #ifdef WITHPTHREADS
1165 
1171 typedef struct ThReAdBuCkEt {
1172  POSITION *deferbuffer; /* For Keep Brackets: remember position */
1173  WORD *threadbuffer; /* Here are the (primary) terms */
1174  WORD *compressbuffer; /* For keep brackets we need the compressbuffer */
1175  LONG threadbuffersize; /* Number of words in threadbuffer */
1176  LONG ddterms; /* Number of primary+secondary terms represented */
1177  LONG firstterm; /* The number of the first term in the bucket */
1178  LONG firstbracket; /* When doing complete brackets */
1179  LONG lastbracket; /* When doing complete brackets */
1180  pthread_mutex_t lock; /* For the load balancing phase */
1181  int free; /* Status of the bucket */
1182  int totnum; /* Total number of primary terms */
1183  int usenum; /* Which is the term being used at the moment */
1184  int busy; /* */
1185  int type; /* Doing brackets? */
1186  PADPOINTER(5,5,0,sizeof(pthread_mutex_t));
1187 } THREADBUCKET;
1188 
1189 #endif
1190 
1198 typedef struct {
1199  WORD *coefs; /* The array of coefficients */
1200  WORD numsym; /* The number of the symbol in the polynomial */
1201  WORD arraysize; /* The size of the allocation of coefs */
1202  WORD polysize; /* The maximum power in the polynomial */
1203  WORD modnum; /* The prime number of the modulus */
1204 } POLYMOD;
1205 
1206 typedef struct {
1207  WORD *outterm; /* Used in DoShuffle/Merge/FinishShuffle system */
1208  WORD *outfun;
1209  WORD *incoef;
1210  WORD *stop1;
1211  WORD *stop2;
1212  WORD *ststop1;
1213  WORD *ststop2;
1214  void *finishuf;
1215  void *do_uffle;
1216  LONG combilast;
1217  WORD nincoef;
1218  WORD level;
1219  WORD thefunction;
1220  WORD option;
1221  PADPOINTER(1,0,4,0);
1222 } SHvariables;
1223 
1224 typedef struct { /* Used for computing calculational cost in optim.c */
1225  LONG add;
1226  LONG mul;
1227  LONG div;
1228  LONG pow;
1229 } COST;
1230 
1231 typedef struct {
1232  UWORD *a; /* The number array */
1233  UWORD *m; /* The modulus array */
1234  WORD na; /* Size of the number */
1235  WORD nm; /* size of the number in the modulus array */
1236 } MODNUM;
1237 
1238 /*
1239  Struct for optimizing outputs. If changed, do not forget to change
1240  the padding information in the AO struct.
1241 */
1242 typedef struct {
1243  union { /* we do this to allow padding */
1244  float fval;
1245  int ival[2]; /* This should be enough */
1246  } mctsconstant;
1247  int horner;
1248  int hornerdirection;
1249  int method;
1250  int mctstimelimit;
1251  int mctsnumexpand;
1252  int mctsnumkeep;
1253  int mctsnumrepeat;
1254  int greedytimelimit;
1255  int greedyminnum;
1256  int greedymaxperc;
1257  int printstats;
1258  int debugflags;
1259  int schemeflags;
1260  int mctsdecaymode;
1261  int saIter; /* Simulated annealing updates */
1262  union {
1263  float fval;
1264  int ival[2];
1265  } saMaxT; /* Maximum temperature of SA */
1266  union {
1267  float fval;
1268  int ival[2];
1269  } saMinT; /* Minimum temperature of SA */
1270 } OPTIMIZE;
1271 
1272 typedef struct {
1273  WORD *code;
1274  UBYTE *nameofexpr; /* It is easier to remember an expression by name */
1275  LONG codesize; /* We need this for the checkpoints */
1276  WORD exprnr; /* Problem here is: we renumber them in execute.c */
1277  WORD minvar;
1278  WORD maxvar;
1279 
1280  PADPOSITION(2,1,0,3,0);
1281 } OPTIMIZERESULT;
1282 
1283 typedef struct {
1284  WORD *lhs; /* Object to be replaced */
1285  WORD *rhs; /* Depending on the type it will be UBYTE* or WORD* */
1286  int type;
1287  int size; /* Size of the lhs */
1289 
1290 typedef struct {
1291  DICTIONARY_ELEMENT **elements;
1292  UBYTE *name;
1293  int sizeelements;
1294  int numelements;
1295  int numbers; /* deal with numbers */
1296  int variables; /* deal with single variables */
1297  int characters; /* deal with special characters */
1298  int funwith; /* deal with functions with arguments */
1299  int gnumelements; /* if .global shrinks the dictionary */
1300  int ranges;
1301 } DICTIONARY;
1302 
1303 /*
1304  #] Varia :
1305  #[ A :
1306  #[ M : The M struct is for global settings at startup or .clear
1307 */
1308 
1316 struct M_const {
1317  POSITION zeropos; /* (M) is zero */
1319  UWORD *gcmod;
1320  UWORD *gpowmod;
1321  UBYTE *TempDir; /* (M) Path with where the temporary files go */
1322  UBYTE *TempSortDir; /* (M) Path with where the sort files go */
1323  UBYTE *IncDir; /* (M) Directory path for include files */
1324  UBYTE *InputFileName; /* (M) */
1325  UBYTE *LogFileName; /* (M) */
1326  UBYTE *OutBuffer; /* (M) Output buffer in pre.c */
1327  UBYTE *Path; /* (M) */
1328  UBYTE *SetupDir; /* (M) Directory with setup file */
1329  UBYTE *SetupFile; /* (M) Name of setup file */
1330  UBYTE *gFortran90Kind;
1331  UBYTE *gextrasym;
1332  UBYTE *ggextrasym;
1333  UBYTE *oldnumextrasymbols;
1334  SPECTATOR *SpectatorFiles;
1335 #ifdef WITHPTHREADS
1336  pthread_rwlock_t handlelock; /* (M) */
1337  pthread_mutex_t storefilelock; /* (M) */
1338  pthread_mutex_t sbuflock; /* (M) Lock for writing in the AM.sbuffer */
1339  LONG ThreadScratSize; /* (M) Size of Fscr[0/2] buffers of the workers */
1340  LONG ThreadScratOutSize; /* (M) Size of Fscr[1] buffers of the workers */
1341 #endif
1342  LONG MaxTer; /* (M) Maximum term size. Fixed at setup. In Bytes!!!*/
1343  LONG CompressSize; /* (M) Size of Compress buffer */
1344  LONG ScratSize; /* (M) Size of Fscr[] buffers */
1345  LONG HideSize; /* (M) Size of Fscr[2] buffer */
1346  LONG SizeStoreCache; /* (M) Size of the chaches for reading global expr. */
1347  LONG MaxStreamSize; /* (M) Maximum buffer size in reading streams */
1348  LONG SIOsize; /* (M) Sort InputOutput buffer size */
1349  LONG SLargeSize; /* (M) */
1350  LONG SSmallEsize; /* (M) */
1351  LONG SSmallSize; /* (M) */
1352  LONG STermsInSmall; /* (M) */
1353  LONG MaxBracketBufferSize; /* (M) Max Size for B+ or AB+ per expression */
1354  LONG hProcessBucketSize; /* (M) */
1355  LONG gProcessBucketSize; /* (M) */
1356  LONG shmWinSize; /* (M) size for shared memory window used in communications */
1357  LONG OldChildTime; /* (M) Zero time. Needed in timer. */
1358  LONG OldSecTime; /* (M) Zero time for measuring wall clock time */
1359  LONG OldMilliTime; /* (M) Same, but milli seconds */
1360  LONG WorkSize; /* (M) Size of WorkSpace */
1361  LONG gThreadBucketSize; /* (C) */
1362  LONG ggThreadBucketSize; /* (C) */
1363  LONG SumTime; /* Used in .clear */
1364  LONG SpectatorSize; /* Size of the buffer in bytes */
1365  int FileOnlyFlag; /* (M) Writing only to file */
1366  int Interact; /* (M) Interactive mode flag */
1367  int MaxParLevel; /* (M) Maximum nesting of parantheses */
1368  int OutBufSize; /* (M) size of OutBuffer */
1369  int SMaxFpatches; /* (M) */
1370  int SMaxPatches; /* (M) */
1371  int StdOut; /* (M) Regular output channel */
1372  int ginsidefirst; /* (M) Not used yet */
1373  int gDefDim; /* (M) */
1374  int gDefDim4; /* (M) */
1375  int NumFixedSets; /* (M) Number of the predefined sets */
1376  int NumFixedFunctions; /* (M) Number of built in functions */
1377  int rbufnum; /* (M) startup compiler buffer */
1378  int dbufnum; /* (M) dollar variables */
1379  int sbufnum; /* (M) subterm variables */
1380  int zbufnum; /* (M) special values */
1381  int SkipClears; /* (M) Number of .clear to skip at start */
1382  int gTokensWriteFlag; /* (M) */
1383  int gfunpowers; /* (M) */
1384  int gStatsFlag; /* (M) */
1385  int gNamesFlag; /* (M) */
1386  int gCodesFlag; /* (M) */
1387  int gSortType; /* (M) */
1388  int gproperorderflag; /* (M) */
1389  int hparallelflag; /* (M) */
1390  int gparallelflag; /* (M) */
1391  int totalnumberofthreads; /* (M) */
1392  int gSizeCommuteInSet;
1393  int gThreadStats;
1394  int ggThreadStats;
1395  int gFinalStats;
1396  int ggFinalStats;
1397  int gThreadsFlag;
1398  int ggThreadsFlag;
1399  int gThreadBalancing;
1400  int ggThreadBalancing;
1401  int gThreadSortFileSynch;
1402  int ggThreadSortFileSynch;
1403  int gProcessStats;
1404  int ggProcessStats;
1405  int gOldParallelStats;
1406  int ggOldParallelStats;
1407  int maxFlevels; /* () maximum function levels */
1408  int resetTimeOnClear; /* (M) */
1409  int gcNumDollars; /* () number of dollars for .clear */
1410  int MultiRun;
1411  int gNoSpacesInNumbers; /* For very long numbers */
1412  int ggNoSpacesInNumbers; /* For very long numbers */
1413  int gIsFortran90;
1414  int PrintTotalSize;
1415  int fbuffersize; /* Size for the AT.fbufnum factorization caches */
1416  int gOldFactArgFlag;
1417  int ggOldFactArgFlag;
1418  int gnumextrasym;
1419  int ggnumextrasym;
1420  int NumSpectatorFiles; /* Elements used in AM.spectatorfiles; */
1421  int SizeForSpectatorFiles; /* Size in AM.spectatorfiles; */
1422  int gOldGCDflag;
1423  int ggOldGCDflag;
1424  int gWTimeStatsFlag;
1425  int ggWTimeStatsFlag;
1426  WORD MaxTal; /* (M) Maximum number of words in a number */
1427  WORD IndDum; /* (M) Basis value for dummy indices */
1428  WORD DumInd; /* (M) */
1429  WORD WilInd; /* (M) Offset for wildcard indices */
1430  WORD gncmod; /* (M) Global setting of modulus. size of gcmod */
1431  WORD gnpowmod; /* (M) Global printing as powers. size gpowmod */
1432  WORD gmodmode; /* (M) Global mode for modulus */
1433  WORD gUnitTrace; /* (M) Global value of Tr[1] */
1434  WORD gOutputMode; /* (M) */
1435  WORD gOutputSpaces; /* (M) */
1436  WORD gOutNumberType; /* (M) */
1437  WORD gCnumpows; /* (M) */
1438  WORD gUniTrace[4]; /* (M) */
1439  WORD MaxWildcards; /* (M) Maximum number of wildcards */
1440  WORD mTraceDum; /* (M) Position/Offset for generated dummies */
1441  WORD OffsetIndex; /* (M) */
1442  WORD OffsetVector; /* (M) */
1443  WORD RepMax; /* (M) Max repeat levels */
1444  WORD LogType; /* (M) Type of writing to log file */
1445  WORD ggStatsFlag; /* (M) */
1446  WORD gLineLength; /* (M) */
1447  WORD qError; /* (M) Only error checking {-c option} */
1448  WORD FortranCont; /* (M) Fortran Continuation character */
1449  WORD HoldFlag; /* (M) Exit on termination? */
1450  WORD Ordering[15]; /* (M) Auxiliary for ordering wildcards */
1451  WORD silent; /* (M) Silent flag. Only results in output. */
1452  WORD tracebackflag; /* (M) For tracing errors */
1453  WORD expnum; /* (M) internal number of ^ function */
1454  WORD denomnum; /* (M) internal number of / function */
1455  WORD facnum; /* (M) internal number of fac_ function */
1456  WORD invfacnum; /* (M) internal number of invfac_ function */
1457  WORD sumnum; /* (M) internal number of sum_ function */
1458  WORD sumpnum; /* (M) internal number of sump_ function */
1459  WORD OldOrderFlag; /* (M) Flag for allowing old statement order */
1460  WORD termfunnum; /* (M) internal number of term_ function */
1461  WORD matchfunnum; /* (M) internal number of match_ function */
1462  WORD countfunnum; /* (M) internal number of count_ function */
1463  WORD gPolyFun; /* (M) global value of PolyFun */
1464  WORD gPolyFunInv; /* (M) global value of Inverse of PolyFun */
1465  WORD gPolyFunType; /* (M) global value of PolyFun */
1466  WORD gPolyFunExp;
1467  WORD gPolyFunVar;
1468  WORD gPolyFunPow;
1469  WORD dollarzero; /* (M) for dollars with zero value */
1470  WORD atstartup; /* To protect against DATE_ ending in \n */
1471  WORD exitflag; /* (R) For the exit statement */
1472  WORD NumStoreCaches; /* () Number of storage caches per processor */
1473  WORD gIndentSpace; /* For indentation in output */
1474  WORD ggIndentSpace;
1477  WORD gextrasymbols;
1478  WORD ggextrasymbols;
1479  WORD zerorhs;
1480  WORD onerhs;
1481  WORD havesortdir;
1482  WORD BracketFactors[8];
1483 #ifdef WITHPTHREADS
1484  PADPOSITION(17,25,61,81,sizeof(pthread_rwlock_t)+sizeof(pthread_mutex_t)*2);
1485 #else
1486  PADPOSITION(17,23,61,81,0);
1487 #endif
1488 };
1489 /*
1490  #] M :
1491  #[ P : The P struct defines objects set by the preprocessor
1492 */
1500 struct P_const {
1501  LIST DollarList; /* (R) Dollar variables. Contains pointers
1502  to contents of the variables.*/
1503  LIST PreVarList; /* (R) List of preprocessor variables
1504  Points to contents. Can be changed */
1505  LIST LoopList; /* (P) List of do loops */
1506  LIST ProcList; /* (P) List of procedures */
1507  INSIDEINFO inside; /* Information during #inside/#endinside */
1508  UBYTE **PreSwitchStrings; /* (P) The string in a switch */
1509  UBYTE *preStart; /* (P) Preprocessor instruction buffer */
1510  UBYTE *preStop; /* (P) end of preStart */
1511  UBYTE *preFill; /* (P) Filling point in preStart */
1512  UBYTE *procedureExtension; /* (P) Extension for procedure files (prc) */
1513  UBYTE *cprocedureExtension; /* (P) Extension after .clear */
1514  LONG *PreAssignStack; /* For nesting #$name assignments */
1515  int *PreIfStack; /* (P) Tracks nesting of #if */
1516  int *PreSwitchModes; /* (P) Stack of switch status */
1517  int *PreTypes; /* (P) stack of #call, #do etc nesting */
1518 #ifdef WITHPTHREADS
1519  pthread_mutex_t PreVarLock; /* (P) */
1520 #endif
1521  LONG StopWatchZero; /* For `timer_' and #reset timer */
1522  LONG InOutBuf; /* (P) Characters in the output buf in pre.c */
1523  LONG pSize; /* (P) size of preStart */
1524  int PreAssignFlag; /* (C) Indicates #assign -> catch dollar */
1525  int PreContinuation; /* (C) Indicates whether the statement is new */
1526  int PreproFlag; /* (P) Internal use to mark work on prepro instr. */
1527  int iBufError; /* (P) Flag for errors with input buffer */
1528  int PreOut; /* (P) Flag for #+ #- */
1529  int PreSwitchLevel; /* (P) Nesting of #switch */
1530  int NumPreSwitchStrings; /* (P) Size of PreSwitchStrings */
1531  int MaxPreTypes; /* (P) Size of PreTypes */
1532  int NumPreTypes; /* (P) Number of nesting objects in PreTypes */
1533  int MaxPreIfLevel; /* (C) Maximum number of nested #if. Dynamic */
1534  int PreIfLevel; /* (C) Current position if PreIfStack */
1535  int PreInsideLevel; /* (C) #inside active? */
1536  int DelayPrevar; /* (P) Delaying prevar substitution */
1537  int AllowDelay; /* (P) Allow delayed prevar substitution */
1538  int lhdollarerror; /* (R) */
1539  int eat; /* () */
1540  int gNumPre; /* (P) Number of preprocessor variables for .clear */
1541  int PreDebug; /* (C) */
1542  int OpenDictionary;
1543  int PreAssignLevel; /* For nesting #$name = ...; assignments */
1544  int MaxPreAssignLevel; /* For nesting #$name = ...; assignments */
1545  WORD DebugFlag; /* (P) For debugging purposes */
1546  WORD preError; /* (P) Blocks certain types of execution */
1547  UBYTE ComChar; /* (P) Commentary character */
1548  UBYTE cComChar; /* (P) Old commentary character for .clear */
1549  PADPOINTER(3,21,2,2);
1550 };
1551 
1552 /*
1553  #] P :
1554  #[ C : The C struct defines objects changed by the compiler
1555 */
1556 
1565 struct C_const {
1567  POSITION StoreFileSize; /* () Size of store file */
1572  /* Later also for write? */
1585 /*
1586  Compile buffer variables
1587 */
1589 /*
1590  Objects for auto declarations
1591 */
1592  LIST AutoSymbolList; /* (C) */
1593  LIST AutoIndexList; /* (C) */
1594  LIST AutoVectorList; /* (C) */
1595  LIST AutoFunctionList; /* (C) */
1598  LIST *Symbols; /* (C) Pointer for autodeclare. Which list is
1599  it searching. Later also for subroutines */
1600  LIST *Indices; /* (C) id. */
1601  LIST *Vectors; /* (C) id. */
1602  LIST *Functions; /* (C) id. */
1603  NAMETREE **activenames;
1608  LONG *termstack;
1610  UWORD *cmod;
1611  UWORD *powmod;
1612  UWORD *modpowers;
1613  UWORD *halfmod; /* (C) half the modulus when not zero */
1614  WORD *ProtoType; /* (C) The subexpression prototype {wildcards} */
1615  WORD *WildC; /* (C) Filling point for wildcards. */
1616  LONG *IfHeap;
1617  LONG *IfCount;
1618  LONG *IfStack;
1619  UBYTE *iBuffer;
1620  UBYTE *iPointer;
1621  UBYTE *iStop;
1622  UBYTE **LabelNames;
1623  WORD *FixIndices;
1625  UBYTE *WildcardNames;
1626  int *Labels;
1627  SBYTE *tokens;
1628  SBYTE *toptokens;
1629  SBYTE *endoftokens;
1631  UWORD *modinverses; /* Table for inverses of primes */
1632  UBYTE *Fortran90Kind; /* The kind of number in Fortran 90 as in _ki */
1633  WORD **MultiBracketBuf; /* Array of buffers for multi-level brackets */
1634  UBYTE *extrasym; /* Array with the name for extra symbols in ToPolynomial */
1635  WORD *doloopstack; /* To keep track of begin and end of doloops */
1636  WORD *doloopnest; /* To keep track of nesting of doloops etc */
1641  WORD *IfSumCheck;
1642  WORD *CommuteInSet; /* groups of noncommuting functions that can commute */
1643  UBYTE *TestValue; /* For debugging */
1644 #ifdef PARALLELCODE
1645  LONG *inputnumbers;
1646  WORD *pfirstnum;
1647 #endif
1648 #ifdef WITHPTHREADS
1649  pthread_mutex_t halfmodlock; /* () Lock for adding buffer for halfmod */
1650 #endif
1651  LONG argstack[MAXNEST]; /* (C) {contents} Stack for nesting of Argument */
1652  LONG insidestack[MAXNEST]; /* (C) {contents} Stack for Argument or Inside. */
1653  LONG inexprstack[MAXNEST]; /* (C) {contents} Stack for Argument or Inside. */
1654  LONG iBufferSize; /* (C) Size of the input buffer */
1655  LONG TransEname; /* (C) Used when a new definition overwrites
1656  an old expression. */
1657  LONG ProcessBucketSize; /* (C) */
1658  LONG mProcessBucketSize; /* (C) */
1659  LONG CModule; /* (C) Counter of current module */
1660  LONG ThreadBucketSize; /* (C) Roughly the maximum number of input terms */
1664  int cbufnum;
1665  int AutoDeclareFlag;
1667  int NoShowInput; /* (C) No listing of input as in .prc, #do */
1668  int ShortStats; /* (C) */
1669  int compiletype; /* (C) type of statement {DECLARATION etc} */
1670  int firstconstindex; /* (C) flag for giving first error message */
1671  int insidefirst; /* (C) Not used yet */
1672  int minsidefirst; /* (?) Not used yet */
1673  int wildflag; /* (C) Flag for marking use of wildcards */
1674  int NumLabels; /* (C) Number of labels {in Labels} */
1675  int MaxLabels; /* (C) Size of Labels array */
1676  int lDefDim; /* (C) */
1677  int lDefDim4; /* (C) */
1678  int NumWildcardNames; /* (C) Number of ?a variables */
1679  int WildcardBufferSize; /* (C) size of WildcardNames buffer */
1680  int MaxIf; /* (C) size of IfHeap, IfSumCheck, IfCount */
1681  int NumStreams; /* (C) */
1682  int MaxNumStreams; /* (C) */
1683  int firstctypemessage; /* (C) Flag for giving first st order error */
1684  int tablecheck; /* (C) For table checking */
1685  int idoption; /* (C) */
1686  int BottomLevel; /* (C) For propercount. Not used!!! */
1687  int CompileLevel; /* (C) Subexpression level */
1688  int TokensWriteFlag; /* (C) */
1689  int UnsureDollarMode; /* (C)?Controls error messages undefined $'s */
1690  int outsidefun; /* (C) Used for writing Tables to file */
1691  int funpowers; /* (C) */
1692  int WarnFlag; /* (C) */
1693  int StatsFlag; /* (C) */
1694  int NamesFlag; /* (C) */
1695  int CodesFlag; /* (C) */
1696  int SetupFlag; /* (C) */
1697  int SortType; /* (C) */
1698  int lSortType; /* (C) */
1699  int ThreadStats; /* (C) */
1700  int FinalStats; /* (C) */
1701  int OldParallelStats; /* (C) */
1702  int ThreadsFlag;
1703  int ThreadBalancing;
1704  int ThreadSortFileSynch;
1705  int ProcessStats; /* (C) */
1706  int BracketNormalize; /* (C) Indicates whether the bracket st is normalized */
1707  int maxtermlevel; /* (C) Size of termstack */
1708  int dumnumflag; /* (C) Where there dummy indices in tokenizer? */
1709  int bracketindexflag; /* (C) Are brackets going to be indexed? */
1710  int parallelflag; /* (C) parallel allowed? */
1711  int mparallelflag; /* (C) parallel allowed in this module? */
1712  int inparallelflag; /* (C) inparallel allowed? */
1713  int partodoflag; /* (C) parallel allowed? */
1714  int properorderflag; /* (C) clean normalizing. */
1715  int vetofilling; /* (C) vetoes overwriting in tablebase stubs */
1716  int tablefilling; /* (C) to notify AddRHS we are filling a table */
1717  int vetotablebasefill; /* (C) For the load in tablebase */
1718  int exprfillwarning; /* (C) Warning has been printed for expressions in fill statements */
1719  int lhdollarflag; /* (R) left hand dollar present */
1720  int NoCompress; /* (R) Controls native compression */
1721  int IsFortran90; /* Tells whether the Fortran is Fortran90 */
1722  int MultiBracketLevels; /* Number of elements in MultiBracketBuf */
1723  int topolynomialflag; /* To avoid ToPolynomial and FactArg together */
1724  int ffbufnum; /* Buffer number for user defined factorizations */
1725  int OldFactArgFlag;
1726  int MemDebugFlag; /* Only used when MALLOCDEBUG in tools.c */
1727  int OldGCDflag;
1728  int WTimeStatsFlag;
1729  int doloopstacksize;
1730  int dolooplevel;
1735  int SizeCommuteInSet; /* Size of the CommuteInSet buffer */
1736 #ifdef PARALLELCODE
1737  int numpfirstnum; /* For redefine */
1738  int sizepfirstnum; /* For redefine */
1739 #endif
1740  int origin; /* Determines whether .sort or ModuleOption */
1741  int vectorlikeLHS;
1742  WORD argsumcheck[MAXNEST]; /* (C) Checking of nesting */
1743  WORD insidesumcheck[MAXNEST];/* (C) Checking of nesting */
1744  WORD inexprsumcheck[MAXNEST];/* (C) Checking of nesting */
1745  WORD RepSumCheck[MAXREPEAT];/* (C) Checks nesting of repeat, if, argument */
1746  WORD lUniTrace[4]; /* (C) */
1747  WORD RepLevel; /* (C) Tracks nesting of repeat. */
1748  WORD arglevel; /* (C) level of nested argument statements */
1749  WORD insidelevel; /* (C) level of nested inside statements */
1750  WORD inexprlevel; /* (C) level of nested inexpr statements */
1751  WORD termlevel; /* (C) level of nested term statements */
1752  WORD MustTestTable; /* (C) Indicates whether tables have been changed */
1753  WORD DumNum; /* (C) */
1754  WORD ncmod; /* (C) Local setting of modulus. size of cmod */
1755  WORD npowmod; /* (C) Local printing as powers. size powmod */
1756  WORD modmode; /* (C) Mode for modulus calculus */
1757  WORD nhalfmod; /* relevant word size of halfmod when defined */
1758  WORD DirtPow; /* (C) Flag for changes in printing mod powers */
1759  WORD lUnitTrace; /* (C) Local value of Tr[1] */
1760  WORD NwildC; /* (C) Wildcard counter */
1761  WORD ComDefer; /* (C) defer brackets */
1762  WORD CollectFun; /* (C) Collect function number */
1763  WORD AltCollectFun; /* (C) Alternate Collect function number */
1764  WORD OutputMode; /* (C) */
1765  WORD Cnumpows;
1766  WORD OutputSpaces; /* (C) */
1767  WORD OutNumberType; /* (C) Controls RATIONAL/FLOAT output */
1768  WORD DidClean; /* (C) Test whether nametree needs cleaning */
1769  WORD IfLevel; /* (C) */
1770  WORD WhileLevel; /* (C) */
1771  WORD LogHandle; /* (C) The Log File */
1772  WORD LineLength; /* (C) */
1773  WORD StoreHandle; /* (C) Handle of .str file */
1774  WORD HideLevel; /* (C) Hiding indicator */
1775  WORD lPolyFun; /* (C) local value of PolyFun */
1776  WORD lPolyFunInv; /* (C) local value of Inverse of PolyFun */
1777  WORD lPolyFunType; /* (C) local value of PolyFunType */
1778  WORD lPolyFunExp;
1779  WORD lPolyFunVar;
1780  WORD lPolyFunPow;
1781  WORD SymChangeFlag; /* (C) */
1782  WORD CollectPercentage; /* (C) Collect function percentage */
1783  WORD ShortStatsMax; /* For On FewerStatistics 10; */
1784  WORD extrasymbols; /* Flag for the extra symbsols output mode */
1785  WORD PolyRatFunChanged; /* Keeps track whether we changed in the compiler */
1786  WORD ToBeInFactors;
1787  WORD InnerTest; /* For debugging */
1788 #ifdef WITHMPI
1789  WORD RhsExprInModuleFlag; /* (C) Set by the compiler if RHS expressions exists. */
1790 #endif
1791  UBYTE Commercial[COMMERCIALSIZE+2]; /* (C) Message to be printed in statistics */
1792  UBYTE debugFlags[MAXFLAGS+2]; /* On/Off Flag number(s) */
1793 #if defined(WITHPTHREADS)
1794  PADPOSITION(47,8+3*MAXNEST,72,45+3*MAXNEST+MAXREPEAT,COMMERCIALSIZE+MAXFLAGS+4+sizeof(LIST)*17+sizeof(pthread_mutex_t));
1795 #elif defined(WITHMPI)
1796  PADPOSITION(47,8+3*MAXNEST,72,46+3*MAXNEST+MAXREPEAT,COMMERCIALSIZE+MAXFLAGS+4+sizeof(LIST)*17);
1797 #else
1798  PADPOSITION(45,8+3*MAXNEST,70,45+3*MAXNEST+MAXREPEAT,COMMERCIALSIZE+MAXFLAGS+4+sizeof(LIST)*17);
1799 #endif
1800 };
1801 /*
1802  #] C :
1803  #[ S : The S struct defines objects changed at the start of the run (Processor)
1804  Basically only set by the master.
1805 */
1813 struct S_const {
1814  POSITION MaxExprSize; /* ( ) Maximum size of in/out/sort */
1815 #ifdef WITHPTHREADS
1816  pthread_mutex_t inputslock;
1817  pthread_mutex_t outputslock;
1818  pthread_mutex_t MaxExprSizeLock;
1819 #endif
1820  POSITION *OldOnFile; /* (S) File positions of expressions */
1821  WORD *OldNumFactors; /* ( ) NumFactors in (old) expression */
1822  WORD *Oldvflags; /* ( ) vflags in (old) expression */
1823  int NumOldOnFile; /* (S) Number of expressions in OldOnFile */
1824  int NumOldNumFactors; /* (S) Number of expressions in OldNumFactors */
1825  int MultiThreaded; /* (S) Are we running multi-threaded? */
1826 #ifdef WITHPTHREADS
1827  int MasterSort; /* Final stage of sorting to the master */
1828 #endif
1829 #ifdef WITHMPI
1830  int printflag; /* controls MesPrint() on each slave */
1831 #endif
1832  int Balancing; /* For second stage loadbalancing */
1833  WORD ExecMode; /* (S) */
1834 
1835  WORD CollectOverFlag; /* (R) Indicates overflow at Collect */
1836 #ifdef WITHPTHREADS
1837  WORD sLevel; /* Copy of AR0.sLevel because it can get messy */
1838 #endif
1839 #if defined(WITHPTHREADS)
1840  PADPOSITION(3,0,5,3,sizeof(pthread_mutex_t)*3);
1841 #elif defined(WITHMPI)
1842  PADPOSITION(3,0,5,2,0);
1843 #else
1844  PADPOSITION(3,0,4,2,0);
1845 #endif
1846 };
1847 /*
1848  #] S :
1849  #[ R : The R struct defines objects changed at run time.
1850  They determine the environment that has to be transfered
1851  together with a term during multithreaded execution.
1852 */
1861 struct R_const {
1862  FILEDATA StoreData; /* (O) */
1863  FILEHANDLE Fscr[3]; /* (R) Dollars etc play with it too */
1864  FILEHANDLE FoStage4[2]; /* (R) In Sort. Stage 4. */
1865  POSITION DefPosition; /* (R) Deferred position of keep brackets. */
1866  FILEHANDLE *infile; /* (R) Points alternatingly to Fscr[0] or Fscr[1] */
1867  FILEHANDLE *outfile; /* (R) Points alternatingly to Fscr[1] or Fscr[0] */
1868  FILEHANDLE *hidefile; /* (R) Points to Fscr[2] */
1869 
1870  WORD *CompressBuffer; /* (M) */
1871  WORD *ComprTop; /* (M) */
1872  WORD *CompressPointer; /* (R) */
1873  VOID *CompareRoutine;
1874  ULONG *wranfia;
1875 
1876  LONG OldTime; /* (R) Zero time. Needed in timer. */
1877  LONG InInBuf; /* (R) Characters in input buffer. Scratch files. */
1878  LONG InHiBuf; /* (R) Characters in hide buffer. Scratch file. */
1879  LONG pWorkSize; /* (R) Size of pWorkSpace */
1880  LONG lWorkSize; /* (R) Size of lWorkSpace */
1881  LONG posWorkSize; /* (R) Size of posWorkSpace */
1882  ULONG wranfseed;
1883  int NoCompress; /* (R) Controls native compression */
1884  int gzipCompress; /* (R) Controls gzip compression */
1885  int Cnumlhs; /* Local copy of cbuf[rbufnum].numlhs */
1886  int outtohide; /* Indicates that output is directly to hide */
1887 #ifdef WITHPTHREADS
1888  int exprtodo; /* The expression to do in parallel mode */
1889 #endif
1890  int wranfcall;
1891  int wranfnpair1;
1892  int wranfnpair2;
1893 #if ( BITSINWORD == 32 )
1894  WORD PrimeList[5000];
1895  WORD numinprimelist;
1896  WORD notfirstprime;
1897 #endif
1898  WORD GetFile; /* (R) Where to get the terms {like Hide} */
1899  WORD KeptInHold; /* (R) */
1900  WORD BracketOn; /* (R) Intensly used in poly_ */
1901  WORD MaxBracket; /* (R) Size of BrackBuf. Changed by poly_ */
1902  WORD CurDum; /* (R) Current maximum dummy number */
1903  WORD DeferFlag; /* (R) For defered brackets */
1904  WORD TePos; /* (R) */
1905  WORD sLevel; /* (R) Sorting level */
1906  WORD Stage4Name; /* (R) Sorting only */
1907  WORD GetOneFile; /* (R) Getting from hide or regular */
1908  WORD PolyFun; /* (C) Number of the PolyFun function */
1909  WORD PolyFunInv; /* (C) Number of the Inverse of the PolyFun function */
1910  WORD PolyFunType; /* () value of PolyFunType */
1911  WORD PolyFunExp;
1912  WORD PolyFunVar;
1913  WORD PolyFunPow;
1914  WORD Eside; /* () Tells which side of = sign */
1915  WORD MaxDum; /* Maximum dummy value in an expression */
1916  WORD level; /* Running level in Generator */
1917  WORD expchanged; /* (R) Info about expression */
1918  WORD expflags; /* (R) Info about expression */
1919  WORD CurExpr; /* (S) Number of current expression */
1920  WORD SortType; /* A copy of AC.SortType to play with */
1921  WORD ShortSortCount; /* For On FewerStatistics 10; */
1922 #if ( BITSINWORD == 32 )
1923 #ifdef WITHPTHREADS
1924  PADPOSITION(8,7,8,5026,0);
1925 #else
1926  PADPOSITION(8,7,7,5026,0);
1927 #endif
1928 #else
1929 #ifdef WITHPTHREADS
1930  PADPOSITION(8,7,8,24,0);
1931 #else
1932  PADPOSITION(8,7,7,24,0);
1933 #endif
1934 #endif
1935 };
1936 
1937 /*
1938  #] R :
1939  #[ T : These are variables that stay in each thread during multi threaded execution.
1940 */
1949 struct T_const {
1950 #ifdef WITHPTHREADS
1951  SORTBLOCK SB;
1952 #endif
1953  SORTING *S0; /* (-) The thread specific sort buffer */
1954  SORTING *SS; /* (R) Current sort buffer */
1955  NESTING Nest; /* (R) Nesting of function levels etc. */
1956  NESTING NestStop; /* (R) */
1957  NESTING NestPoin; /* (R) */
1958  WORD *BrackBuf; /* (R) Bracket buffer. Used by poly_ at runtime. */
1959  STORECACHE StoreCache; /* (R) Cache for picking up stored expr. */
1960  STORECACHE StoreCacheAlloc; /* (R) Permanent address of StoreCache to keep valgrind happy */
1961  WORD **pWorkSpace; /* (R) Workspace for pointers. Dynamic. */
1962  LONG *lWorkSpace; /* (R) WorkSpace for LONG. Dynamic. */
1963  POSITION *posWorkSpace; /* (R) WorkSpace for file positions */
1964  WORD *WorkSpace; /* (M) */
1965  WORD *WorkTop; /* (M) */
1966  WORD *WorkPointer; /* (R) Pointer in the WorkSpace heap. */
1967  int *RepCount; /* (M) Buffer for repeat nesting */
1968  int *RepTop; /* (M) Top of RepCount buffer */
1969  WORD *WildArgTaken; /* (N) Stack for wildcard pattern matching */
1970  UWORD *factorials; /* (T) buffer of factorials. Dynamic. */
1971  WORD *small_power_n; /* length of the number */
1972  UWORD **small_power; /* the number*/
1973  UWORD *bernoullis; /* (T) The buffer with bernoulli numbers. Dynamic. */
1974  WORD *primelist;
1975  LONG *pfac; /* (T) array of positions of factorials. Dynamic. */
1976  LONG *pBer; /* (T) array of positions of Bernoulli's. Dynamic. */
1977  WORD *TMaddr; /* (R) buffer for TestSub */
1978  WORD *WildMask; /* (N) Wildcard info during pattern matching */
1979  WORD *previousEfactor; /* () Cache for factors in expressions */
1980  WORD **TermMemHeap; /* For TermMalloc. Set zero in Checkpoint */
1981  UWORD **NumberMemHeap; /* For NumberMalloc. Set zero in Checkpoint */
1982  UWORD **CacheNumberMemHeap; /* For CacheNumberMalloc. Set zero in Checkpoint */
1983  BRACKETINFO *bracketinfo;
1984  WORD **ListPoly;
1985  WORD *ListSymbols;
1986  UWORD *NumMem;
1987  PARTI partitions;
1988  LONG sBer; /* (T) Size of the bernoullis buffer */
1989  LONG pWorkPointer; /* (R) Offset-pointer in pWorkSpace */
1990  LONG lWorkPointer; /* (R) Offset-pointer in lWorkSpace */
1991  LONG posWorkPointer; /* (R) Offset-pointer in posWorkSpace */
1992  LONG InNumMem;
1993  int sfact; /* (T) size of the factorials buffer */
1994  int mfac; /* (T) size of the pfac array. */
1995  int ebufnum; /* (R) extra compiler buffer */
1996  int fbufnum; /* extra compiler buffer for factorization cache */
1997  int allbufnum; /* extra compiler buffer for id,all */
1998  int aebufnum; /* extra compiler buffer for id,all */
1999  int idallflag; /* indicates use of id,all buffers */
2000  int idallnum;
2001  int idallmaxnum;
2002  int WildcardBufferSize; /* () local copy for updates */
2003 #ifdef WITHPTHREADS
2004  int identity; /* () When we work with B->T */
2005  int LoadBalancing; /* Needed for synchronization */
2006 #ifdef WITHSORTBOTS
2007  int SortBotIn1; /* Input stream 1 for a SortBot */
2008  int SortBotIn2; /* Input stream 2 for a SortBot */
2009 #endif
2010 #endif
2011  int TermMemMax; /* For TermMalloc. Set zero in Checkpoint */
2012  int TermMemTop; /* For TermMalloc. Set zero in Checkpoint */
2013  int NumberMemMax; /* For NumberMalloc. Set zero in Checkpoint */
2014  int NumberMemTop; /* For NumberMalloc. Set zero in Checkpoint */
2015  int CacheNumberMemMax; /* For CacheNumberMalloc. Set zero in Checkpoint */
2016  int CacheNumberMemTop; /* For CacheNumberMalloc. Set zero in Checkpoint */
2017  int bracketindexflag; /* Are brackets going to be indexed? */
2018  int optimtimes; /* Number of the evaluation of the MCTS tree */
2019  int ListSymbolsSize;
2020  int NumListSymbols;
2021  int numpoly;
2022  int LeaveNegative;
2023  int TrimPower; /* Indicates trimming in polyratfun expansion */
2024  WORD small_power_maxx; /* size of the cache for small powers */
2025  WORD small_power_maxn; /* size of the cache for small powers */
2026  WORD dummysubexp[SUBEXPSIZE+4]; /* () used in normal.c */
2027  WORD comsym[8]; /* () Used in tools.c = {8,SYMBOL,4,0,1,1,1,3} */
2028  WORD comnum[4]; /* () Used in tools.c = { 4,1,1,3 } */
2029  WORD comfun[FUNHEAD+4]; /* () Used in tools.c = {7,FUNCTION,3,0,1,1,3} */
2030  /* or { 8,FUNCTION,4,0,0,1,1,3 } */
2031  WORD comind[7]; /* () Used in tools.c = {7,INDEX,3,0,1,1,3} */
2032  WORD MinVecArg[7+ARGHEAD]; /* (N) but should be more local */
2033  WORD FunArg[4+ARGHEAD+FUNHEAD]; /* (N) but can be more local */
2034  WORD locwildvalue[SUBEXPSIZE]; /* () Used in argument.c = {SUBEXPRESSION,SUBEXPSIZE,0,0,0} */
2035  WORD mulpat[SUBEXPSIZE+5]; /* () Used in argument.c = {TYPEMULT, SUBEXPSIZE+3, 0, */
2036  /* SUBEXPRESSION, SUBEXPSIZE, 0, 1, 0, 0, 0 } */
2037  WORD proexp[SUBEXPSIZE+5]; /* () Used in poly.c */
2038  WORD TMout[40]; /* (R) Passing info */
2039  WORD TMbuff; /* (R) Communication between TestSub and Genera */
2040  WORD TMdolfac; /* factor number for dollar */
2041  WORD nfac; /* (T) Number of highest stored factorial */
2042  WORD nBer; /* (T) Number of highest bernoulli number. */
2043  WORD mBer; /* (T) Size of buffer pBer. */
2044  WORD PolyAct; /* (R) Used for putting the PolyFun at end. ini at 0 */
2045  WORD RecFlag; /* (R) Used in TestSub. ini at zero. */
2046  WORD inprimelist;
2047  WORD sizeprimelist;
2048  WORD fromindex; /* Tells the compare routine whether call from index */
2049 #ifdef WITHPTHREADS
2050 #ifdef WITHSORTBOTS
2051  PADPOINTER(5,27,100+SUBEXPSIZE*4+FUNHEAD*2+ARGHEAD*2,0);
2052 #else
2053  PADPOINTER(5,25,100+SUBEXPSIZE*4+FUNHEAD*2+ARGHEAD*2,0);
2054 #endif
2055 #else
2056  PADPOINTER(5,23,100+SUBEXPSIZE*4+FUNHEAD*2+ARGHEAD*2,0);
2057 #endif
2058 };
2059 /*
2060  #] T :
2061  #[ N : The N struct contains variables used in running information
2062  that is inside blocks that should not be split, like pattern
2063  matching, traces etc. They are local for each thread.
2064  They don't need initializations.
2065 */
2074 struct N_const {
2075  POSITION OldPosIn; /* (R) Used in sort. */
2076  POSITION OldPosOut; /* (R) Used in sort */
2077  POSITION theposition; /* () Used in index.c */
2078  WORD *EndNest; /* (R) Nesting of function levels etc. */
2079  WORD *Frozen; /* (R) Bracket info */
2080  WORD *FullProto; /* (R) Prototype of a subexpression or table */
2081  WORD *cTerm; /* (R) Current term for coef_ and term_ */
2082  int *RepPoint; /* (R) Pointer in RepCount buffer. Tracks repeat */
2083  WORD *WildValue; /* (N) Wildcard info during pattern matching */
2084  WORD *WildStop; /* (N) Wildcard info during pattern matching */
2085  WORD *argaddress; /* (N) Used in pattern matching of arguments */
2086  WORD *RepFunList; /* (N) For pattern matching */
2087  WORD *patstop; /* (N) Used in pattern matching */
2088  WORD *terstop; /* (N) Used in pattern matching */
2089  WORD *terstart; /* (N) Used in pattern matching */
2090  WORD *terfirstcomm; /* (N) Used in pattern matching */
2091  WORD *DumFound; /* (N) For renumbering indices {make local?} */
2092  WORD **DumPlace; /* (N) For renumbering indices {make local?} */
2093  WORD **DumFunPlace; /* (N) For renumbering indices {make local?} */
2094  WORD *UsedSymbol; /* (N) When storing terms of a global expr. */
2095  WORD *UsedVector; /* (N) When storing terms of a global expr. */
2096  WORD *UsedIndex; /* (N) When storing terms of a global expr. */
2097  WORD *UsedFunction; /* (N) When storing terms of a global expr. */
2098  WORD *MaskPointer; /* (N) For wildcard pattern matching */
2099  WORD *ForFindOnly; /* (N) For wildcard pattern matching */
2100  WORD *findTerm; /* (N) For wildcard pattern matching */
2101  WORD *findPattern; /* (N) For wildcard pattern matching */
2102 #ifdef WITHZLIB
2103  Bytef **ziobufnum; /* () Used in compress.c */
2104  Bytef *ziobuffers; /* () Used in compress.c */
2105 #endif
2106  WORD *dummyrenumlist; /* () Used in execute.c and store.c */
2107  int *funargs; /* () Used in lus.c */
2108  WORD **funlocs; /* () Used in lus.c */
2109  int *funinds; /* () Used in lus.c */
2110  UWORD *NoScrat2; /* () Used in normal.c */
2111  WORD *ReplaceScrat; /* () Used in normal.c */
2112  TRACES *tracestack; /* () used in opera.c */
2113  WORD *selecttermundo; /* () Used in pattern.c */
2114  WORD *patternbuffer; /* () Used in pattern.c */
2115  WORD *termbuffer; /* () Used in pattern.c */
2116  WORD **PoinScratch; /* () used in reshuf.c */
2117  WORD **FunScratch; /* () used in reshuf.c */
2118  WORD *RenumScratch; /* () used in reshuf.c */
2119  FUN_INFO *FunInfo; /* () Used in smart.c */
2120  WORD **SplitScratch; /* () Used in sort.c */
2121  WORD **SplitScratch1; /* () Used in sort.c */
2122  SORTING **FunSorts; /* () Used in sort.c */
2123  UWORD *SoScratC; /* () Used in sort.c */
2124  WORD *listinprint; /* () Used in proces.c and message.c */
2125  WORD *currentTerm; /* () Used in proces.c and message.c */
2126  WORD **arglist; /* () Used in function.c */
2127  int *tlistbuf; /* () used in lus.c */
2128 #ifdef WHICHSUBEXPRESSION
2129  UWORD *BinoScrat; /* () Used in proces.c */
2130 #endif
2131  WORD *compressSpace; /* () Used in sort.c */
2132 #ifdef WITHPTHREADS
2133  THREADBUCKET *threadbuck;
2134  EXPRESSIONS expr;
2135 #endif
2136  UWORD *SHcombi;
2137  WORD *poly_vars;
2138  UWORD *cmod; /* Local setting of modulus. Pointer to value. */
2139  SHvariables SHvar;
2140  LONG deferskipped; /* () Used in proces.c store.c and parallel.c */
2141  LONG InScratch; /* () Used in sort.c */
2142  LONG SplitScratchSize; /* () Used in sort.c */
2143  LONG InScratch1; /* () Used in sort.c */
2144  LONG SplitScratchSize1; /* () Used in sort.c */
2145  LONG ninterms; /* () Used in proces.c and sort.c */
2146 #ifdef WITHPTHREADS
2147  LONG inputnumber; /* () For use in redefine */
2148  LONG lastinindex;
2149 #endif
2150 #ifdef WHICHSUBEXPRESSION
2151  LONG last2; /* () Used in proces.c */
2152  LONG last3; /* () Used in proces.c */
2153 #endif
2154  LONG SHcombisize;
2155  int NumTotWildArgs; /* (N) Used in pattern matching */
2156  int UseFindOnly; /* (N) Controls pattern routines */
2157  int UsedOtherFind; /* (N) Controls pattern routines */
2158  int ErrorInDollar; /* (R) */
2159  int numfargs; /* () Used in lus.c */
2160  int numflocs; /* () Used in lus.c */
2161  int nargs; /* () Used in lus.c */
2162  int tohunt; /* () Used in lus.c */
2163  int numoffuns; /* () Used in lus.c */
2164  int funisize; /* () Used in lus.c */
2165  int RSsize; /* () Used in normal.c */
2166  int numtracesctack; /* () used in opera.c */
2167  int intracestack; /* () used in opera.c */
2168  int numfuninfo; /* () Used in smart.c */
2169  int NumFunSorts; /* () Used in sort.c */
2170  int MaxFunSorts; /* () Used in sort.c */
2171  int arglistsize; /* () Used in function.c */
2172  int tlistsize; /* () used in lus.c */
2173  int filenum; /* () used in setfile.c */
2174  int compressSize; /* () Used in sort.c */
2175  int polysortflag;
2176  int nogroundlevel; /* () Used to see whether pattern matching at groundlevel */
2177  int subsubveto; /* () Sabotage combining subexpressions in TestSub */
2178  WORD MaxRenumScratch; /* () used in reshuf.c */
2179  WORD oldtype; /* (N) WildCard info at pattern matching */
2180  WORD oldvalue; /* (N) WildCard info at pattern matching */
2181  WORD NumWild; /* (N) Used in Wildcard */
2182  WORD RepFunNum; /* (N) Used in pattern matching */
2183  WORD DisOrderFlag; /* (N) Disorder option? Used in pattern matching */
2184  WORD WildDirt; /* (N) dirty in wldcard substitution. */
2185  WORD NumFound; /* (N) in reshuf only. Local? */
2186  WORD WildReserve; /* (N) Used in the wildcards */
2187  WORD TeInFun; /* (R) Passing type of action */
2188  WORD TeSuOut; /* (R) Passing info. Local? */
2189  WORD WildArgs; /* (R) */
2190  WORD WildEat; /* (R) */
2191  WORD PolyNormFlag; /* (R) For polynomial arithmetic */
2192  WORD PolyFunTodo; /* deals with expansions and multiplications */
2193  WORD sizeselecttermundo; /* () Used in pattern.c */
2194  WORD patternbuffersize; /* () Used in pattern.c */
2195  WORD numlistinprint; /* () Used in process.c */
2196  WORD ncmod; /* () used as some type of flag to disable */
2197  WORD ExpectedSign;
2198  WORD SignCheck;
2199  WORD IndDum; /* Active dummy indices */
2200  WORD poly_num_vars;
2201  WORD idfunctionflag;
2202  WORD poly_vars_type; /* type of allocation. For free. */
2203  WORD tryterm; /* For EndSort(...,2) */
2204 #ifdef WHICHSUBEXPRESSION
2205  WORD nbino; /* () Used in proces.c */
2206  WORD last1; /* () Used in proces.c */
2207 #endif
2208 #ifdef WITHPTHREADS
2209 #ifdef WHICHSUBEXPRESSION
2210 #ifdef WITHZLIB
2211  PADPOSITION(55,11,23,28,sizeof(SHvariables));
2212 #else
2213  PADPOSITION(53,11,23,28,sizeof(SHvariables));
2214 #endif
2215 #else
2216 #ifdef WITHZLIB
2217  PADPOSITION(54,9,23,26,sizeof(SHvariables));
2218 #else
2219  PADPOSITION(52,9,23,26,sizeof(SHvariables));
2220 #endif
2221 #endif
2222 #else
2223 #ifdef WHICHSUBEXPRESSION
2224 #ifdef WITHZLIB
2225  PADPOSITION(53,9,23,28,sizeof(SHvariables));
2226 #else
2227  PADPOSITION(51,9,23,28,sizeof(SHvariables));
2228 #endif
2229 #else
2230 #ifdef WITHZLIB
2231  PADPOSITION(52,7,23,26,sizeof(SHvariables));
2232 #else
2233  PADPOSITION(50,7,23,26,sizeof(SHvariables));
2234 #endif
2235 #endif
2236 #endif
2237 };
2238 
2239 /*
2240  #] N :
2241  #[ O : The O struct concerns output variables
2242 */
2251 struct O_const {
2252  FILEDATA SaveData; /* (O) */
2253  STOREHEADER SaveHeader; /* () System Independent save-Files */
2254  OPTIMIZERESULT OptimizeResult;
2255  UBYTE *OutputLine; /* (O) Sits also in debug statements */
2256  UBYTE *OutStop; /* (O) Top of OutputLine buffer */
2257  UBYTE *OutFill; /* (O) Filling point in OutputLine buffer */
2258  WORD *bracket; /* (O) For writing brackets */
2259  WORD *termbuf; /* (O) For writing terms */
2260  WORD *tabstring;
2261  UBYTE *wpos; /* (O) Only when storing file {local?} */
2262  UBYTE *wpoin; /* (O) Only when storing file {local?} */
2263  UBYTE *DollarOutBuffer; /* (O) Outputbuffer for Dollars */
2264  UBYTE *CurBufWrt; /* (O) Name of currently written expr. */
2265  VOID (*FlipWORD)(UBYTE *); /* () Function pointers for translations. Initialized by ReadSaveHeader() */
2266  VOID (*FlipLONG)(UBYTE *);
2267  VOID (*FlipPOS)(UBYTE *);
2268  VOID (*FlipPOINTER)(UBYTE *);
2269  VOID (*ResizeData)(UBYTE *,int,UBYTE *,int);
2270  VOID (*ResizeWORD)(UBYTE *,UBYTE *);
2271  VOID (*ResizeNCWORD)(UBYTE *,UBYTE *);
2272  VOID (*ResizeLONG)(UBYTE *,UBYTE *);
2273  VOID (*ResizePOS)(UBYTE *,UBYTE *);
2274  VOID (*ResizePOINTER)(UBYTE *,UBYTE *);
2275  VOID (*CheckPower)(UBYTE *);
2276  VOID (*RenumberVec)(UBYTE *);
2277  DICTIONARY **Dictionaries;
2278  UBYTE *tensorList; /* Dynamically allocated list with functions that are tensorial. */
2279  WORD *inscheme; /* for feeding a Horner scheme to Optimize */
2280 /*----Leave NumInBrack as first non-pointer. This is used by the checkpoints--*/
2281  LONG NumInBrack; /* (O) For typing [] option in print */
2282  LONG wlen; /* (O) Used to store files. */
2283  LONG DollarOutSizeBuffer; /* (O) Size of DollarOutBuffer */
2284  LONG DollarInOutBuffer; /* (O) Characters in DollarOutBuffer */
2285 #if defined(mBSD) && defined(MICROTIME)
2286  LONG wrap; /* (O) For statistics time. wrap around */
2287  LONG wrapnum; /* (O) For statistics time. wrap around */
2288 #endif
2289  OPTIMIZE Optimize;
2290  int OutInBuffer; /* (O) Which routine does the writing */
2291  int NoSpacesInNumbers; /* For very long numbers */
2292  int BlockSpaces; /* For very long numbers */
2293  int CurrentDictionary;
2294  int SizeDictionaries;
2295  int NumDictionaries;
2296  int CurDictNumbers;
2297  int CurDictVariables;
2298  int CurDictSpecials;
2299  int CurDictFunWithArgs;
2300  int CurDictNumberWarning;
2301  int CurDictNotInFunctions;
2302  int CurDictInDollars;
2303  int gNumDictionaries;
2304  WORD schemenum; /* for feeding a Horner scheme to Optimize */
2305  WORD transFlag; /* () >0 indicades that translations have to be done */
2306  WORD powerFlag; /* () >0 indicades that some exponents/powers had to be adjusted */
2307  WORD mpower; /* For maxpower adjustment to larger value */
2308  WORD resizeFlag; /* () >0 indicades that something went wrong when resizing words */
2309  WORD bufferedInd; /* () Contains extra INDEXENTRIES, see ReadSaveIndex() for an explanation */
2310  WORD OutSkip; /* (O) How many chars to skip in output line */
2311  WORD IsBracket; /* (O) Controls brackets */
2312  WORD InFbrack; /* (O) For writing only */
2313  WORD PrintType; /* (O) */
2314  WORD FortFirst; /* (O) Only in sch.c */
2315  WORD DoubleFlag; /* (O) Output in double precision */
2316  WORD IndentSpace; /* For indentation in output */
2317  WORD FactorMode; /* When the output should be written as factors */
2318  WORD FactorNum; /* Number of factor currently treated */
2319  WORD ErrorBlock;
2320  WORD OptimizationLevel; /* Level of optimization in the output */
2321  UBYTE FortDotChar; /* (O) */
2322 /*
2323  For the padding, please count also the number of int's in the OPTIMIZE struct.
2324 */
2325 #if defined(mBSD) && defined(MICROTIME)
2326  PADPOSITION(25,6,35,17,1);
2327 #else
2328  PADPOSITION(25,4,35,17,1);
2329 #endif
2330 };
2331 /*
2332  #] O :
2333  #[ X : The X struct contains variables that deal with the external channel
2334 */
2342 struct X_const {
2343  UBYTE *currentPrompt;
2344  UBYTE *shellname; /* if !=NULL (default is "/bin/sh -c"), start in
2345  the specified subshell*/
2346  UBYTE *stderrname; /* If !=NULL (default if "/dev/null"), stderr is
2347  redirected to the specified file*/
2348  int timeout; /* timeout to initialize preset channels.
2349  If timeout<0, the preset channels are
2350  already initialized*/
2351  int killSignal; /* signal number, SIGKILL by default*/
2352  int killWholeGroup; /* if 0, the signal is sent only to a process,
2353  if !=0 (default) is sent to a whole process group*/
2354  int daemonize; /* if !=0 (default), start in a daemon mode */
2355  int currentExternalChannel;
2356  PADPOINTER(0,5,0,0);
2357 };
2358 /*
2359  #] X :
2360  #[ Definitions :
2361 */
2362 
2363 #ifdef WITHPTHREADS
2364 
2370 typedef struct AllGlobals {
2371  struct M_const M;
2372  struct C_const C;
2373  struct S_const S;
2374  struct O_const O;
2375  struct P_const P;
2376  struct X_const X;
2377  PADPOSITION(0,0,0,0,sizeof(struct P_const)+sizeof(struct X_const));
2378 } ALLGLOBALS;
2379 
2385 typedef struct AllPrivates {
2386  struct R_const R;
2387  struct N_const N;
2388  struct T_const T;
2389  PADPOSITION(0,0,0,0,sizeof(struct T_const));
2390 } ALLPRIVATES;
2391 
2392 #else
2393 
2398 typedef struct AllGlobals {
2399  struct M_const M;
2400  struct C_const C;
2401  struct S_const S;
2402  struct R_const R;
2403  struct N_const N;
2404  struct O_const O;
2405  struct P_const P;
2406  struct T_const T;
2407  struct X_const X;
2408  PADPOSITION(0,0,0,0,sizeof(struct P_const)+sizeof(struct T_const)+sizeof(struct X_const));
2409 } ALLGLOBALS;
2410 
2411 #endif
2412 
2413 /*
2414  #] Definitions :
2415  #] A :
2416  #[ FG :
2417 */
2418 
2419 #ifdef ANSI
2420 typedef WORD (*WCN)(PHEAD WORD *,WORD *,WORD,WORD);
2421 typedef WORD (*WCN2)(PHEAD WORD *,WORD *);
2422 #else
2423 typedef WORD (*WCN)();
2424 typedef WORD (*WCN2)();
2425 #endif
2426 
2438 typedef struct FixedGlobals {
2439  WCN Operation[8];
2440  WCN2 OperaFind[6];
2441  char *VarType[10];
2442  char *ExprStat[21];
2443  char *FunNam[2];
2444  char *swmes[3];
2445  char *fname;
2446  char *fname2;
2447  UBYTE *s_one;
2448  WORD fnamebase;
2449  WORD fname2base;
2450  UINT cTable[256];
2451 } FIXEDGLOBALS;
2452 
2453 /*
2454  #] FG :
2455 */
2456 
2457 #endif
UBYTE * pointer
Definition: structs.h:679
WORD * tokenarglevel
Definition: structs.h:1630
WORD bufferssize
Definition: structs.h:366
struct VaRrEnUm VARRENUM
struct sOrT SORTING
int CheckpointFlag
Definition: structs.h:1731
LONG * NumTerms
Definition: structs.h:928
UBYTE revision
Definition: structs.h:88
WORD * buffers
Definition: structs.h:352
int value
Definition: structs.h:285
WORD number
Definition: structs.h:469
UBYTE sFun
Definition: structs.h:85
char * name
Definition: structs.h:953
LONG reserved
Definition: structs.h:354
NAMETREE * autonames
Definition: structs.h:1596
UBYTE * name
Definition: structs.h:780
struct ChAnNeL CHANNEL
LONG totind
Definition: structs.h:353
#define INFILEINDEX
Definition: structs.h:118
int numclear
Definition: structs.h:212
int numtree
Definition: structs.h:362
NAMETREE * exprnames
Definition: structs.h:1569
WORD left
Definition: structs.h:237
LONG clearnamefill
Definition: structs.h:267
struct CbUf CBUF
int parent
Definition: structs.h:282
LIST IndexList
Definition: structs.h:1577
LIST DubiousList
Definition: structs.h:1573
UBYTE * dollarname
Definition: structs.h:840
Definition: structs.h:431
WORD flags
Definition: structs.h:470
int prototypeSize
Definition: structs.h:357
UBYTE * buffer
Definition: structs.h:678
int right
Definition: structs.h:284
WORD size
Definition: structs.h:297
struct PaRtI PARTI
WORD * FixIndices
Definition: structs.h:1623
LONG namefill
Definition: structs.h:261
WORD SignCheck
Definition: structs.h:2198
WORD type
Definition: structs.h:240
Definition: structs.h:485
NAMENODE * namenode
Definition: structs.h:253
WORD * pattern
Definition: structs.h:344
struct AllGlobals ALLGLOBALS
WORD * bracketbuffer
Definition: structs.h:318
int left
Definition: structs.h:283
WORD nsymbols
Definition: structs.h:104
UBYTE * name
Definition: structs.h:837
Definition: structs.h:620
WORD nvectors
Definition: structs.h:106
LONG CheckpointStamp
Definition: structs.h:1661
POSITION position
Definition: structs.h:100
NAMETREE * dollarnames
Definition: structs.h:1568
#define PHEAD
Definition: ftypes.h:56
VARRENUM indi
Definition: structs.h:181
int sparse
Definition: structs.h:361
LONG * termsortstack
Definition: structs.h:1609
LIST cbufList
Definition: structs.h:1588
SBYTE empty[EMPTYININDEX]
Definition: structs.h:141
UBYTE * iBuffer
Definition: structs.h:1619
LONG CompressSize
Definition: structs.h:103
struct TaBlEs * spare
Definition: structs.h:351
int NoShowInput
Definition: structs.h:1667
VARRENUM vect
Definition: structs.h:182
POSITION next
Definition: structs.h:138
LIST ModOptDolList
Definition: structs.h:1583
UWORD * cmod
Definition: structs.h:1610
int size
Definition: structs.h:209
int strict
Definition: structs.h:360
UBYTE * top
Definition: structs.h:680
LONG symminfo
Definition: structs.h:465
WORD number
Definition: structs.h:241
struct PeRmUtEp PERMP
Definition: structs.h:1224
STREAM * Streams
Definition: structs.h:1605
WORD mode
Definition: structs.h:369
int cbufnum
Definition: structs.h:1664
LONG nodefill
Definition: structs.h:259
LONG nodesize
Definition: structs.h:258
Definition: minos.h:94
struct pReVaR PREVAR
WORD node
Definition: structs.h:473
WORD ** lhs
Definition: structs.h:925
SBYTE * toptokens
Definition: structs.h:1628
UBYTE lenPOINTER
Definition: structs.h:80
int numind
Definition: structs.h:358
UBYTE sVec
Definition: structs.h:84
int numglobal
Definition: structs.h:210
LONG globalnodefill
Definition: structs.h:266
UBYTE sInd
Definition: structs.h:83
POSITION variables
Definition: structs.h:102
WORD mini
Definition: structs.h:295
LONG globalnamefill
Definition: structs.h:264
WORD * termsumcheck
Definition: structs.h:1624
UBYTE lenPOS
Definition: structs.h:79
int num
Definition: structs.h:207
Definition: structs.h:921
LIST PotModDolList
Definition: structs.h:1582
struct ReNuMbEr * RENUMBER
WORD parent
Definition: structs.h:236
SBYTE name[MAXENAME+1]
Definition: structs.h:109
UWORD * gpowmod
Definition: structs.h:1320
Definition: structs.h:281
WORD * Pointer
Definition: structs.h:924
WORD * IfSumCheck
Definition: structs.h:1641
struct FiLe FILEHANDLE
WORD * vecnum
Definition: structs.h:187
set_of_char separators
Definition: structs.h:1566
INDEXENTRY expression[INFILEINDEX]
Definition: structs.h:140
UBYTE * FoldName
Definition: structs.h:681
UWORD * gcmod
Definition: structs.h:1319
WORD * dimension
Definition: structs.h:930
TABLES tabl
Definition: structs.h:464
LONG name
Definition: structs.h:235
LIST SymbolList
Definition: structs.h:1580
WORD symmetric
Definition: structs.h:472
WORD * symnum
Definition: structs.h:185
WORD SortType
Definition: structs.h:323
int usage
Definition: structs.h:287
UBYTE sSym
Definition: structs.h:82
UBYTE lenWORD
Definition: structs.h:77
WORD * renumlists
Definition: structs.h:385
WORD ggShortStatsMax
Definition: structs.h:1476
int blnce
Definition: structs.h:286
WORD maxi
Definition: structs.h:296
int wildarg
Definition: structs.h:784
WORD * tablepointers
Definition: structs.h:338
LIST FunctionList
Definition: structs.h:1575
LIST TableBaseList
Definition: structs.h:1584
void * lijst
Definition: structs.h:205
UBYTE * iStop
Definition: structs.h:1621
UBYTE * argtail
Definition: structs.h:349
UBYTE * name
Definition: structs.h:682
WORD balance
Definition: structs.h:239
UBYTE lenLONG
Definition: structs.h:78
WORD tablenum
Definition: structs.h:368
UBYTE * iPointer
Definition: structs.h:1620
SORTING * S0
Definition: structs.h:1318
WORD ** rhs
Definition: structs.h:926
POSITION length
Definition: structs.h:101
char * message
Definition: structs.h:206
WORD * hi
Definition: structs.h:168
POSITION number
Definition: structs.h:139
int MaxTreeSize
Definition: structs.h:364
LONG * IfHeap
Definition: structs.h:1616
struct InDeXeNtRy INDEXENTRY
WORD bufnum
Definition: structs.h:365
struct TrAcEn * TRACEN
STREAM * CurrentStream
Definition: structs.h:1606
WORD buffersfill
Definition: structs.h:367
Definition: structs.h:1069
struct NeStInG * NESTING
WORD nindices
Definition: structs.h:105
WORD * numdum
Definition: structs.h:929
LIST SetElementList
Definition: structs.h:1578
WORD complex
Definition: structs.h:468
int numtemp
Definition: structs.h:211
int maxnum
Definition: structs.h:208
LONG * termstack
Definition: structs.h:1608
COMPTREE * boomlijst
Definition: structs.h:931
LONG defined
Definition: structs.h:355
struct StOrEcAcHe * STORECACHE
MINMAX * mm
Definition: structs.h:346
WORD size
Definition: structs.h:108
struct NaMeNode NAMENODE
BRACKETINDEX * indexbuffer
Definition: structs.h:317
COMPTREE * boomlijst
Definition: structs.h:348
WORD IndDum
Definition: structs.h:2199
LONG CheckpointInterval
Definition: structs.h:1662
WORD * prototype
Definition: structs.h:343
LONG name
Definition: structs.h:466
SBYTE * tokens
Definition: structs.h:1627
LONG namesize
Definition: structs.h:260
int bounds
Definition: structs.h:359
char * CheckpointRunBefore
Definition: structs.h:1639
LONG oldnamefill
Definition: structs.h:262
SBYTE * endoftokens
Definition: structs.h:1629
struct DoLoOp DOLOOP
LONG oldnodefill
Definition: structs.h:263
#define EMPTYININDEX
Definition: structs.h:123
WORD spec
Definition: structs.h:471
UWORD * powmod
Definition: structs.h:1611
WORD * Buffer
Definition: structs.h:922
WORD * start
Definition: structs.h:166
LONG BufferSize
Definition: structs.h:932
Definition: structs.h:204
UBYTE * WildcardNames
Definition: structs.h:1625
struct bit_field * one_byte
Definition: structs.h:896
WORD * indnum
Definition: structs.h:186
struct StreaM STREAM
WORD * Top
Definition: structs.h:923
struct tree COMPTREE
struct DiStRiBuTe DISTRIBUTE
NAMETREE * varnames
Definition: structs.h:1570
int nargs
Definition: structs.h:783
struct NaMeTree NAMETREE
UBYTE * namebuffer
Definition: structs.h:255
LONG * IfStack
Definition: structs.h:1618
struct TrAcEs TRACES
UBYTE * pname
Definition: structs.h:683
LIST VectorList
Definition: structs.h:1581
WORD right
Definition: structs.h:238
PRELOAD p
Definition: structs.h:836
LIST SetList
Definition: structs.h:1579
LIST ExpressionList
Definition: structs.h:1576
WORD namesize
Definition: structs.h:474
LONG mdefined
Definition: structs.h:356
LIST ChannelList
Definition: structs.h:1571
WORD headnode
Definition: structs.h:269
VARRENUM func
Definition: structs.h:183
int rootnum
Definition: structs.h:363
UBYTE * value
Definition: structs.h:781
struct FuNcTiOn * FUNCTIONS
LONG * IfCount
Definition: structs.h:1617
struct bit_field set_of_char[32]
Definition: structs.h:890
struct FiLeInDeX FILEINDEX
UBYTE * argnames
Definition: structs.h:782
struct PeRmUtE PERM
WORD * flags
Definition: structs.h:347
WORD nfunctions
Definition: structs.h:107
LONG clearnodefill
Definition: structs.h:268
int handle
Definition: structs.h:648
int handle
Definition: structs.h:954
UBYTE ** LabelNames
Definition: structs.h:1622
VARRENUM symb
Definition: structs.h:180
LONG * CanCommu
Definition: structs.h:927
char * CheckpointRunAfter
Definition: structs.h:1637
struct TaBlEs * TABLES
WORD commute
Definition: structs.h:467
struct FixedGlobals FIXEDGLOBALS
int * Labels
Definition: structs.h:1626
UWORD * modpowers
Definition: structs.h:1612
WORD * funnum
Definition: structs.h:188
WORD * lo
Definition: structs.h:167
WORD gShortStatsMax
Definition: structs.h:1475