forked from vermaseren/form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeclare.h
1674 lines (1570 loc) · 64.1 KB
/
declare.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef __FDECLARE__
#define __FDECLARE__
/** @file declare.h
*
* Contains macros and function declarations.
*/
/* #[ License : */
/*
* Copyright (C) 1984-2022 J.A.M. Vermaseren
* When using this file you are requested to refer to the publication
* J.A.M.Vermaseren "New features of FORM" math-ph/0010025
* This is considered a matter of courtesy as the development was paid
* for by FOM the Dutch physics granting agency and we would like to
* be able to track its scientific use to convince FOM of its value
* for the community.
*
* This file is part of FORM.
*
* FORM is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* FORM is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along
* with FORM. If not, see <http://www.gnu.org/licenses/>.
*/
/* #] License : */
/*
#[ Macro's :
*/
#define MaX(x,y) ((x) > (y) ? (x): (y))
#define MiN(x,y) ((x) < (y) ? (x): (y))
#define ABS(x) ( (x) < 0 ? -(x): (x) )
#define SGN(x) ( (x) > 0 ? 1 : (x) < 0 ? -1 : 0 )
#define REDLENG(x) ((((x)<0)?((x)+1):((x)-1))/2)
#define INCLENG(x) (((x)<0)?(((x)*2)-1):(((x)*2)+1))
#define GETCOEF(x,y) x += *x;y = x[-1];x -= ABS(y);y=REDLENG(y)
#define GETSTOP(x,y) y=x+(*x)-1;y -= ABS(*y)-1
#define StuffAdd(x,y) (((x)<0?-1:1)*(y)+((y)<0?-1:1)*(x))
#define EXCHN(t1,t2,n) { WORD a,i; for(i=0;i<n;i++){a=t1[i];t1[i]=t2[i];t2[i]=a;} }
#define EXCH(x,y) { WORD a = (x); (x) = (y); (y) = a; }
#define TOKENTOLINE(x,y) if ( AC.OutputSpaces == NOSPACEFORMAT ) { \
TokenToLine((UBYTE *)(y)); } else { TokenToLine((UBYTE *)(x)); }
#define UngetFromStream(stream,c) ((stream)->nextchar[(stream)->isnextchar++]=c)
#ifdef WITHRETURN
#define AddLineFeed(s,n) { (s)[(n)++] = CARRIAGERETURN; (s)[(n)++] = LINEFEED; }
#else
#define AddLineFeed(s,n) { (s)[(n)++] = LINEFEED; }
#endif
#define TryRecover(x) Terminate(-1)
#define UngetChar(c) { pushbackchar = c; }
#define ParseNumber(x,s) {(x)=0;while(*(s)>='0'&&*(s)<='9')(x)=10*(x)+*(s)++ -'0';}
#define ParseSign(sgn,s) {(sgn)=0;while(*(s)=='-'||*(s)=='+'){\
if ( *(s)++ == '-' ) sgn ^= 1;}}
#define ParseSignedNumber(x,s) { int sgn; ParseSign(sgn,s)\
ParseNumber(x,s) if ( sgn ) x = -x; }
#define NCOPY(s,t,n) while ( --n >= 0 ) *s++ = *t++;
/*#define NCOPY(s,t,n) { memcpy(s,t,n*sizeof(WORD)); s+=n; t+=n; n = -1; }*/
#define NCOPYI(s,t,n) while ( --n >= 0 ) *s++ = *t++;
#define NCOPYB(s,t,n) while ( --n >= 0 ) *s++ = *t++;
#define NCOPYI32(s,t,n) while ( --n >= 0 ) *s++ = *t++;
#define WCOPY(s,t,n) { int nn=n; WORD *ss=(WORD *)s, *tt=(WORD *)t; while ( --nn >= 0 ) *ss++=*tt++; }
#define NeedNumber(x,s,err) { int sgn = 1; \
while ( *s == ' ' || *s == '\t' || *s == '-' || *s == '+' ) { \
if ( *s == '-' ) sgn = -sgn; s++; } \
if ( chartype[*s] != 1 ) goto err; \
ParseNumber(x,s) \
if ( sgn < 0 ) (x) = -(x); while ( *s == ' ' || *s == '\t' ) s++;\
}
#define SKIPBLANKS(s) { while ( *(s) == ' ' || *(s) == '\t' ) (s)++; }
#define FLUSHCONSOLE if ( AP.InOutBuf > 0 ) CharOut(LINEFEED)
#define SKIPBRA1(s) { int lev1=0; s++; while(*s) { if(*s=='[')lev1++; \
else if(*s==']'&&--lev1<0)break; s++;} }
#define SKIPBRA2(s) { int lev2=0; s++; while(*s) { if(*s=='{')lev2++; \
else if(*s=='}'&&--lev2<0)break; \
else if(*s=='[')SKIPBRA1(s) s++;} }
#define SKIPBRA3(s) { int lev3=0; s++; while(*s) { if(*s=='(')lev3++; \
else if(*s==')'&&--lev3<0)break; \
else if(*s=='{')SKIPBRA2(s) \
else if(*s=='[')SKIPBRA1(s) s++;} }
#define SKIPBRA4(s) { int lev4=0; s++; while(*s) { if(*s=='(')lev4++; \
else if(*s==')'&&--lev4<0)break; \
else if(*s=='[')SKIPBRA1(s) s++;} }
#define SKIPBRA5(s) { int lev5=0; s++; while(*s) { if(*s=='{')lev5++; \
else if(*s=='}'&&--lev5<0)break; \
else if(*s=='(')SKIPBRA4(s) \
else if(*s=='[')SKIPBRA1(s) s++;} }
/*
#define CYCLE1(a,i) {WORD iX,jX; iX=*a; for(jX=1;jX<i;jX++)a[jX-1]=a[jX]; a[i-1]=iX;}
*/
#define CYCLE1(t,a,i) {t iX=*a; WORD jX; for(jX=1;jX<i;jX++)a[jX-1]=a[jX]; a[i-1]=iX;}
#define AddToCB(c,wx) if(c->Pointer>=c->Top) \
DoubleCbuffer(c-cbuf,c->Pointer,21); \
*(c->Pointer)++ = wx;
#define EXCHINOUT { FILEHANDLE *ffFi = AR.outfile; \
AR.outfile = AR.infile; AR.infile = ffFi; }
#define BACKINOUT { FILEHANDLE *ffFi = AR.outfile; POSITION posi; \
AR.outfile = AR.infile; AR.infile = ffFi; \
SetEndScratch(AR.infile,&posi); }
#define CopyArg(to,from) { if ( *from > 0 ) { int ica = *from; NCOPY(to,from,ica) } \
else if ( *from <= -FUNCTION ) *to++ = *from++; \
else { *to++ = *from++; *to++ = *from++; } }
#if ARGHEAD > 2
#define FILLARG(w) { int i = ARGHEAD-2; while ( --i >= 0 ) *w++ = 0; }
#define COPYARG(w,t) { int i = ARGHEAD-2; while ( --i >= 0 ) *w++ = *t++; }
#define ZEROARG(w) { int i; for ( i = 2; i < ARGHEAD; i++ ) w[i] = 0; }
#else
#define FILLARG(w)
#define COPYARG(w,t)
#define ZEROARG(w)
#endif
#if FUNHEAD > 2
#define FILLFUN(w) { *w++ = 0; FILLFUN3(w) }
#define COPYFUN(w,t) { *w++ = *t++; COPYFUN3(w,t) }
#else
#define FILLFUN(w)
#define COPYFUN(w,t)
#endif
#if FUNHEAD > 3
#define FILLFUN3(w) { int ie = FUNHEAD-3; while ( --ie >= 0 ) *w++ = 0; }
#define COPYFUN3(w,t) { int ie = FUNHEAD-3; while ( --ie >= 0 ) *w++ = *t++; }
#else
#define COPYFUN3(w,t)
#define FILLFUN3(w)
#endif
#if SUBEXPSIZE > 5
#define FILLSUB(w) { int ie = SUBEXPSIZE-5; while ( --ie >= 0 ) *w++ = 0; }
#define COPYSUB(w,ww) { int ie = SUBEXPSIZE-5; while ( --ie >= 0 ) *w++ = *ww++; }
#else
#define FILLSUB(w)
#define COPYSUB(w,ww)
#endif
#if EXPRHEAD > 4
#define FILLEXPR(w) { int ie = EXPRHEAD-4; while ( --ie >= 0 ) *w++ = 0; }
#else
#define FILLEXPR(w)
#endif
#define NEXTARG(x) if(*x>0) x += *x; else if(*x <= -FUNCTION)x++; else x += 2;
#define COPY1ARG(s1,t1) { int ica; if ( (ica=*t1) > 0 ) { NCOPY(s1,t1,ica) } \
else if(*t1<=-FUNCTION){*s1++=*t1++;} else{*s1++=*t1++;*s1++=*t1++;} }
/**
* Fills a buffer by zero in the range [begin,end).
*
* @param w The buffer.
* @param begin The index for the beginning of the range.
* @param end The index for the end of the range (exclusive).
*/
#define ZeroFillRange(w,begin,end) do { \
int tmp_i; \
for ( tmp_i = begin; tmp_i < end; tmp_i++ ) { (w)[tmp_i] = 0; } \
} while (0)
#define TABLESIZE(a,b) (((WORD)sizeof(a))/((WORD)sizeof(b)))
#define WORDDIF(x,y) (WORD)(x-y)
#define wsizeof(a) ((WORD)sizeof(a))
#define VARNAME(type,num) (AC.varnames->namebuffer+type[num].name)
#define DOLLARNAME(type,num) (AC.dollarnames->namebuffer+type[num].name)
#define EXPRNAME(num) (AC.exprnames->namebuffer+Expressions[num].name)
#define PREV(x) prevorder?prevorder:x
#define SETERROR(x) { Terminate(-1); return(-1); }
/* use this macro to avoid the unused parameter warning */
#define DUMMYUSE(x) (void)(x);
#ifdef _FILE_OFFSET_BITS
#if _FILE_OFFSET_BITS==64
/*:[19mar2004 mt]*/
#define ADDPOS(pp,x) (pp).p1 = ((pp).p1+(off_t)(x))
#define SETBASELENGTH(ss,x) (ss).p1 = (off_t)(x)
#define SETBASEPOSITION(pp,x) (pp).p1 = (off_t)(x)
#define ISEQUALPOSINC(pp1,pp2,x) ( (pp1).p1 == ((pp2).p1+(off_t)(x)) )
#define ISGEPOSINC(pp1,pp2,x) ( (pp1).p1 >= ((pp2).p1+(off_t)(x)) )
#define DIVPOS(pp,n) ( (pp).p1/(off_t)(n) )
#define MULPOS(pp,n) (pp).p1 *= (off_t)(n)
#else
#define ADDPOS(pp,x) (pp).p1 = ((pp).p1+(x))
#define SETBASELENGTH(ss,x) (ss).p1 = (x)
#define SETBASEPOSITION(pp,x) (pp).p1 = (x)
#define ISEQUALPOSINC(pp1,pp2,x) ( (pp1).p1 == ((pp2).p1+(LONG)(x)) )
#define ISGEPOSINC(pp1,pp2,x) ( (pp1).p1 >= ((pp2).p1+(LONG)(x)) )
#define DIVPOS(pp,n) ( (pp).p1/(n) )
#define MULPOS(pp,n) (pp).p1 *= (n)
#endif
#else
#define ADDPOS(pp,x) (pp).p1 = ((pp).p1+(LONG)(x))
#define SETBASELENGTH(ss,x) (ss).p1 = (LONG)(x)
#define SETBASEPOSITION(pp,x) (pp).p1 = (LONG)(x)
#define ISEQUALPOSINC(pp1,pp2,x) ( (pp1).p1 == ((pp2).p1+(LONG)(x)) )
#define ISGEPOSINC(pp1,pp2,x) ( (pp1).p1 >= ((pp2).p1+(LONG)(x)) )
#define DIVPOS(pp,n) ( (pp).p1/(LONG)(n) )
#define MULPOS(pp,n) (pp).p1 *= (LONG)(n)
#endif
#define DIFPOS(ss,pp1,pp2) (ss).p1 = ((pp1).p1-(pp2).p1)
#define DIFBASE(pp1,pp2) ((pp1).p1-(pp2).p1)
#define ADD2POS(pp1,pp2) (pp1).p1 += (pp2).p1
#define PUTZERO(pp) (pp).p1 = 0
#define BASEPOSITION(pp) ((pp).p1)
#define SETSTARTPOS(pp) (pp).p1 = -2
#define NOTSTARTPOS(pp) ( (pp).p1 > -2 )
#define ISMINPOS(pp) ( (pp).p1 == -1 )
#define ISEQUALPOS(pp1,pp2) ( (pp1).p1 == (pp2).p1 )
#define ISNOTEQUALPOS(pp1,pp2) ( (pp1).p1 != (pp2).p1 )
#define ISLESSPOS(pp1,pp2) ( (pp1).p1 < (pp2).p1 )
#define ISGEPOS(pp1,pp2) ( (pp1).p1 >= (pp2).p1 )
#define ISNOTZEROPOS(pp) ( (pp).p1 != 0 )
#define ISZEROPOS(pp) ( (pp).p1 == 0 )
#define ISPOSPOS(pp) ( (pp).p1 > 0 )
#define ISNEGPOS(pp) ( (pp).p1 < 0 )
extern VOID TELLFILE(int,POSITION *);
#define TOLONG(x) ((LONG)(x))
#define Add2Com(x) { WORD cod[2]; cod[0] = x; cod[1] = 2; AddNtoL(2,cod); }
#define Add3Com(x1,x2) { WORD cod[3]; cod[0] = x1; cod[1] = 3; cod[2] = x2; AddNtoL(3,cod); }
#define Add4Com(x1,x2,x3) { WORD cod[4]; cod[0] = x1; cod[1] = 4; \
cod[2] = x2; cod[3] = x3; AddNtoL(4,cod); }
#define Add5Com(x1,x2,x3,x4) { WORD cod[5]; cod[0] = x1; cod[1] = 5; \
cod[2] = x2; cod[3] = x3; cod[4] = x4; AddNtoL(5,cod); }
/*
The temporary variable ppp is to avoid a compiler warning about strict aliassing
*/
#define WantAddPointers(x) while((AT.pWorkPointer+(x))>AR.pWorkSize){WORD ***ppp=&AT.pWorkSpace;\
ExpandBuffer((void **)ppp,&AR.pWorkSize,(int)(sizeof(WORD *)));}
#define WantAddLongs(x) while((AT.lWorkPointer+(x))>AR.lWorkSize){LONG **ppp=&AT.lWorkSpace;\
ExpandBuffer((void **)ppp,&AR.lWorkSize,sizeof(LONG));}
#define WantAddPositions(x) while((AT.posWorkPointer+(x))>AR.posWorkSize){POSITION **ppp=&AT.posWorkSpace;\
ExpandBuffer((void **)ppp,&AR.posWorkSize,sizeof(POSITION));}
/* inline in form3.h (or config.h). */
#define FORM_INLINE inline
/*
Macro's for memory management. This can be done by routines, but that
would be slower. Inline routines could do this, but we don't want to
leave this to the friendliness of the compiler(s).
The routines can be found in the file tools.c
*/
#define MEMORYMACROS
#ifdef MEMORYMACROS
#define TermMalloc(x) ( (AT.TermMemTop <= 0 ) ? TermMallocAddMemory(BHEAD0), AT.TermMemHeap[--AT.TermMemTop]: AT.TermMemHeap[--AT.TermMemTop] )
#define NumberMalloc(x) ( (AT.NumberMemTop <= 0 ) ? NumberMallocAddMemory(BHEAD0), AT.NumberMemHeap[--AT.NumberMemTop]: AT.NumberMemHeap[--AT.NumberMemTop] )
#define CacheNumberMalloc(x) ( (AT.CacheNumberMemTop <= 0 ) ? CacheNumberMallocAddMemory(BHEAD0), AT.CacheNumberMemHeap[--AT.CacheNumberMemTop]: AT.CacheNumberMemHeap[--AT.CacheNumberMemTop] )
#define TermFree(TermMem,x) AT.TermMemHeap[AT.TermMemTop++] = (WORD *)(TermMem)
#define NumberFree(NumberMem,x) AT.NumberMemHeap[AT.NumberMemTop++] = (UWORD *)(NumberMem)
#define CacheNumberFree(NumberMem,x) AT.CacheNumberMemHeap[AT.CacheNumberMemTop++] = (UWORD *)(NumberMem)
#else
#define TermMalloc(x) TermMalloc2(BHEAD (char *)(x))
#define NumberMalloc(x) NumberMalloc2(BHEAD (char *)(x))
#define CacheNumberMalloc(x) CacheNumberMalloc2(BHEAD (char *)(x))
#define TermFree(x,y) TermFree2(BHEAD (WORD *)(x),(char *)(y))
#define NumberFree(x,y) NumberFree2(BHEAD (UWORD *)(x),(char *)(y))
#define CacheNumberFree(x,y) CacheNumberFree2(BHEAD (UWORD *)(x),(char *)(y))
#endif
/*
* Macros for checking nesting levels in the compiler, used as follows:
*
* AC.IfSumCheck[AC.IfLevel] = NestingChecksum();
* AC.IfLevel++;
*
* AC.IfLevel--;
* if ( AC.IfSumCheck[AC.IfLevel] != NestingChecksum() ) {
* MesNesting();
* }
*
* Note that NestingChecksum() also contains AC.IfLevel and so in this case
* using increment/decrement operators on it in the left-hand side may be
* confusing.
*/
#define NestingChecksum() (AC.IfLevel + AC.RepLevel + AC.arglevel + AC.insidelevel + AC.termlevel + AC.inexprlevel + AC.dolooplevel +AC.SwitchLevel)
#define MesNesting() MesPrint("&Illegal nesting of if, repeat, argument, inside, term, inexpression and do")
#define MarkPolyRatFunDirty(T) {if(*T&&AR.PolyFunType==2){WORD *TP,*TT;TT=T+*T;TT-=ABS(TT[-1]);\
TP=T+1;while(TP<TT){if(*TP==AR.PolyFun){TP[2]|=(DIRTYFLAG|MUSTCLEANPRF);}TP+=TP[1];}}}
/*
Macros for nesting input levels for #$name = ...; assign instructions.
Note that the level should never go below zero.
*/
#define PUSHPREASSIGNLEVEL AP.PreAssignLevel++; { GETIDENTITY \
if ( AP.PreAssignLevel >= AP.MaxPreAssignLevel ) { int i; \
LONG *ap = (LONG *)Malloc1(2*AP.MaxPreAssignLevel*sizeof(LONG *),"PreAssignStack"); \
for ( i = 0; i < AP.MaxPreAssignLevel; i++ ) ap[i] = AP.PreAssignStack[i]; \
M_free(AP.PreAssignStack,"PreAssignStack"); \
AP.MaxPreAssignLevel *= 2; AP.PreAssignStack = ap; \
} \
*AT.WorkPointer++ = AP.PreContinuation; AP.PreContinuation = 0; \
AP.PreAssignStack[AP.PreAssignLevel] = AC.iPointer - AC.iBuffer; }
#define POPPREASSIGNLEVEL if ( AP.PreAssignLevel > 0 ) { GETIDENTITY \
AC.iPointer = AC.iBuffer + AP.PreAssignStack[AP.PreAssignLevel--]; \
AP.PreContinuation = *--AT.WorkPointer; \
*AC.iPointer = 0; }
/*
MesPrint("P-level popped to %d with %d",AP.PreAssignLevel,(WORD)(AC.iPointer - AC.iBuffer));
#] Macro's :
#[ Inline functions :
*/
/*
* The following three functions give the unsigned absolute value of a signed
* integer even for the most negative integer. This is beyond the scope of
* the standard abs() function and its family, whose return-values are signed.
* In short, we should not use the unary minus operator with signed numbers
* unless we are sure that there are no integer overflows. Instead, we rely on
* two well-defined operations: (i) signed-to-unsigned conversion and
* (ii) unary minus of unsigned operands.
*
* See also:
* https://stackoverflow.com/a/4536188 (Unary minus and signed-to-unsigned conversion)
* https://stackoverflow.com/q/8026694 (C: unary minus operator behavior with unsigned operands)
* https://stackoverflow.com/q/1610947 (Why does stdlib.h's abs() family of functions return a signed value?)
* https://blog.regehr.org/archives/226 (A Guide to Undefined Behavior in C and C++, Part 2)
*/
static inline unsigned int IntAbs(int x)
{
if ( x >= 0 ) return x;
return(-((unsigned int)x));
}
static inline UWORD WordAbs(WORD x)
{
if ( x >= 0 ) return x;
return(-((UWORD)x));
}
static inline ULONG LongAbs(LONG x)
{
if ( x >= 0 ) return x;
return(-((ULONG)x));
}
/*
* The following functions provide portable unsigned-to-signed conversions
* (to avoid the implementation-defined behaviour), which is expected to be
* optimized to a no-op.
*
* See also:
* https://stackoverflow.com/a/13208789 (Efficient unsigned-to-signed cast avoiding implementation-defined behavior)
*/
static inline int UnsignedToInt(unsigned int x)
{
extern void Terminate(int);
if ( x <= INT_MAX ) return(x);
if ( x >= (unsigned int)INT_MIN ) return((int)(x - INT_MIN) + INT_MIN);
Terminate(1);
return(0);
}
static inline WORD UWordToWord(UWORD x)
{
extern void Terminate(int);
if ( x <= WORD_MAX_VALUE ) return(x);
if ( x >= (UWORD)WORD_MIN_VALUE ) return((WORD)(x - WORD_MIN_VALUE) + WORD_MIN_VALUE);
Terminate(1);
return(0);
}
static inline LONG ULongToLong(ULONG x)
{
extern void Terminate(int);
if ( x <= LONG_MAX_VALUE ) return(x);
if ( x >= (ULONG)LONG_MIN_VALUE ) return((LONG)(x - LONG_MIN_VALUE) + LONG_MIN_VALUE);
Terminate(1);
return(0);
}
/*
#] Inline functions :
#[ Thread objects :
*/
/**
* NOTE: We have replaced LOCK(ErrorMessageLock) and UNLOCK(ErrorMessageLock)
* by MLOCK(ErrorMessageLock) and MUNLOCK(ErrorMessageLock). They are used
* for the synchronised output in ParFORM.
* (TU 28 May 2011)
*/
#ifdef WITHPTHREADS
#define EXTERNLOCK(x) extern pthread_mutex_t x;
#define INILOCK(x) pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER;
#define EXTERNRWLOCK(x) extern pthread_rwlock_t x;
#define INIRWLOCK(x) pthread_rwlock_t x = PTHREAD_RWLOCK_INITIALIZER;
#ifdef DEBUGGINGLOCKS
#include <asm/errno.h>
#define LOCK(x) while ( pthread_mutex_trylock(&(x)) == EBUSY ) {}
#define RWLOCKR(x) while ( pthread_rwlock_tryrdlock(&(x)) == EBUSY ) {}
#define RWLOCKW(x) while ( pthread_rwlock_trywrlock(&(x)) == EBUSY ) {}
#else
#define LOCK(x) pthread_mutex_lock(&(x))
#define RWLOCKR(x) pthread_rwlock_rdlock(&(x))
#define RWLOCKW(x) pthread_rwlock_wrlock(&(x))
#endif
#define UNLOCK(x) pthread_mutex_unlock(&(x))
#define UNRWLOCK(x) pthread_rwlock_unlock(&(x))
#define MLOCK(x) LOCK(x)
#define MUNLOCK(x) UNLOCK(x)
#define GETBIDENTITY
#define GETIDENTITY int identity = WhoAmI(); ALLPRIVATES *B = AB[identity];
#else
#define EXTERNLOCK(x)
#define INILOCK(x)
#define LOCK(x)
#define UNLOCK(x)
#define EXTERNRWLOCK(x)
#define INIRWLOCK(x)
#define RWLOCKR(x)
#define RWLOCKW(x)
#define UNRWLOCK(x)
#ifdef WITHMPI
#define MLOCK(x) do { if ( PF.me != MASTER ) PF_MLock(); } while (0)
#define MUNLOCK(x) do { if ( PF.me != MASTER ) PF_MUnlock(); } while (0)
#else
#define MLOCK(x)
#define MUNLOCK(x)
#endif
#define GETIDENTITY
#define GETBIDENTITY
#endif
/*
#] Thread objects :
#[ Declarations :
*/
#ifdef TERMMALLOCDEBUG
extern WORD **DebugHeap1, **DebugHeap2;
#endif
/**
* All functions (well, nearly all) are declared here.
*/
extern VOID StartVariables();
extern VOID setSignalHandlers(VOID);
extern UBYTE *CodeToLine(WORD,UBYTE *);
extern UBYTE *AddArrayIndex(WORD ,UBYTE *);
extern INDEXENTRY *FindInIndex(WORD,FILEDATA *,WORD,WORD);
extern INDEXENTRY *NextFileIndex(POSITION *);
extern WORD *PasteTerm(PHEAD WORD,WORD *,WORD *,WORD,WORD);
extern UBYTE *StrCopy(UBYTE *,UBYTE *);
extern UBYTE *WrtPower(UBYTE *,WORD);
extern WORD AccumGCD(PHEAD UWORD *,WORD *,UWORD *,WORD);
extern VOID AddArgs(PHEAD WORD *,WORD *,WORD *);
extern WORD AddCoef(PHEAD WORD **,WORD **);
extern WORD AddLong(UWORD *,WORD,UWORD *,WORD,UWORD *,WORD *);
extern WORD AddPLon(UWORD *,WORD,UWORD *,WORD,UWORD *,WORD *);
extern WORD AddPoly(PHEAD WORD **,WORD **);
extern WORD AddRat(PHEAD UWORD *,WORD,UWORD *,WORD,UWORD *,WORD *);
extern VOID AddToLine(UBYTE *);
extern WORD AddWild(PHEAD WORD,WORD,WORD);
extern WORD BigLong(UWORD *,WORD,UWORD *,WORD);
extern WORD BinomGen(PHEAD WORD *,WORD,WORD **,WORD,WORD,WORD,WORD,WORD,UWORD *,WORD);
extern WORD CheckWild(PHEAD WORD,WORD,WORD,WORD *);
extern WORD Chisholm(PHEAD WORD *,WORD);
extern WORD CleanExpr(WORD);
extern VOID CleanUp(WORD);
extern VOID ClearWild(PHEAD0);
extern WORD CompareFunctions(WORD *,WORD *);
extern WORD Commute(WORD *,WORD *);
extern WORD DetCommu(WORD *);
extern WORD DoesCommu(WORD *);
extern int CompArg(WORD *,WORD *);
extern WORD CompCoef(WORD *, WORD *);
extern WORD CompGroup(PHEAD WORD,WORD **,WORD *,WORD *,WORD);
extern WORD Compare1(WORD *,WORD *,WORD);
extern WORD CountDo(WORD *,WORD *);
extern WORD CountFun(WORD *,WORD *);
extern WORD DimensionSubterm(WORD *);
extern WORD DimensionTerm(WORD *);
extern WORD DimensionExpression(PHEAD WORD *);
extern WORD Deferred(PHEAD WORD *,WORD);
extern WORD DeleteStore(WORD);
extern WORD DetCurDum(PHEAD WORD *);
extern VOID DetVars(WORD *,WORD);
extern WORD Distribute(DISTRIBUTE *,WORD);
extern WORD DivLong(UWORD *,WORD,UWORD *,WORD,UWORD *,WORD *,UWORD *,WORD *);
extern WORD DivRat(PHEAD UWORD *,WORD,UWORD *,WORD,UWORD *,WORD *);
extern WORD Divvy(PHEAD UWORD *,WORD *,UWORD *,WORD);
extern WORD DoDelta(WORD *);
extern WORD DoDelta3(PHEAD WORD *,WORD);
extern WORD TestPartitions(WORD *, PARTI *);
extern WORD DoPartitions(PHEAD WORD *,WORD);
extern int CoCanonicalize(UBYTE *);
extern int DoCanonicalize(PHEAD WORD *, WORD *);
extern WORD GenTopologies(PHEAD WORD *,WORD);
extern WORD GenDiagrams(PHEAD WORD *,WORD);
extern int DoTopologyCanonicalize(PHEAD WORD *,WORD,WORD,WORD *);
extern int DoShattering(PHEAD WORD *,WORD *,WORD *,WORD);
extern WORD GenerateTopologies(PHEAD WORD,WORD,WORD,WORD);
extern WORD DoTableExpansion(WORD *,WORD);
extern WORD DoDistrib(PHEAD WORD *,WORD);
extern WORD DoShuffle(WORD *,WORD,WORD,WORD);
extern WORD DoPermutations(PHEAD WORD *,WORD);
extern int Shuffle(WORD *, WORD *, WORD *);
extern int FinishShuffle(WORD *);
extern WORD DoStuffle(WORD *,WORD,WORD,WORD);
extern int Stuffle(WORD *, WORD *, WORD *);
extern int FinishStuffle(WORD *);
extern WORD *StuffRootAdd(WORD *, WORD *, WORD *);
extern WORD TestUse(WORD *,WORD);
extern DBASE *FindTB(UBYTE *);
extern int CheckTableDeclarations(DBASE *);
extern WORD Apply(WORD *,WORD);
extern int ApplyExec(WORD *,int,WORD);
extern WORD ApplyReset(WORD);
extern WORD TableReset(VOID);
extern VOID ReWorkT(WORD *,WORD *,WORD);
extern WORD GetIfDollarNum(WORD *, WORD *);
extern int FindVar(WORD *,WORD *);
extern WORD DoIfStatement(PHEAD WORD *,WORD *);
extern WORD DoOnePow(PHEAD WORD *,WORD,WORD,WORD *,WORD *,WORD,WORD *);
extern void DoRevert(WORD *,WORD *);
extern WORD DoSumF1(PHEAD WORD *,WORD *,WORD,WORD);
extern WORD DoSumF2(PHEAD WORD *,WORD *,WORD,WORD);
extern WORD DoTheta(PHEAD WORD *);
extern LONG EndSort(PHEAD WORD *,int);
extern WORD EntVar(WORD,UBYTE *,WORD,WORD,WORD,WORD);
extern WORD EpfCon(PHEAD WORD *,WORD *,WORD,WORD);
extern WORD EpfFind(PHEAD WORD *,WORD *);
extern WORD EpfGen(WORD,WORD *,WORD *,WORD *,WORD);
extern WORD EqualArg(WORD *,WORD,WORD);
extern WORD Evaluate(UBYTE **);
extern int Factorial(PHEAD WORD,UWORD *,WORD *);
extern int Bernoulli(WORD,UWORD *,WORD *);
extern int FactorIn(PHEAD WORD *,WORD);
extern int FactorInExpr(PHEAD WORD *,WORD);
extern WORD FindAll(PHEAD WORD *,WORD *,WORD,WORD *);
extern WORD FindMulti(PHEAD WORD *,WORD *);
extern WORD FindOnce(PHEAD WORD *,WORD *);
extern WORD FindOnly(PHEAD WORD *,WORD *);
extern WORD FindRest(PHEAD WORD *,WORD *);
extern WORD FindSpecial(WORD *);
extern WORD FindrNumber(WORD,VARRENUM *);
extern VOID FiniLine(VOID);
extern WORD FiniTerm(PHEAD WORD *,WORD *,WORD *,WORD,WORD);
extern WORD FlushOut(POSITION *,FILEHANDLE *,int);
extern VOID FunLevel(PHEAD WORD *);
extern VOID AdjustRenumScratch(PHEAD0);
extern VOID GarbHand(VOID);
extern WORD GcdLong(PHEAD UWORD *,WORD,UWORD *,WORD,UWORD *,WORD *);
extern WORD LcmLong(PHEAD UWORD *,WORD,UWORD *,WORD,UWORD *,WORD *);
extern VOID GCD(UWORD *,WORD,UWORD *,WORD,UWORD *,WORD *);
extern ULONG GCD2(ULONG,ULONG);
extern WORD Generator(PHEAD WORD *,WORD);
extern WORD GetBinom(UWORD *,WORD *,WORD,WORD);
extern WORD GetFromStore(WORD *,POSITION *,RENUMBER,WORD *,WORD);
extern WORD GetLong(UBYTE *,UWORD *,WORD *);
extern WORD GetMoreTerms(WORD *);
extern WORD GetMoreFromMem(WORD *,WORD **);
extern WORD GetOneTerm(PHEAD WORD *,FILEHANDLE *,POSITION *,int);
extern RENUMBER GetTable(WORD,POSITION *,WORD);
extern WORD GetTerm(PHEAD WORD *);
extern WORD Glue(PHEAD WORD *,WORD *,WORD *,WORD);
extern WORD InFunction(PHEAD WORD *,WORD *);
extern VOID IniLine(WORD);
extern WORD IniVars(VOID);
extern VOID Initialize(VOID);
extern WORD InsertTerm(PHEAD WORD *,WORD,WORD,WORD *,WORD *,WORD);
extern VOID LongToLine(UWORD *,WORD);
extern WORD MakeDirty(WORD *,WORD *,WORD);
extern VOID MarkDirty(WORD *,WORD);
extern VOID PolyFunDirty(PHEAD WORD *);
extern VOID PolyFunClean(PHEAD WORD *);
extern WORD MakeModTable(VOID);
extern WORD MatchE(PHEAD WORD *,WORD *,WORD *,WORD);
extern int MatchCy(PHEAD WORD *,WORD *,WORD *,WORD);
extern int FunMatchCy(PHEAD WORD *,WORD *,WORD *,WORD);
extern int FunMatchSy(PHEAD WORD *,WORD *,WORD *,WORD);
extern int MatchArgument(PHEAD WORD *,WORD *);
extern WORD MatchFunction(PHEAD WORD *,WORD *,WORD *);
extern WORD MergePatches(WORD);
extern WORD MesCerr(char *, UBYTE *);
extern WORD MesComp(char *, UBYTE *, UBYTE *);
extern WORD Modulus(WORD *);
extern VOID MoveDummies(PHEAD WORD *,WORD);
extern WORD MulLong(UWORD *,WORD,UWORD *,WORD,UWORD *,WORD *);
extern WORD MulRat(PHEAD UWORD *,WORD,UWORD *,WORD,UWORD *,WORD *);
extern WORD Mully(PHEAD UWORD *,WORD *,UWORD *,WORD);
extern WORD MultDo(PHEAD WORD *,WORD *);
extern WORD NewSort(PHEAD0);
extern WORD ExtraSymbol(WORD,WORD,WORD,WORD *,WORD *);
extern WORD Normalize(PHEAD WORD *);
extern WORD BracketNormalize(PHEAD WORD *);
extern VOID DropCoefficient(PHEAD WORD *);
extern VOID DropSymbols(PHEAD WORD *);
extern int PutInside(PHEAD WORD *, WORD *);
extern WORD OpenTemp(VOID);
extern VOID Pack(UWORD *,WORD *,UWORD *,WORD );
extern LONG PasteFile(PHEAD WORD,WORD *,POSITION *,WORD **,RENUMBER,WORD *,WORD);
extern WORD Permute(PERM *,WORD);
extern WORD PermuteP(PERMP *,WORD);
extern WORD PolyFunMul(PHEAD WORD *);
extern WORD PopVariables(VOID);
extern WORD PrepPoly(PHEAD WORD *,WORD);
extern WORD Processor(VOID);
extern WORD Product(UWORD *,WORD *,WORD);
extern VOID PrtLong(UWORD *,WORD,UBYTE *);
extern VOID PrtTerms(VOID);
extern VOID PrintRunningTime(VOID);
extern LONG GetRunningTime(VOID);
extern WORD PutBracket(PHEAD WORD *);
extern LONG PutIn(FILEHANDLE *,POSITION *,WORD *,WORD **,int);
extern WORD PutInStore(INDEXENTRY *,WORD);
extern WORD PutOut(PHEAD WORD *,POSITION *,FILEHANDLE *,WORD);
extern UWORD Quotient(UWORD *,WORD *,WORD);
extern WORD RaisPow(PHEAD UWORD *,WORD *,UWORD);
extern VOID RaisPowCached (PHEAD WORD, WORD, UWORD **, WORD *);
extern WORD RaisPowMod (WORD, WORD, WORD);
extern int NormalModulus(UWORD *,WORD *);
extern int MakeInverses(VOID);
extern int GetModInverses(WORD,WORD,WORD *,WORD *);
extern int GetLongModInverses(PHEAD UWORD *, WORD, UWORD *, WORD, UWORD *, WORD *, UWORD *, WORD *);
extern VOID RatToLine(UWORD *,WORD);
extern WORD RatioFind(PHEAD WORD *,WORD *);
extern WORD RatioGen(PHEAD WORD *,WORD *,WORD,WORD);
extern WORD ReNumber(PHEAD WORD *);
extern WORD ReadSnum(UBYTE **);
extern WORD Remain10(UWORD *,WORD *);
extern WORD Remain4(UWORD *,WORD *);
extern WORD ResetScratch(VOID);
extern WORD ResolveSet(PHEAD WORD *,WORD *,WORD *);
extern WORD RevertScratch(VOID);
extern WORD ScanFunctions(PHEAD WORD *,WORD *,WORD);
extern VOID SeekScratch(FILEHANDLE *,POSITION *);
extern VOID SetEndScratch(FILEHANDLE *,POSITION *);
extern VOID SetEndHScratch(FILEHANDLE *,POSITION *);
extern WORD SetFileIndex(VOID);
extern WORD Sflush(FILEHANDLE *);
extern WORD Simplify(PHEAD UWORD *,WORD *,UWORD *,WORD *);
extern WORD SortWild(WORD *,WORD);
extern FILE *LocateBase(char **,char **);
extern LONG SplitMerge(PHEAD WORD **,LONG);
extern WORD StoreTerm(PHEAD WORD *);
extern VOID SubPLon(UWORD *,WORD,UWORD *,WORD,UWORD *,WORD *);
extern VOID Substitute(PHEAD WORD *,WORD *,WORD);
extern WORD SymFind(PHEAD WORD *,WORD *);
extern WORD SymGen(PHEAD WORD *,WORD *,WORD,WORD);
extern WORD Symmetrize(PHEAD WORD *,WORD *,WORD,WORD,WORD);
extern int FullSymmetrize(PHEAD WORD *,int);
extern WORD TakeModulus(UWORD *,WORD *,UWORD *,WORD,WORD);
extern WORD TakeNormalModulus(UWORD *,WORD *,UWORD *,WORD,WORD);
extern VOID TalToLine(UWORD);
extern WORD TenVec(PHEAD WORD *,WORD *,WORD,WORD);
extern WORD TenVecFind(PHEAD WORD *,WORD *);
extern WORD TermRenumber(WORD *,RENUMBER,WORD);
extern VOID TestDrop(VOID);
extern VOID PutInVflags(WORD);
extern WORD TestMatch(PHEAD WORD *,WORD *);
extern WORD TestSub(PHEAD WORD *,WORD);
extern LONG TimeCPU(WORD);
extern LONG TimeChildren(WORD);
extern LONG TimeWallClock(WORD);
extern LONG Timer(int);
extern int GetTimerInfo(LONG **,LONG **);
extern void WriteTimerInfo(LONG *,LONG *);
extern LONG GetWorkerTimes(VOID);
extern WORD ToStorage(EXPRESSIONS,POSITION *);
extern VOID TokenToLine(UBYTE *);
extern WORD Trace4(PHEAD WORD *,WORD *,WORD,WORD);
extern WORD Trace4Gen(PHEAD TRACES *,WORD);
extern WORD Trace4no(WORD,WORD *,TRACES *);
extern WORD TraceFind(PHEAD WORD *,WORD *);
extern WORD TraceN(PHEAD WORD *,WORD *,WORD,WORD);
extern WORD TraceNgen(PHEAD TRACES *,WORD);
extern WORD TraceNno(WORD,WORD *,TRACES *);
extern WORD Traces(PHEAD WORD *,WORD *,WORD,WORD);
extern WORD Trick(WORD *,TRACES *);
extern WORD TryDo(PHEAD WORD *,WORD *,WORD);
extern VOID UnPack(UWORD *,WORD,WORD *,WORD *);
extern WORD VarStore(UBYTE *,WORD,WORD,WORD);
extern WORD WildFill(PHEAD WORD *,WORD *,WORD *);
extern WORD WriteAll(VOID);
extern WORD WriteOne(UBYTE *,int,int,WORD);
extern VOID WriteArgument(WORD *);
extern WORD WriteExpression(WORD *,LONG);
extern WORD WriteInnerTerm(WORD *,WORD);
extern VOID WriteLists(VOID);
extern VOID WriteSetup(VOID);
extern VOID WriteStats(POSITION *,WORD);
extern WORD WriteSubTerm(WORD *,WORD);
extern WORD WriteTerm(WORD *,WORD *,WORD,WORD,WORD);
extern WORD execarg(PHEAD WORD *,WORD);
extern WORD execterm(PHEAD WORD *,WORD);
extern VOID SpecialCleanup(PHEAD0);
extern void SetMods();
extern void UnSetMods();
/*---------------------------------------------------------------------*/
extern WORD DoExecute(WORD,WORD);
extern VOID SetScratch(FILEHANDLE *,POSITION *);
extern VOID Warning(char *);
extern VOID HighWarning(char *);
extern int SpareTable(TABLES);
extern UBYTE *strDup1(UBYTE *,char *);
extern VOID *Malloc(LONG);
extern VOID *Malloc1(LONG,const char *);
extern int DoTail(int,UBYTE **);
extern int OpenInput(VOID);
extern int PutPreVar(UBYTE *,UBYTE *,UBYTE *,int);
extern VOID Error0(char *);
extern VOID Error1(char *,UBYTE *);
extern VOID Error2(char *,char *,UBYTE *);
extern UBYTE ReadFromStream(STREAM *);
extern UBYTE GetFromStream(STREAM *);
extern UBYTE LookInStream(STREAM *);
extern STREAM *OpenStream(UBYTE *,int,int,int);
extern int LocateFile(UBYTE **,int);
extern STREAM *CloseStream(STREAM *);
extern VOID PositionStream(STREAM *,LONG);
extern int ReverseStatements(STREAM *);
extern int ProcessOption(UBYTE *,UBYTE *,int);
extern int DoSetups(VOID);
extern VOID Terminate(int);
extern NAMENODE *GetNode(NAMETREE *,UBYTE *);
extern int AddName(NAMETREE *,UBYTE *,WORD,WORD,int *);
extern int GetName(NAMETREE *,UBYTE *,WORD *,int);
extern UBYTE *GetFunction(UBYTE *,WORD *);
extern UBYTE *GetNumber(UBYTE *,WORD *);
extern int GetLastExprName(UBYTE *,WORD *);
extern int GetAutoName(UBYTE *,WORD *);
extern int GetVar(UBYTE *,WORD *,WORD *,int,int);
extern int MakeDubious(NAMETREE *,UBYTE *,WORD *);
extern int GetOName(NAMETREE *,UBYTE *,WORD *,int);
extern VOID DumpTree(NAMETREE *);
extern VOID DumpNode(NAMETREE *,WORD,WORD);
extern VOID LinkTree(NAMETREE *,WORD,WORD);
extern VOID CopyTree(NAMETREE *,NAMETREE *,WORD,WORD);
extern int CompactifyTree(NAMETREE *,WORD);
extern NAMETREE *MakeNameTree(VOID);
extern VOID FreeNameTree(NAMETREE *);
extern int AddExpression(UBYTE *,int,int);
extern int AddSymbol(UBYTE *,int,int,int,int);
extern int AddDollar(UBYTE *,WORD,WORD *,LONG);
extern int ReplaceDollar(WORD,WORD,WORD *,LONG);
extern int DollarRaiseLow(UBYTE *,LONG);
extern int AddVector(UBYTE *,int,int);
extern int AddDubious(UBYTE *);
extern int AddIndex(UBYTE *,int,int);
extern UBYTE *DoDimension(UBYTE *,int *,int *);
extern int AddFunction(UBYTE *,int,int,int,int,int,int,int);
extern int CoCommuteInSet(UBYTE *);
extern int CoFunction(UBYTE *,int,int);
extern int TestName(UBYTE *);
extern int AddSet(UBYTE *,WORD);
extern int DoElements(UBYTE *,SETS,UBYTE *);
extern int DoTempSet(UBYTE *,UBYTE *);
extern int NameConflict(int,UBYTE *);
extern int OpenFile(char *);
extern int OpenAddFile(char *);
extern int ReOpenFile(char *);
extern int CreateFile(char *);
extern int CreateLogFile(char *);
extern VOID CloseFile(int);
extern int CopyFile(char *, char *);
extern int CreateHandle(VOID);
extern LONG ReadFile(int,UBYTE *,LONG);
extern LONG ReadPosFile(PHEAD FILEHANDLE *,UBYTE *,LONG,POSITION *);
extern LONG WriteFileToFile(int,UBYTE *,LONG);
extern VOID SeekFile(int,POSITION *,int);
extern LONG TellFile(int);
extern void FlushFile(int);
extern int GetPosFile(int,fpos_t *);
extern int SetPosFile(int,fpos_t *);
extern VOID SynchFile(int);
extern VOID TruncateFile(int);
extern int GetChannel(char *,int);
extern int GetAppendChannel(char *);
extern int CloseChannel(char *);
extern VOID inictable(VOID);
extern KEYWORD *findcommand(UBYTE *);
extern int inicbufs(VOID);
extern VOID StartFiles(VOID);
extern UBYTE *MakeDate(VOID);
extern VOID PreProcessor(VOID);
extern VOID *FromList(LIST *);
extern VOID *From0List(LIST *);
extern VOID *FromVarList(LIST *);
extern int DoubleList(VOID ***,int *,int,char *);
extern int DoubleLList(VOID ***,LONG *,int,char *);
extern void DoubleBuffer(void **,void **,int,char *);
extern void ExpandBuffer(void **,LONG *,int);
extern LONG iexp(LONG,int);
extern int IsLikeVector(WORD *);
extern int AreArgsEqual(WORD *,WORD *);
extern int CompareArgs(WORD *,WORD *);
extern UBYTE *SkipField(UBYTE *,int);
extern int StrCmp(UBYTE *,UBYTE *);
extern int StrICmp(UBYTE *,UBYTE *);
extern int StrHICmp(UBYTE *,UBYTE *);
extern int StrICont(UBYTE *,UBYTE *);
extern int CmpArray(WORD *,WORD *,WORD);
extern int ConWord(UBYTE *,UBYTE *);
extern int StrLen(UBYTE *);
extern UBYTE *GetPreVar(UBYTE *,int);
extern void ToGeneral(WORD *,WORD *,WORD);
extern WORD ToPolyFunGeneral(PHEAD WORD *);
extern int ToFast(WORD *,WORD *);
extern SETUPPARAMETERS *GetSetupPar(UBYTE *);
extern int RecalcSetups(VOID);
extern int AllocSetups(VOID);
extern SORTING *AllocSort(LONG,LONG,LONG,LONG,int,int,LONG);
extern VOID AllocSortFileName(SORTING *);
extern UBYTE *LoadInputFile(UBYTE *,int);
extern UBYTE GetInput(VOID);
extern VOID ClearPushback(VOID);
extern UBYTE GetChar(int);
extern VOID CharOut(UBYTE);
extern VOID UnsetAllowDelay(VOID);
extern VOID PopPreVars(int);
extern VOID IniModule(int);
extern VOID IniSpecialModule(int);
extern int ModuleInstruction(int *,int *);
extern int PreProInstruction(VOID);
extern int LoadInstruction(int);
extern int LoadStatement(int);
extern KEYWORD *FindKeyWord(UBYTE *,KEYWORD *,int);
extern KEYWORD *FindInKeyWord(UBYTE *,KEYWORD *,int);
extern int DoDefine(UBYTE *);
extern int DoRedefine(UBYTE *);
extern int TheDefine(UBYTE *,int);
extern int TheUndefine(UBYTE *);
extern int ClearMacro(UBYTE *);
extern int DoUndefine(UBYTE *);
extern int DoInclude(UBYTE *);
extern int DoReverseInclude(UBYTE *);
extern int Include(UBYTE *,int);
/*[14apr2004 mt]:*/
extern int DoExternal(UBYTE *);
extern int DoToExternal(UBYTE *);
extern int DoFromExternal(UBYTE *);
extern int DoPrompt(UBYTE *);
extern int DoSetExternal(UBYTE *);
/*[10may2006 mt]:*/
extern int DoSetExternalAttr(UBYTE *);
/*:[10may2006 mt]*/
extern int DoRmExternal(UBYTE *);
/*:[14apr2004 mt]*/
extern int DoFactDollar(UBYTE *);
extern WORD GetDollarNumber(UBYTE **,DOLLARS);
extern int DoSetRandom(UBYTE *);
extern int DoOptimize(UBYTE *);
extern int DoClearOptimize(UBYTE *);
extern int DoSkipExtraSymbols(UBYTE *);
extern int DoTimeOutAfter(UBYTE *);
extern int DoMessage(UBYTE *);
extern int DoPreOut(UBYTE *);
extern int DoPreAppend(UBYTE *);
extern int DoPreCreate(UBYTE *);
extern int DoPreAssign(UBYTE *);
extern int DoPreBreak(UBYTE *);
extern int DoPreDefault(UBYTE *);
extern int DoPreSwitch(UBYTE *);
extern int DoPreEndSwitch(UBYTE *);
extern int DoPreCase(UBYTE *);
extern int DoPreShow(UBYTE *);
extern int DoPreExchange(UBYTE *);
extern int DoSystem(UBYTE *);
extern int DoPipe(UBYTE *);
extern VOID StartPrepro(VOID);
extern int DoIfdef(UBYTE *,int);
extern int DoIfydef(UBYTE *);
extern int DoIfndef(UBYTE *);
extern int DoElse(UBYTE *);
extern int DoElseif(UBYTE *);
extern int DoEndif(UBYTE *);
extern int DoTerminate(UBYTE *);
extern int DoIf(UBYTE *);
extern int DoCall(UBYTE *);
extern int DoDebug(UBYTE *);
extern int DoDo(UBYTE *);
extern int DoBreakDo(UBYTE *);
extern int DoEnddo(UBYTE *);
extern int DoEndprocedure(UBYTE *);
extern int DoInside(UBYTE *);
extern int DoEndInside(UBYTE *);
extern int DoProcedure(UBYTE *);
extern int DoPrePrintTimes(UBYTE *);
extern int DoPreWrite(UBYTE *);
extern int DoPreClose(UBYTE *);
extern int DoPreRemove(UBYTE *);
extern int DoCommentChar(UBYTE *);
extern int DoPrcExtension(UBYTE *);
extern int DoPreReset(UBYTE *);
extern VOID WriteString(int,UBYTE *,int);
extern VOID WriteUnfinString(int,UBYTE *,int);
extern UBYTE *AddToString(UBYTE *,UBYTE *,int);
extern UBYTE *PreCalc(VOID);
extern UBYTE *PreEval(UBYTE *,LONG *);
extern VOID NumToStr(UBYTE *,LONG);
extern int PreCmp(int,int,UBYTE *,int,int,UBYTE *,int);
extern int PreEq(int,int,UBYTE *,int,int,UBYTE *,int);
extern UBYTE *pParseObject(UBYTE *,int *,LONG *);
extern UBYTE *PreIfEval(UBYTE *,int *);
extern int EvalPreIf(UBYTE *);
extern int PreLoad(PRELOAD *,UBYTE *,UBYTE *,int,char *);
extern int PreSkip(UBYTE *,UBYTE *,int);
extern UBYTE *EndOfToken(UBYTE *);
extern VOID SetSpecialMode(int,int);
extern VOID MakeGlobal(VOID);
extern int ExecModule(int);
extern int ExecStore(VOID);
extern VOID FullCleanUp(VOID);
extern int DoExecStatement(VOID);
extern int DoPipeStatement(VOID);
extern int DoPolyfun(UBYTE *);
extern int DoPolyratfun(UBYTE *);
extern int CompileStatement(UBYTE *);
extern UBYTE *ToToken(UBYTE *);
extern int GetDollar(UBYTE *);
extern int MesWork(VOID);
extern int MesPrint(const char *,...);
extern int MesCall(char *);
extern UBYTE *NumCopy(WORD,UBYTE *);
extern char *LongCopy(LONG,char *);
extern char *LongLongCopy(off_t *,char *);
extern VOID ReserveTempFiles(int);
extern VOID PrintTerm(WORD *,char *);
extern VOID PrintTermC(WORD *,char *);
extern VOID PrintSubTerm(WORD *,char *);
extern VOID PrintWords(WORD *,LONG);
extern void PrintSeq(WORD *,char *);
extern int ExpandTripleDots(int);
extern LONG ComPress(WORD **,LONG *);
extern VOID StageSort(FILEHANDLE *);
#define M_alloc(x) malloc((size_t)(x))
extern void M_free(VOID *,const char *);
extern void ClearWildcardNames(VOID);
extern int AddWildcardName(UBYTE *);
extern int GetWildcardName(UBYTE *);
extern void Globalize(int);
extern void ResetVariables(int);
extern void AddToPreTypes(int);
extern void MessPreNesting(int);
extern LONG GetStreamPosition(STREAM *);
extern WORD *DoubleCbuffer(int,WORD *,int);
extern WORD *AddLHS(int);
extern WORD *AddRHS(int,int);
extern int AddNtoL(int,WORD *);
extern int AddNtoC(int,int,WORD *,int);
extern VOID DoubleIfBuffers(VOID);
extern STREAM *CreateStream(UBYTE *);
extern int setonoff(UBYTE *,int *,int,int);
extern int DoPrint(UBYTE *,int);
extern int SetExpr(UBYTE *,int,int);
extern void AddToCom(int,WORD *);
extern int Add2ComStrings(int,WORD *,UBYTE *,UBYTE *);
extern int DoSymmetrize(UBYTE *,int);
extern int DoArgument(UBYTE *,int);
extern int ArgFactorize(PHEAD WORD *,WORD *);