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