@@ -46,15 +46,19 @@ extern "C" {
4646*F * * * * * * * * * * * * * module specific state * * * * * * * * * * * * *
4747*/
4848
49+ #ifdef HPCGAP
4950struct CollectorsState_ {
50- Obj SC_NW_STACK ;
51- Obj SC_LW_STACK ;
52- Obj SC_PW_STACK ;
53- Obj SC_EW_STACK ;
54- Obj SC_GE_STACK ;
55- Obj SC_CW_VECTOR ;
56- Obj SC_CW2_VECTOR ;
57- UInt SC_MAX_STACK_SIZE ;
51+ #endif
52+
53+ DECL_MODULE_STATE Obj SC_NW_STACK ;
54+ DECL_MODULE_STATE Obj SC_LW_STACK ;
55+ DECL_MODULE_STATE Obj SC_PW_STACK ;
56+ DECL_MODULE_STATE Obj SC_EW_STACK ;
57+ DECL_MODULE_STATE Obj SC_GE_STACK ;
58+ DECL_MODULE_STATE Obj SC_CW_VECTOR ;
59+ DECL_MODULE_STATE Obj SC_CW2_VECTOR ;
60+ DECL_MODULE_STATE UInt SC_MAX_STACK_SIZE ;
61+ #ifdef HPCGAP
5862};
5963
6064static ModuleStateOffset CollectorsStateOffset = -1 ;
@@ -64,6 +68,17 @@ extern inline struct CollectorsState_ * CollectorsState(void)
6468 return (struct CollectorsState_ *)StateSlotsAtOffset (CollectorsStateOffset);
6569}
6670
71+ #define SC_NW_STACK (CollectorsState()->SC_NW_STACK )
72+ #define SC_LW_STACK (CollectorsState()->SC_LW_STACK )
73+ #define SC_PW_STACK (CollectorsState()->SC_PW_STACK )
74+ #define SC_EW_STACK (CollectorsState()->SC_EW_STACK )
75+ #define SC_GE_STACK (CollectorsState()->SC_GE_STACK )
76+ #define SC_CW_VECTOR (CollectorsState()->SC_CW_VECTOR )
77+ #define SC_CW2_VECTOR (CollectorsState()->SC_CW2_VECTOR )
78+ #define SC_MAX_STACK_SIZE (CollectorsState()->SC_MAX_STACK_SIZE )
79+
80+ #endif
81+
6782
6883/* ***************************************************************************
6984**
@@ -84,7 +99,7 @@ extern inline struct CollectorsState_ * CollectorsState(void)
8499*/
85100#define SC_PUSH_WORD ( word, exp ) \
86101 if ( ++sp == max ) { \
87- CollectorsState ()-> SC_MAX_STACK_SIZE *= 2 ; \
102+ SC_MAX_STACK_SIZE *= 2 ; \
88103 return -1 ; \
89104 } \
90105 *++nw = DATA_WORD (word); \
@@ -95,7 +110,7 @@ extern inline struct CollectorsState_ * CollectorsState(void)
95110
96111#define SC_PUSH_GEN ( gen, exp ) \
97112 if ( ++sp == max ) { \
98- CollectorsState ()-> SC_MAX_STACK_SIZE *= 2 ; \
113+ SC_MAX_STACK_SIZE *= 2 ; \
99114 return -1 ; \
100115 } \
101116 *++nw = DATA_WORD (gen); \
@@ -385,22 +400,22 @@ static Int SingleCollectWord(Obj sc, Obj vv, Obj w)
385400 exps = (UInt)1 << (ebits-1 );
386401
387402 // <nw> contains the stack of words to insert
388- vnw = CollectorsState ()-> SC_NW_STACK ;
403+ vnw = SC_NW_STACK ;
389404
390405 // <lw> contains the word end of the word in <nw>
391- vlw = CollectorsState ()-> SC_LW_STACK ;
406+ vlw = SC_LW_STACK ;
392407
393408 // <pw> contains the position of the word in <nw> to look at
394- vpw = CollectorsState ()-> SC_PW_STACK ;
409+ vpw = SC_PW_STACK ;
395410
396411 // <ew> contains the unprocessed exponents at position <pw>
397- vew = CollectorsState ()-> SC_EW_STACK ;
412+ vew = SC_EW_STACK ;
398413
399414 // <ge> contains the global exponent of the word
400- vge = CollectorsState ()-> SC_GE_STACK ;
415+ vge = SC_GE_STACK ;
401416
402417 // get the maximal stack size
403- max = CollectorsState ()-> SC_MAX_STACK_SIZE ;
418+ max = SC_MAX_STACK_SIZE ;
404419
405420 // ensure that the stacks are large enough
406421 const UInt desiredStackSize = sizeof (Obj) * (max + 2 );
@@ -893,22 +908,22 @@ static Int CombiCollectWord(Obj sc, Obj vv, Obj w)
893908 exps = (UInt)1 << (ebits-1 );
894909
895910 // <nw> contains the stack of words to insert
896- vnw = CollectorsState ()-> SC_NW_STACK ;
911+ vnw = SC_NW_STACK ;
897912
898913 // <lw> contains the word end of the word in <nw>
899- vlw = CollectorsState ()-> SC_LW_STACK ;
914+ vlw = SC_LW_STACK ;
900915
901916 // <pw> contains the position of the word in <nw> to look at
902- vpw = CollectorsState ()-> SC_PW_STACK ;
917+ vpw = SC_PW_STACK ;
903918
904919 // <ew> contains the unprocessed exponents at position <pw>
905- vew = CollectorsState ()-> SC_EW_STACK ;
920+ vew = SC_EW_STACK ;
906921
907922 // <ge> contains the global exponent of the word
908- vge = CollectorsState ()-> SC_GE_STACK ;
923+ vge = SC_GE_STACK ;
909924
910925 // get the maximal stack size
911- max = CollectorsState ()-> SC_MAX_STACK_SIZE ;
926+ max = SC_MAX_STACK_SIZE ;
912927
913928 // ensure that the stacks are large enough
914929 const UInt desiredStackSize = sizeof (Obj) * (max + 2 );
@@ -1267,7 +1282,7 @@ static Obj ReducedComm(FinPowConjCol * fc, Obj sc, Obj w, Obj u)
12671282 Obj vc2; // collect vector
12681283
12691284 // use 'cwVector' to collect word <u>*<w> to
1270- vcw = CollectorsState ()-> SC_CW_VECTOR ;
1285+ vcw = SC_CW_VECTOR ;
12711286 num = SC_NUMBER_RWS_GENERATORS (sc);
12721287
12731288 // check that it has the correct length, unpack <u> into it
@@ -1283,7 +1298,7 @@ static Obj ReducedComm(FinPowConjCol * fc, Obj sc, Obj w, Obj u)
12831298 }
12841299
12851300 // use 'cw2Vector' to collect word <w>*<u> to
1286- vc2 = CollectorsState ()-> SC_CW2_VECTOR ;
1301+ vc2 = SC_CW2_VECTOR ;
12871302
12881303 // check that it has the correct length, unpack <w> into it
12891304 if ( fc->vectorWord ( vc2, w, num ) == -1 ) {
@@ -1325,7 +1340,7 @@ static Obj ReducedForm(FinPowConjCol * fc, Obj sc, Obj w)
13251340 Obj type; // type of the return objue
13261341
13271342 // use 'cwVector' to collect word <w> to
1328- vcw = CollectorsState ()-> SC_CW_VECTOR ;
1343+ vcw = SC_CW_VECTOR ;
13291344 num = SC_NUMBER_RWS_GENERATORS (sc);
13301345
13311346 // check that it has the correct length
@@ -1358,7 +1373,7 @@ static Obj ReducedLeftQuotient(FinPowConjCol * fc, Obj sc, Obj w, Obj u)
13581373 Obj vc2; // collect vector
13591374
13601375 // use 'cwVector' to collect word <w> to
1361- vcw = CollectorsState ()-> SC_CW_VECTOR ;
1376+ vcw = SC_CW_VECTOR ;
13621377 num = SC_NUMBER_RWS_GENERATORS (sc);
13631378
13641379 // check that it has the correct length, unpack <w> into it
@@ -1368,7 +1383,7 @@ static Obj ReducedLeftQuotient(FinPowConjCol * fc, Obj sc, Obj w, Obj u)
13681383 }
13691384
13701385 // use 'cw2Vector' to collect word <u> to
1371- vc2 = CollectorsState ()-> SC_CW2_VECTOR ;
1386+ vc2 = SC_CW2_VECTOR ;
13721387
13731388 // check that it has the correct length, unpack <u> into it
13741389 if ( fc->vectorWord ( vc2, u, num ) == -1 ) {
@@ -1402,7 +1417,7 @@ static Obj ReducedProduct(FinPowConjCol * fc, Obj sc, Obj w, Obj u)
14021417 Obj vcw; // collect vector
14031418
14041419 // use 'cwVector' to collect word <w> to
1405- vcw = CollectorsState ()-> SC_CW_VECTOR ;
1420+ vcw = SC_CW_VECTOR ;
14061421 num = SC_NUMBER_RWS_GENERATORS (sc);
14071422
14081423 // check that it has the correct length, unpack <w> into it
@@ -1441,8 +1456,8 @@ static Obj ReducedPowerSmallInt(FinPowConjCol * fc, Obj sc, Obj w, Obj vpow)
14411456 pow = INT_INTOBJ (vpow);
14421457
14431458 // use 'cwVector' and 'cw2Vector to collect words to
1444- vcw = CollectorsState ()-> SC_CW_VECTOR ;
1445- vc2 = CollectorsState ()-> SC_CW2_VECTOR ;
1459+ vcw = SC_CW_VECTOR ;
1460+ vc2 = SC_CW2_VECTOR ;
14461461 num = SC_NUMBER_RWS_GENERATORS (sc);
14471462 type = SC_DEFAULT_TYPE (sc);
14481463
@@ -1528,8 +1543,8 @@ static Obj ReducedQuotient(FinPowConjCol * fc, Obj sc, Obj w, Obj u)
15281543 Obj vc2; // collect vector
15291544
15301545 // use 'cwVector' to collect word <w> to
1531- vcw = CollectorsState ()-> SC_CW_VECTOR ;
1532- vc2 = CollectorsState ()-> SC_CW2_VECTOR ;
1546+ vcw = SC_CW_VECTOR ;
1547+ vc2 = SC_CW2_VECTOR ;
15331548 num = SC_NUMBER_RWS_GENERATORS (sc);
15341549 type = SC_DEFAULT_TYPE (sc);
15351550
@@ -1647,8 +1662,7 @@ static Obj FuncFinPowConjCol_ReducedQuotient ( Obj self, Obj sc, Obj w, Obj u )
16471662*/
16481663static Obj FuncSET_SCOBJ_MAX_STACK_SIZE (Obj self, Obj size)
16491664{
1650- CollectorsState ()->SC_MAX_STACK_SIZE =
1651- GetPositiveSmallInt (SELF_NAME , size);
1665+ SC_MAX_STACK_SIZE = GetPositiveSmallInt (SELF_NAME , size);
16521666 return 0 ;
16531667}
16541668
@@ -1739,25 +1753,25 @@ static Int InitLibrary (
17391753static Int InitModuleState (void )
17401754{
17411755 // register global bags with the garbage collector
1742- InitGlobalBag ( & CollectorsState ()-> SC_NW_STACK , " SC_NW_STACK" );
1743- InitGlobalBag ( & CollectorsState ()-> SC_LW_STACK , " SC_LW_STACK" );
1744- InitGlobalBag ( & CollectorsState ()-> SC_PW_STACK , " SC_PW_STACK" );
1745- InitGlobalBag ( & CollectorsState ()-> SC_EW_STACK , " SC_EW_STACK" );
1746- InitGlobalBag ( & CollectorsState ()-> SC_GE_STACK , " SC_GE_STACK" );
1747- InitGlobalBag ( & CollectorsState ()-> SC_CW_VECTOR , " SC_CW_VECTOR" );
1748- InitGlobalBag ( & CollectorsState ()-> SC_CW2_VECTOR , " SC_CW2_VECTOR" );
1756+ InitGlobalBag (& SC_NW_STACK , " SC_NW_STACK" );
1757+ InitGlobalBag (& SC_LW_STACK , " SC_LW_STACK" );
1758+ InitGlobalBag (& SC_PW_STACK , " SC_PW_STACK" );
1759+ InitGlobalBag (& SC_EW_STACK , " SC_EW_STACK" );
1760+ InitGlobalBag (& SC_GE_STACK , " SC_GE_STACK" );
1761+ InitGlobalBag (& SC_CW_VECTOR , " SC_CW_VECTOR" );
1762+ InitGlobalBag (& SC_CW2_VECTOR , " SC_CW2_VECTOR" );
17491763
17501764 const UInt maxStackSize = 256 ;
17511765 const UInt desiredStackSize = sizeof (Obj) * (maxStackSize + 2 );
1752- CollectorsState ()-> SC_NW_STACK = NewKernelBuffer (desiredStackSize);
1753- CollectorsState ()-> SC_LW_STACK = NewKernelBuffer (desiredStackSize);
1754- CollectorsState ()-> SC_PW_STACK = NewKernelBuffer (desiredStackSize);
1755- CollectorsState ()-> SC_EW_STACK = NewKernelBuffer (desiredStackSize);
1756- CollectorsState ()-> SC_GE_STACK = NewKernelBuffer (desiredStackSize);
1766+ SC_NW_STACK = NewKernelBuffer (desiredStackSize);
1767+ SC_LW_STACK = NewKernelBuffer (desiredStackSize);
1768+ SC_PW_STACK = NewKernelBuffer (desiredStackSize);
1769+ SC_EW_STACK = NewKernelBuffer (desiredStackSize);
1770+ SC_GE_STACK = NewKernelBuffer (desiredStackSize);
17571771
1758- CollectorsState ()-> SC_CW_VECTOR = NEW_STRING (0 );
1759- CollectorsState ()-> SC_CW2_VECTOR = NEW_STRING (0 );
1760- CollectorsState ()-> SC_MAX_STACK_SIZE = maxStackSize;
1772+ SC_CW_VECTOR = NEW_STRING (0 );
1773+ SC_CW2_VECTOR = NEW_STRING (0 );
1774+ SC_MAX_STACK_SIZE = maxStackSize;
17611775
17621776 return 0 ;
17631777}
@@ -1779,8 +1793,13 @@ static StructInitInfo module = {
17791793 /* preSave = */ 0 ,
17801794 /* postSave = */ 0 ,
17811795 /* postRestore = */ 0 ,
1796+ #ifdef HPCGAP
17821797 /* moduleStateSize = */ sizeof (CollectorsState_),
17831798 /* moduleStateOffsetPtr = */ &CollectorsStateOffset,
1799+ #else
1800+ /* moduleStateSize = */ 0 ,
1801+ /* moduleStateOffsetPtr = */ 0 ,
1802+ #endif
17841803 /* initModuleState = */ InitModuleState,
17851804 /* destroyModuleState = */ 0 ,
17861805};
0 commit comments