From 71bdfae94122fff6f245c47721d284f78c286164 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 29 Sep 2012 17:11:03 -0400 Subject: Replacing 'st_table' by 'st__table' to resolve linker problems. --- src/misc/extra/extraBdd.h | 2 +- src/misc/extra/extraBddCas.c | 174 +++++++++++++++++++-------------------- src/misc/extra/extraBddMisc.c | 28 +++---- src/misc/extra/extraBddTime.c | 28 +++---- src/misc/st/st.c | 186 +++++++++++++++++++++--------------------- src/misc/st/st.h | 104 +++++++++++------------ src/misc/st/stmm.c | 6 +- src/misc/st/stmm.h | 12 +-- 8 files changed, 270 insertions(+), 270 deletions(-) (limited to 'src/misc') diff --git a/src/misc/extra/extraBdd.h b/src/misc/extra/extraBdd.h index 8341f53d..fc225e50 100644 --- a/src/misc/extra/extraBdd.h +++ b/src/misc/extra/extraBdd.h @@ -135,7 +135,7 @@ extern DdNode * Extra_bddEncodingBinary( DdManager * dd, DdNode ** pbFuncs, /* solves the column encoding problem using a sophisticated method */ extern DdNode * Extra_bddEncodingNonStrict( DdManager * dd, DdNode ** pbColumns, int nColumns, DdNode * bVarsCol, DdNode ** pCVars, int nMulti, int * pSimple ); /* collects the nodes under the cut and, for each node, computes the sum of paths leading to it from the root */ -extern st_table * Extra_bddNodePathsUnderCut( DdManager * dd, DdNode * bFunc, int CutLevel ); +extern st__table * Extra_bddNodePathsUnderCut( DdManager * dd, DdNode * bFunc, int CutLevel ); /* collects the nodes under the cut starting from the given set of ADD nodes */ extern int Extra_bddNodePathsUnderCutArray( DdManager * dd, DdNode ** paNodes, DdNode ** pbCubes, int nNodes, DdNode ** paNodesRes, DdNode ** pbCubesRes, int CutLevel ); /* find the profile of a DD (the number of edges crossing each level) */ diff --git a/src/misc/extra/extraBddCas.c b/src/misc/extra/extraBddCas.c index 08b0f95f..b745d306 100644 --- a/src/misc/extra/extraBddCas.c +++ b/src/misc/extra/extraBddCas.c @@ -112,8 +112,8 @@ static DdNode * ComputeVarSetAndCountMinterms2( DdManager * dd, DdNode * bVars, unsigned Extra_CountCofactorMinterms( DdManager * dd, DdNode * bFunc, DdNode * bVarsCof, DdNode * bVarsAll ); static unsigned Extra_CountMintermsSimple( DdNode * bFunc, unsigned max ); -static void CountNodeVisits_rec( DdManager * dd, DdNode * aFunc, st_table * Visited ); -static void CollectNodesAndComputePaths_rec( DdManager * dd, DdNode * aFunc, DdNode * bCube, st_table * Visited, st_table * CutNodes ); +static void CountNodeVisits_rec( DdManager * dd, DdNode * aFunc, st__table * Visited ); +static void CollectNodesAndComputePaths_rec( DdManager * dd, DdNode * aFunc, DdNode * bCube, st__table * Visited, st__table * CutNodes ); /**AutomaticEnd***************************************************************/ @@ -225,19 +225,19 @@ Extra_bddEncodingNonStrict( // find the simplest encoding if ( nColumns > 2 ) EvaluateEncodings_rec( dd, bVarsCol, nVarsCol, nMulti, 1 ); -// printf( "The number of backtracks = %d\n", s_BackTracks ); -// s_EncSearchTime += clock() - clk; +// printf( "The number of backtracks = %d\n", s_BackTracks ); +// s_EncSearchTime += clock() - clk; // allocate the temporary storage for the columns s_pbTemp = (DdNode **)ABC_ALLOC( char, nColumns * sizeof(DdNode *) ); -// clk = clock(); +// clk = clock(); bResult = CreateTheCodes_rec( dd, bEncoded, 0, pCVars ); Cudd_Ref( bResult ); -// s_EncComputeTime += clock() - clk; +// s_EncComputeTime += clock() - clk; // delocate the preliminarily encoded set Cudd_RecursiveDeref( dd, bEncoded ); -// Cudd_RecursiveDeref( dd, aEncoded ); +// Cudd_RecursiveDeref( dd, aEncoded ); ABC_FREE( s_pbTemp ); @@ -260,28 +260,28 @@ Extra_bddEncodingNonStrict( SeeAlso [Extra_bddNodePaths] ******************************************************************************/ -st_table * Extra_bddNodePathsUnderCut( DdManager * dd, DdNode * bFunc, int CutLevel ) + st__table * Extra_bddNodePathsUnderCut( DdManager * dd, DdNode * bFunc, int CutLevel ) { - st_table * Visited; // temporary table to remember the visited nodes - st_table * CutNodes; // the result goes here - st_table * Result; // the result goes here + st__table * Visited; // temporary table to remember the visited nodes + st__table * CutNodes; // the result goes here + st__table * Result; // the result goes here DdNode * aFunc; s_CutLevel = CutLevel; - Result = st_init_table(st_ptrcmp, st_ptrhash);; + Result = st__init_table( st__ptrcmp, st__ptrhash);; // the terminal cases if ( Cudd_IsConstant( bFunc ) ) { if ( bFunc == b1 ) { - st_insert( Result, (char*)b1, (char*)b1 ); + st__insert( Result, (char*)b1, (char*)b1 ); Cudd_Ref( b1 ); Cudd_Ref( b1 ); } else { - st_insert( Result, (char*)b0, (char*)b0 ); + st__insert( Result, (char*)b0, (char*)b0 ); Cudd_Ref( b0 ); Cudd_Ref( b0 ); } @@ -293,8 +293,8 @@ st_table * Extra_bddNodePathsUnderCut( DdManager * dd, DdNode * bFunc, int CutLe // Step 1: Start the tables and collect information about the nodes above the cut // this information tells how many edges point to each node - Visited = st_init_table(st_ptrcmp, st_ptrhash);; - CutNodes = st_init_table(st_ptrcmp, st_ptrhash);; + Visited = st__init_table( st__ptrcmp, st__ptrhash);; + CutNodes = st__init_table( st__ptrcmp, st__ptrhash);; CountNodeVisits_rec( dd, aFunc, Visited ); @@ -303,29 +303,29 @@ st_table * Extra_bddNodePathsUnderCut( DdManager * dd, DdNode * bFunc, int CutLe // at this point the table of cut nodes is ready and the table of visited is useless { - st_generator * gen; + st__generator * gen; DdNode * aNode; traventry * p; - st_foreach_item( Visited, gen, (const char**)&aNode, (char**)&p ) + st__foreach_item( Visited, gen, (const char**)&aNode, (char**)&p ) { Cudd_RecursiveDeref( dd, p->bSum ); ABC_FREE( p ); } - st_free_table( Visited ); + st__free_table( Visited ); } // go through the table CutNodes and create the BDD and the path to be returned { - st_generator * gen; + st__generator * gen; DdNode * aNode, * bNode, * bSum; - st_foreach_item( CutNodes, gen, (const char**)&aNode, (char**)&bSum) + st__foreach_item( CutNodes, gen, (const char**)&aNode, (char**)&bSum) { // aNode is not referenced, because aFunc is holding it bNode = Cudd_addBddPattern( dd, aNode ); Cudd_Ref( bNode ); - st_insert( Result, (char*)bNode, (char*)bSum ); + st__insert( Result, (char*)bNode, (char*)bSum ); // the new table takes both refs } - st_free_table( CutNodes ); + st__free_table( CutNodes ); } // dereference the ADD @@ -354,8 +354,8 @@ st_table * Extra_bddNodePathsUnderCut( DdManager * dd, DdNode * bFunc, int CutLe ******************************************************************************/ int Extra_bddNodePathsUnderCutArray( DdManager * dd, DdNode ** paNodes, DdNode ** pbCubes, int nNodes, DdNode ** paNodesRes, DdNode ** pbCubesRes, int CutLevel ) { - st_table * Visited; // temporary table to remember the visited nodes - st_table * CutNodes; // the nodes under the cut go here + st__table * Visited; // temporary table to remember the visited nodes + st__table * CutNodes; // the nodes under the cut go here int i, Counter; s_CutLevel = CutLevel; @@ -379,8 +379,8 @@ int Extra_bddNodePathsUnderCutArray( DdManager * dd, DdNode ** paNodes, DdNode * // Step 1: Start the table and collect information about the nodes above the cut // this information tells how many edges point to each node - CutNodes = st_init_table(st_ptrcmp, st_ptrhash);; - Visited = st_init_table(st_ptrcmp, st_ptrhash);; + CutNodes = st__init_table( st__ptrcmp, st__ptrhash);; + Visited = st__init_table( st__ptrcmp, st__ptrhash);; for ( i = 0; i < nNodes; i++ ) CountNodeVisits_rec( dd, paNodes[i], Visited ); @@ -391,29 +391,29 @@ int Extra_bddNodePathsUnderCutArray( DdManager * dd, DdNode ** paNodes, DdNode * // at this point, the table of cut nodes is ready and the table of visited is useless { - st_generator * gen; + st__generator * gen; DdNode * aNode; traventry * p; - st_foreach_item( Visited, gen, (const char**)&aNode, (char**)&p ) + st__foreach_item( Visited, gen, (const char**)&aNode, (char**)&p ) { Cudd_RecursiveDeref( dd, p->bSum ); ABC_FREE( p ); } - st_free_table( Visited ); + st__free_table( Visited ); } // go through the table CutNodes and create the BDD and the path to be returned { - st_generator * gen; + st__generator * gen; DdNode * aNode, * bSum; Counter = 0; - st_foreach_item( CutNodes, gen, (const char**)&aNode, (char**)&bSum) + st__foreach_item( CutNodes, gen, (const char**)&aNode, (char**)&bSum) { paNodesRes[Counter] = aNode; Cudd_Ref( aNode ); pbCubesRes[Counter] = bSum; Counter++; } - st_free_table( CutNodes ); + st__free_table( CutNodes ); } // return the number of cofactors found @@ -432,11 +432,11 @@ int Extra_bddNodePathsUnderCutArray( DdManager * dd, DdNode ** paNodes, DdNode * SeeAlso [] ***********************************************************************/ -void extraCollectNodes( DdNode * Func, st_table * tNodes ) +void extraCollectNodes( DdNode * Func, st__table * tNodes ) { DdNode * FuncR; FuncR = Cudd_Regular(Func); - if ( st_find_or_add( tNodes, (char*)FuncR, NULL ) ) + if ( st__find_or_add( tNodes, (char*)FuncR, NULL ) ) return; if ( cuddIsConstant(FuncR) ) return; @@ -455,10 +455,10 @@ void extraCollectNodes( DdNode * Func, st_table * tNodes ) SeeAlso [] ***********************************************************************/ -st_table * Extra_CollectNodes( DdNode * Func ) + st__table * Extra_CollectNodes( DdNode * Func ) { - st_table * tNodes; - tNodes = st_init_table( st_ptrcmp, st_ptrhash ); + st__table * tNodes; + tNodes = st__init_table( st__ptrcmp, st__ptrhash ); extraCollectNodes( Func, tNodes ); return tNodes; } @@ -477,11 +477,11 @@ st_table * Extra_CollectNodes( DdNode * Func ) SeeAlso [] ***********************************************************************/ -void extraProfileUpdateTopLevel( st_table * tNodeTopRef, int TopLevelNew, DdNode * node ) +void extraProfileUpdateTopLevel( st__table * tNodeTopRef, int TopLevelNew, DdNode * node ) { int * pTopLevel; - if ( st_find_or_add( tNodeTopRef, (char*)node, (char***)&pTopLevel ) ) + if ( st__find_or_add( tNodeTopRef, (char*)node, (char***)&pTopLevel ) ) { // the node is already referenced // the current top level should be updated if it is larger than the new level if ( *pTopLevel > TopLevelNew ) @@ -518,27 +518,27 @@ void extraProfileUpdateTopLevel( st_table * tNodeTopRef, int TopLevelNew, DdNode ***********************************************************************/ int Extra_ProfileWidth( DdManager * dd, DdNode * Func, int * pProfile, int CutLevel ) { - st_generator * gen; - st_table * tNodeTopRef; // this table stores the top level from which this node is pointed to - st_table * tNodes; + st__generator * gen; + st__table * tNodeTopRef; // this table stores the top level from which this node is pointed to + st__table * tNodes; DdNode * node; DdNode * nodeR; int LevelStart, Limit; - int i, size; + int i, size; int WidthMax; // start the mapping table - tNodeTopRef = st_init_table(st_ptrcmp, st_ptrhash);; + tNodeTopRef = st__init_table( st__ptrcmp, st__ptrhash);; // add the topmost node to the profile extraProfileUpdateTopLevel( tNodeTopRef, 0, Func ); // collect all nodes tNodes = Extra_CollectNodes( Func ); // go though all the nodes and set the top level the cofactors are pointed from -// Cudd_ForeachNode( dd, Func, genDD, node ) - st_foreach_item( tNodes, gen, (const char**)&node, NULL ) +// Cudd_ForeachNode( dd, Func, genDD, node ) + st__foreach_item( tNodes, gen, (const char**)&node, NULL ) { -// assert( Cudd_Regular(node) ); // this procedure works only with ADD/ZDD (not BDD w/ compl.edges) +// assert( Cudd_Regular(node) ); // this procedure works only with ADD/ZDD (not BDD w/ compl.edges) nodeR = Cudd_Regular(node); if ( cuddIsConstant(nodeR) ) continue; @@ -546,7 +546,7 @@ int Extra_ProfileWidth( DdManager * dd, DdNode * Func, int * pProfile, int CutLe extraProfileUpdateTopLevel( tNodeTopRef, dd->perm[node->index]+1, cuddE(nodeR) ); extraProfileUpdateTopLevel( tNodeTopRef, dd->perm[node->index]+1, cuddT(nodeR) ); } - st_free_table( tNodes ); + st__free_table( tNodes ); // clean the profile size = ddMax(dd->size, dd->sizeZ) + 1; @@ -554,7 +554,7 @@ int Extra_ProfileWidth( DdManager * dd, DdNode * Func, int * pProfile, int CutLe pProfile[i] = 0; // create the profile - st_foreach_item( tNodeTopRef, gen, (const char**)&node, (char**)&LevelStart ) + st__foreach_item( tNodeTopRef, gen, (const char**)&node, (char**)&LevelStart ) { nodeR = Cudd_Regular(node); Limit = (cuddIsConstant(nodeR))? dd->size: dd->perm[nodeR->index]; @@ -572,7 +572,7 @@ int Extra_ProfileWidth( DdManager * dd, DdNode * Func, int * pProfile, int CutLe WidthMax = pProfile[i]; // deref the table - st_free_table( tNodeTopRef ); + st__free_table( tNodeTopRef ); return WidthMax; } /* end of Extra_ProfileWidth */ @@ -605,9 +605,9 @@ DdNode * CreateTheCodes_rec( DdManager * dd, DdNode * bEncoded, int Level, DdNod if ( Level == s_nVarsBest ) { // the terminal case, when we need to remap the encoded function // from the preliminary encoded variables to the new ones - st_table * CutNodes; + st__table * CutNodes; int nCols; -// double nMints; +// double nMints; /* #ifdef _DEBUG @@ -615,7 +615,7 @@ DdNode * CreateTheCodes_rec( DdManager * dd, DdNode * bEncoded, int Level, DdNod DdNode * bTemp; // make sure that the given number of variables is enough bTemp = Cudd_bddExistAbstract( dd, bEncoded, s_VarAll ); Cudd_Ref( bTemp ); -// nMints = Cudd_CountMinterm( dd, bTemp, s_MultiStart ); +// nMints = Cudd_CountMinterm( dd, bTemp, s_MultiStart ); nMints = Extra_CountMintermsSimple( bTemp, (1< Extra_Power2( s_MultiStart-Level ) ) { // the number of minterms is too large to encode the columns @@ -634,10 +634,10 @@ DdNode * CreateTheCodes_rec( DdManager * dd, DdNode * bEncoded, int Level, DdNod // put the entries from the table into the temporary array { - st_generator * gen; + st__generator * gen; DdNode * bColumn, * bCode; nCols = 0; - st_foreach_item( CutNodes, gen, (const char**)&bCode, (char**)&bColumn ) + st__foreach_item( CutNodes, gen, (const char**)&bCode, (char**)&bColumn ) { if ( bCode == b0 ) { // the unused part of the columns @@ -652,15 +652,15 @@ DdNode * CreateTheCodes_rec( DdManager * dd, DdNode * bEncoded, int Level, DdNod nCols++; } } - st_free_table( CutNodes ); -// assert( nCols == (int)nMints ); + st__free_table( CutNodes ); +// assert( nCols == (int)nMints ); } // encode the columns if ( s_MultiStart-Level == 0 ) // we reached the bottom level of recursion { assert( nCols == 1 ); -// assert( (int)nMints == 1 ); +// assert( (int)nMints == 1 ); bRes = s_pbTemp[0]; Cudd_Ref( bRes ); } else @@ -864,7 +864,7 @@ DdNode * ComputeVarSetAndCountMinterms( DdManager * dd, DdNode * bVars, DdNode * *Cost = Extra_CountCofactorMinterms( dd, s_Encoded, bVarsRes, s_VarAll ); Cudd_Deref( bVarsRes ); -// s_CountCalls++; +// s_CountCalls++; return bVarsRes; } @@ -893,7 +893,7 @@ DdNode * ComputeVarSetAndCountMinterms2( DdManager * dd, DdNode * bVars, DdNode Cudd_RecursiveDeref( dd, bCof ); Cudd_Deref( bVarsRes ); -// s_CountCalls++; +// s_CountCalls++; return bVarsRes; } @@ -917,23 +917,23 @@ unsigned Extra_CountCofactorMinterms( DdManager * dd, DdNode * bFunc, DdNode * b DdNode * bFuncR; // if the function is zero, there are no minterms -// if ( bFunc == b0 ) -// return 0; +// if ( bFunc == b0 ) +// return 0; -// if ( st_lookup(Visited, (char*)bFunc, NULL) ) -// return 0; +// if ( st__lookup(Visited, (char*)bFunc, NULL) ) +// return 0; -// HKey = hashKey2c( s_Signature, bFuncR ); -// if ( HHTable1[HKey].Sign == s_Signature && HHTable1[HKey].Arg1 == bFuncR ) // this node is visited -// return 0; +// HKey = hashKey2c( s_Signature, bFuncR ); +// if ( HHTable1[HKey].Sign == s_Signature && HHTable1[HKey].Arg1 == bFuncR ) // this node is visited +// return 0; // check the hash-table bFuncR = Cudd_Regular(bFunc); -// HKey = hashKey2( s_Signature, bFuncR, _TABLESIZE_COF ); +// HKey = hashKey2( s_Signature, bFuncR, _TABLESIZE_COF ); HKey = hashKey2( s_Signature, bFunc, _TABLESIZE_COF ); for ( ; HHTable1[HKey].Sign == s_Signature; HKey = (HKey+1) % _TABLESIZE_COF ) -// if ( HHTable1[HKey].Arg1 == bFuncR ) // this node is visited +// if ( HHTable1[HKey].Arg1 == bFuncR ) // this node is visited if ( HHTable1[HKey].Arg1 == bFunc ) // this node is visited return 0; @@ -941,14 +941,14 @@ unsigned Extra_CountCofactorMinterms( DdManager * dd, DdNode * bFunc, DdNode * b // if the function is already the code if ( dd->perm[bFuncR->index] >= s_EncodingVarsLevel ) { -// st_insert(Visited, (char*)bFunc, NULL); +// st__insert(Visited, (char*)bFunc, NULL); -// HHTable1[HKey].Sign = s_Signature; -// HHTable1[HKey].Arg1 = bFuncR; +// HHTable1[HKey].Sign = s_Signature; +// HHTable1[HKey].Arg1 = bFuncR; assert( HHTable1[HKey].Sign != s_Signature ); HHTable1[HKey].Sign = s_Signature; -// HHTable1[HKey].Arg1 = bFuncR; +// HHTable1[HKey].Arg1 = bFuncR; HHTable1[HKey].Arg1 = bFunc; return Extra_CountMintermsSimple( bFunc, (1<TimeStop && clock() > ddS->TimeStop ) @@ -1397,8 +1397,8 @@ extraTransferPermuteRecur( Cudd_RecursiveDeref( ddD, t ); Cudd_RecursiveDeref( ddD, e ); - if ( st_add_direct( table, ( char * ) f, ( char * ) res ) == - ST_OUT_OF_MEM ) + if ( st__add_direct( table, ( char * ) f, ( char * ) res ) == + st__OUT_OF_MEM ) { Cudd_RecursiveDeref( ddD, res ); return ( NULL ); diff --git a/src/misc/extra/extraBddTime.c b/src/misc/extra/extraBddTime.c index b5e2672a..0f4d238d 100644 --- a/src/misc/extra/extraBddTime.c +++ b/src/misc/extra/extraBddTime.c @@ -56,7 +56,7 @@ ABC_NAMESPACE_IMPL_START static DdNode * cuddBddAndRecurTime( DdManager * manager, DdNode * f, DdNode * g, int * pRecCalls, int TimeOut ); static DdNode * cuddBddAndAbstractRecurTime( DdManager * manager, DdNode * f, DdNode * g, DdNode * cube, int * pRecCalls, int TimeOut ); static DdNode * extraTransferPermuteTime( DdManager * ddS, DdManager * ddD, DdNode * f, int * Permute, int TimeOut ); -static DdNode * extraTransferPermuteRecurTime( DdManager * ddS, DdManager * ddD, DdNode * f, st_table * table, int * Permute, int TimeOut ); +static DdNode * extraTransferPermuteRecurTime( DdManager * ddS, DdManager * ddD, DdNode * f, st__table * table, int * Permute, int TimeOut ); /**AutomaticEnd***************************************************************/ @@ -513,11 +513,11 @@ cuddBddAndAbstractRecurTime( DdNode * extraTransferPermuteTime( DdManager * ddS, DdManager * ddD, DdNode * f, int * Permute, int TimeOut ) { DdNode *res; - st_table *table = NULL; - st_generator *gen = NULL; + st__table *table = NULL; + st__generator *gen = NULL; DdNode *key, *value; - table = st_init_table( st_ptrcmp, st_ptrhash ); + table = st__init_table( st__ptrcmp, st__ptrhash ); if ( table == NULL ) goto failure; res = extraTransferPermuteRecurTime( ddS, ddD, f, table, Permute, TimeOut ); @@ -527,16 +527,16 @@ DdNode * extraTransferPermuteTime( DdManager * ddS, DdManager * ddD, DdNode * f, /* Dereference all elements in the table and dispose of the table. ** This must be done also if res is NULL to avoid leaks in case of ** reordering. */ - gen = st_init_gen( table ); + gen = st__init_gen( table ); if ( gen == NULL ) goto failure; - while ( st_gen( gen, ( const char ** ) &key, ( char ** ) &value ) ) + while ( st__gen( gen, ( const char ** ) &key, ( char ** ) &value ) ) { Cudd_RecursiveDeref( ddD, value ); } - st_free_gen( gen ); + st__free_gen( gen ); gen = NULL; - st_free_table( table ); + st__free_table( table ); table = NULL; if ( res != NULL ) @@ -545,9 +545,9 @@ DdNode * extraTransferPermuteTime( DdManager * ddS, DdManager * ddD, DdNode * f, failure: if ( table != NULL ) - st_free_table( table ); + st__free_table( table ); if ( gen != NULL ) - st_free_gen( gen ); + st__free_gen( gen ); return ( NULL ); } /* end of extraTransferPermuteTime */ @@ -570,7 +570,7 @@ extraTransferPermuteRecurTime( DdManager * ddS, DdManager * ddD, DdNode * f, - st_table * table, + st__table * table, int * Permute, int TimeOut ) { @@ -593,7 +593,7 @@ extraTransferPermuteRecurTime( /* Now f is a regular pointer to a non-constant node. */ /* Check the cache. */ - if ( st_lookup( table, ( char * ) f, ( char ** ) &res ) ) + if ( st__lookup( table, ( char * ) f, ( char ** ) &res ) ) return ( Cudd_NotCond( res, comple ) ); if ( TimeOut && clock() > TimeOut ) @@ -643,8 +643,8 @@ extraTransferPermuteRecurTime( Cudd_RecursiveDeref( ddD, t ); Cudd_RecursiveDeref( ddD, e ); - if ( st_add_direct( table, ( char * ) f, ( char * ) res ) == - ST_OUT_OF_MEM ) + if ( st__add_direct( table, ( char * ) f, ( char * ) res ) == + st__OUT_OF_MEM ) { Cudd_RecursiveDeref( ddD, res ); return ( NULL ); diff --git a/src/misc/st/st.c b/src/misc/st/st.c index 2e2edc53..cbdac8be 100644 --- a/src/misc/st/st.c +++ b/src/misc/st/st.c @@ -16,34 +16,34 @@ ABC_NAMESPACE_IMPL_START -#define ST_NUMCMP(x,y) ((x) != (y)) -#define ST_NUMHASH(x,size) (Abc_AbsInt((long)x)%(size)) -//#define ST_PTRHASH(x,size) ((int)((ABC_PTRUINT_T)(x)>>2)%size) // 64-bit bug fix 9/17/2007 -#define ST_PTRHASH(x,size) ((int)(((ABC_PTRUINT_T)(x)>>2)%size)) +#define st__NUMCMP(x,y) ((x) != (y)) +#define st__NUMHASH(x,size) (Abc_AbsInt((long)x)%(size)) +//#define st__PTRHASH(x,size) ((int)((ABC_PTRUINT_T)(x)>>2)%size) // 64-bit bug fix 9/17/2007 +#define st__PTRHASH(x,size) ((int)(((ABC_PTRUINT_T)(x)>>2)%size)) #define EQUAL(func, x, y) \ - ((((func) == st_numcmp) || ((func) == st_ptrcmp)) ?\ - (ST_NUMCMP((x),(y)) == 0) : ((*func)((x), (y)) == 0)) + ((((func) == st__numcmp) || ((func) == st__ptrcmp)) ?\ + (st__NUMCMP((x),(y)) == 0) : ((*func)((x), (y)) == 0)) #define do_hash(key, table)\ - ((table->hash == st_ptrhash) ? ST_PTRHASH((key),(table)->num_bins) :\ - (table->hash == st_numhash) ? ST_NUMHASH((key), (table)->num_bins) :\ + ((table->hash == st__ptrhash) ? st__PTRHASH((key),(table)->num_bins) :\ + (table->hash == st__numhash) ? st__NUMHASH((key), (table)->num_bins) :\ (*table->hash)((key), (table)->num_bins)) -static int rehash(st_table *table); +static int rehash( st__table *table); -int st_numhash(const char*, int); -int st_ptrhash(const char*, int); -int st_numcmp(const char*, const char*); -int st_ptrcmp(const char*, const char*); +int st__numhash(const char*, int); +int st__ptrhash(const char*, int); +int st__numcmp(const char*, const char*); +int st__ptrcmp(const char*, const char*); -st_table * -st_init_table_with_params(st_compare_func_type compare, st_hash_func_type hash, int size, int density, double grow_factor, int reorder_flag) + st__table * + st__init_table_with_params( st__compare_func_type compare, st__hash_func_type hash, int size, int density, double grow_factor, int reorder_flag) { int i; - st_table *newTable; + st__table *newTable; - newTable = ABC_ALLOC(st_table, 1); + newTable = ABC_ALLOC( st__table, 1); if (newTable == NULL) { return NULL; } @@ -57,7 +57,7 @@ st_init_table_with_params(st_compare_func_type compare, st_hash_func_type hash, size = 1; } newTable->num_bins = size; - newTable->bins = ABC_ALLOC(st_table_entry *, size); + newTable->bins = ABC_ALLOC( st__table_entry *, size); if (newTable->bins == NULL) { ABC_FREE(newTable); return NULL; @@ -68,19 +68,19 @@ st_init_table_with_params(st_compare_func_type compare, st_hash_func_type hash, return newTable; } -st_table * -st_init_table(st_compare_func_type compare, st_hash_func_type hash) + st__table * + st__init_table( st__compare_func_type compare, st__hash_func_type hash) { - return st_init_table_with_params(compare, hash, ST_DEFAULT_INIT_TABLE_SIZE, - ST_DEFAULT_MAX_DENSITY, - ST_DEFAULT_GROW_FACTOR, - ST_DEFAULT_REORDER_FLAG); + return st__init_table_with_params(compare, hash, st__DEFAULT_INIT_TABLE_SIZE, + st__DEFAULT_MAX_DENSITY, + st__DEFAULT_GROW_FACTOR, + st__DEFAULT_REORDER_FLAG); } void -st_free_table(st_table *table) + st__free_table( st__table *table) { - st_table_entry *ptr, *next; + st__table_entry *ptr, *next; int i; for(i = 0; i < table->num_bins ; i++) { @@ -111,10 +111,10 @@ st_free_table(st_table *table) } int -st_lookup(st_table *table, const char *key, char **value) + st__lookup( st__table *table, const char *key, char **value) { int hash_val; - st_table_entry *ptr, **last; + st__table_entry *ptr, **last; hash_val = do_hash(key, table); @@ -131,10 +131,10 @@ st_lookup(st_table *table, const char *key, char **value) } int -st_lookup_int(st_table *table, char *key, int *value) + st__lookup_int( st__table *table, char *key, int *value) { int hash_val; - st_table_entry *ptr, **last; + st__table_entry *ptr, **last; hash_val = do_hash(key, table); @@ -158,7 +158,7 @@ st_lookup_int(st_table *table, char *key, int *value) hash_val = do_hash(key,table);\ }\ \ - new = ABC_ALLOC(st_table_entry, 1);\ + new = ABC_ALLOC( st__table_entry, 1);\ \ new->key = key;\ new->record = value;\ @@ -168,11 +168,11 @@ st_lookup_int(st_table *table, char *key, int *value) } int -st_insert(st_table *table, const char *key, char *value) + st__insert( st__table *table, const char *key, char *value) { int hash_val; - st_table_entry *newEntry; - st_table_entry *ptr, **last; + st__table_entry *newEntry; + st__table_entry *ptr, **last; hash_val = do_hash(key, table); @@ -180,14 +180,14 @@ st_insert(st_table *table, const char *key, char *value) if (ptr == NULL) { if (table->num_entries/table->num_bins >= table->max_density) { - if (rehash(table) == ST_OUT_OF_MEM) { - return ST_OUT_OF_MEM; + if (rehash(table) == st__OUT_OF_MEM) { + return st__OUT_OF_MEM; } hash_val = do_hash(key, table); } - newEntry = ABC_ALLOC(st_table_entry, 1); + newEntry = ABC_ALLOC( st__table_entry, 1); if (newEntry == NULL) { - return ST_OUT_OF_MEM; + return st__OUT_OF_MEM; } newEntry->key = (char *)key; newEntry->record = value; @@ -202,21 +202,21 @@ st_insert(st_table *table, const char *key, char *value) } int -st_add_direct(st_table *table, char *key, char *value) + st__add_direct( st__table *table, char *key, char *value) { int hash_val; - st_table_entry *newEntry; + st__table_entry *newEntry; hash_val = do_hash(key, table); if (table->num_entries / table->num_bins >= table->max_density) { - if (rehash(table) == ST_OUT_OF_MEM) { - return ST_OUT_OF_MEM; + if (rehash(table) == st__OUT_OF_MEM) { + return st__OUT_OF_MEM; } } hash_val = do_hash(key, table); - newEntry = ABC_ALLOC(st_table_entry, 1); + newEntry = ABC_ALLOC( st__table_entry, 1); if (newEntry == NULL) { - return ST_OUT_OF_MEM; + return st__OUT_OF_MEM; } newEntry->key = key; newEntry->record = value; @@ -227,10 +227,10 @@ st_add_direct(st_table *table, char *key, char *value) } int -st_find_or_add(st_table *table, char *key, char ***slot) + st__find_or_add( st__table *table, char *key, char ***slot) { int hash_val; - st_table_entry *newEntry, *ptr, **last; + st__table_entry *newEntry, *ptr, **last; hash_val = do_hash(key, table); @@ -238,14 +238,14 @@ st_find_or_add(st_table *table, char *key, char ***slot) if (ptr == NULL) { if (table->num_entries / table->num_bins >= table->max_density) { - if (rehash(table) == ST_OUT_OF_MEM) { - return ST_OUT_OF_MEM; + if (rehash(table) == st__OUT_OF_MEM) { + return st__OUT_OF_MEM; } hash_val = do_hash(key, table); } - newEntry = ABC_ALLOC(st_table_entry, 1); + newEntry = ABC_ALLOC( st__table_entry, 1); if (newEntry == NULL) { - return ST_OUT_OF_MEM; + return st__OUT_OF_MEM; } newEntry->key = key; newEntry->record = (char *) 0; @@ -261,10 +261,10 @@ st_find_or_add(st_table *table, char *key, char ***slot) } int -st_find(st_table *table, char *key, char ***slot) + st__find( st__table *table, char *key, char ***slot) { int hash_val; - st_table_entry *ptr, **last; + st__table_entry *ptr, **last; hash_val = do_hash(key, table); @@ -281,9 +281,9 @@ st_find(st_table *table, char *key, char ***slot) } static int -rehash(st_table *table) +rehash( st__table *table) { - st_table_entry *ptr, *next, **old_bins; + st__table_entry *ptr, *next, **old_bins; int i, old_num_bins, hash_val, old_num_entries; /* save old values */ @@ -297,12 +297,12 @@ rehash(st_table *table) table->num_bins += 1; } table->num_entries = 0; - table->bins = ABC_ALLOC(st_table_entry *, table->num_bins); + table->bins = ABC_ALLOC( st__table_entry *, table->num_bins); if (table->bins == NULL) { table->bins = old_bins; table->num_bins = old_num_bins; table->num_entries = old_num_entries; - return ST_OUT_OF_MEM; + return st__OUT_OF_MEM; } /* initialize */ for (i = 0; i < table->num_bins; i++) { @@ -326,20 +326,20 @@ rehash(st_table *table) return 1; } -st_table * -st_copy(st_table *old_table) + st__table * + st__copy( st__table *old_table) { - st_table *newEntry_table; - st_table_entry *ptr, *newEntryptr, *next, *newEntry; + st__table *newEntry_table; + st__table_entry *ptr, *newEntryptr, *next, *newEntry; int i, j, num_bins = old_table->num_bins; - newEntry_table = ABC_ALLOC(st_table, 1); + newEntry_table = ABC_ALLOC( st__table, 1); if (newEntry_table == NULL) { return NULL; } *newEntry_table = *old_table; - newEntry_table->bins = ABC_ALLOC(st_table_entry *, num_bins); + newEntry_table->bins = ABC_ALLOC( st__table_entry *, num_bins); if (newEntry_table->bins == NULL) { ABC_FREE(newEntry_table); return NULL; @@ -348,7 +348,7 @@ st_copy(st_table *old_table) newEntry_table->bins[i] = NULL; ptr = old_table->bins[i]; while (ptr != NULL) { - newEntry = ABC_ALLOC(st_table_entry, 1); + newEntry = ABC_ALLOC( st__table_entry, 1); if (newEntry == NULL) { for (j = 0; j <= i; j++) { newEntryptr = newEntry_table->bins[j]; @@ -372,11 +372,11 @@ st_copy(st_table *old_table) } int -st_delete(st_table *table, const char **keyp, char **value) + st__delete( st__table *table, const char **keyp, char **value) { int hash_val; const char *key = *keyp; - st_table_entry *ptr, **last; + st__table_entry *ptr, **last; hash_val = do_hash(key, table); @@ -395,11 +395,11 @@ st_delete(st_table *table, const char **keyp, char **value) } int -st_delete_int(st_table *table, long *keyp, char **value) + st__delete_int( st__table *table, long *keyp, char **value) { int hash_val; char *key = (char *) *keyp; - st_table_entry *ptr, **last; + st__table_entry *ptr, **last; hash_val = do_hash(key, table); @@ -418,10 +418,10 @@ st_delete_int(st_table *table, long *keyp, char **value) } int -st_foreach(st_table *table, enum st_retval (*func)(char *, char *, char *), char *arg) + st__foreach( st__table *table, enum st__retval (*func)(char *, char *, char *), char *arg) { - st_table_entry *ptr, **last; - enum st_retval retval; + st__table_entry *ptr, **last; + enum st__retval retval; int i; for(i = 0; i < table->num_bins; i++) { @@ -429,14 +429,14 @@ st_foreach(st_table *table, enum st_retval (*func)(char *, char *, char *), char while (ptr != NULL) { retval = (*func)(ptr->key, ptr->record, arg); switch (retval) { - case ST_CONTINUE: + case st__CONTINUE: last = &ptr->next; ptr = *last; break; - case ST_STOP: + case st__STOP: return 0; - case ST_DELETE: + case st__DELETE: *last = ptr->next; - table->num_entries--; /* cstevens@ic */ + table->num_entries--; /* cstevens@ic */ ABC_FREE(ptr); ptr = *last; } @@ -446,7 +446,7 @@ st_foreach(st_table *table, enum st_retval (*func)(char *, char *, char *), char } int -st_strhash(const char *string, int modulus) + st__strhash(const char *string, int modulus) { int val = 0; int c; @@ -459,35 +459,35 @@ st_strhash(const char *string, int modulus) } int -st_numhash(const char *x, int size) + st__numhash(const char *x, int size) { - return ST_NUMHASH(x, size); + return st__NUMHASH(x, size); } int -st_ptrhash(const char *x, int size) + st__ptrhash(const char *x, int size) { - return ST_PTRHASH(x, size); + return st__PTRHASH(x, size); } int -st_numcmp(const char *x, const char *y) + st__numcmp(const char *x, const char *y) { - return ST_NUMCMP(x, y); + return st__NUMCMP(x, y); } int -st_ptrcmp(const char *x, const char *y) + st__ptrcmp(const char *x, const char *y) { - return ST_NUMCMP(x, y); + return st__NUMCMP(x, y); } -st_generator * -st_init_gen(st_table *table) + st__generator * + st__init_gen( st__table *table) { - st_generator *gen; + st__generator *gen; - gen = ABC_ALLOC(st_generator, 1); + gen = ABC_ALLOC( st__generator, 1); if (gen == NULL) { return NULL; } @@ -499,7 +499,7 @@ st_init_gen(st_table *table) int -st_gen(st_generator *gen, const char **key_p, char **value_p) + st__gen( st__generator *gen, const char **key_p, char **value_p) { int i; @@ -513,7 +513,7 @@ st_gen(st_generator *gen, const char **key_p, char **value_p) } } if (gen->entry == NULL) { - return 0; /* that's all folks ! */ + return 0; /* that's all folks ! */ } } *key_p = gen->entry->key; @@ -526,7 +526,7 @@ st_gen(st_generator *gen, const char **key_p, char **value_p) int -st_gen_int(st_generator *gen, const char **key_p, long *value_p) + st__gen_int( st__generator *gen, const char **key_p, long *value_p) { int i; @@ -540,12 +540,12 @@ st_gen_int(st_generator *gen, const char **key_p, long *value_p) } } if (gen->entry == NULL) { - return 0; /* that's all folks ! */ + return 0; /* that's all folks ! */ } } *key_p = gen->entry->key; if (value_p != 0) { - *value_p = (long) gen->entry->record; + *value_p = (long) gen->entry->record; } gen->entry = gen->entry->next; return 1; @@ -553,7 +553,7 @@ st_gen_int(st_generator *gen, const char **key_p, long *value_p) void -st_free_gen(st_generator *gen) + st__free_gen( st__generator *gen) { ABC_FREE(gen); } diff --git a/src/misc/st/st.h b/src/misc/st/st.h index 2cdebcec..07c6ef3b 100644 --- a/src/misc/st/st.h +++ b/src/misc/st/st.h @@ -13,7 +13,7 @@ #ifndef ABC__misc__st__st_h #define ABC__misc__st__st_h -#define ST_INCLUDED +#define st__INCLUDED #include "misc/util/abc_global.h" @@ -38,79 +38,79 @@ ABC_NAMESPACE_HEADER_START #endif -typedef int (*st_compare_func_type)(const char*, const char*); -typedef int (*st_hash_func_type)(const char*, int); +typedef int (* st__compare_func_type)(const char*, const char*); +typedef int (* st__hash_func_type)(const char*, int); -typedef struct st_table_entry st_table_entry; -struct st_table_entry { +typedef struct st__table_entry st__table_entry; +struct st__table_entry { char *key; char *record; - st_table_entry *next; + st__table_entry *next; }; -typedef struct st_table st_table; -struct st_table { - st_compare_func_type compare; - st_hash_func_type hash; +typedef struct st__table st__table; +struct st__table { + st__compare_func_type compare; + st__hash_func_type hash; int num_bins; int num_entries; int max_density; int reorder_flag; double grow_factor; - st_table_entry **bins; + st__table_entry **bins; }; -typedef struct st_generator st_generator; -struct st_generator { - st_table *table; - st_table_entry *entry; +typedef struct st__generator st__generator; +struct st__generator { + st__table *table; + st__table_entry *entry; int index; }; -#define st_is_member(table,key) st_lookup(table,key,(char **) 0) -#define st_count(table) ((table)->num_entries) +#define st__is_member(table,key) st__lookup(table,key,(char **) 0) +#define st__count(table) ((table)->num_entries) -enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE}; +enum st__retval { st__CONTINUE, st__STOP, st__DELETE}; -typedef enum st_retval (*ST_PFSR)(char *, char *, char *); -typedef int (*ST_PFI)(); +typedef enum st__retval (* st__PFSR)(char *, char *, char *); +typedef int (* st__PFI)(); -extern st_table *st_init_table_with_params (st_compare_func_type compare, st_hash_func_type hash, int size, int density, double grow_factor, int reorder_flag); -extern st_table *st_init_table (st_compare_func_type, st_hash_func_type); -extern void st_free_table (st_table *); -extern int st_lookup (st_table *, const char *, char **); -extern int st_lookup_int (st_table *, char *, int *); -extern int st_insert (st_table *, const char *, char *); -extern int st_add_direct (st_table *, char *, char *); -extern int st_find_or_add (st_table *, char *, char ***); -extern int st_find (st_table *, char *, char ***); -extern st_table *st_copy (st_table *); -extern int st_delete (st_table *, const char **, char **); -extern int st_delete_int (st_table *, long *, char **); -extern int st_foreach (st_table *, ST_PFSR, char *); -extern int st_strhash (const char *, int); -extern int st_numhash (const char *, int); -extern int st_ptrhash (const char *, int); -extern int st_numcmp (const char *, const char *); -extern int st_ptrcmp (const char *, const char *); -extern st_generator *st_init_gen (st_table *); -extern int st_gen (st_generator *, const char **, char **); -extern int st_gen_int (st_generator *, const char **, long *); -extern void st_free_gen (st_generator *); +extern st__table * st__init_table_with_params ( st__compare_func_type compare, st__hash_func_type hash, int size, int density, double grow_factor, int reorder_flag); +extern st__table * st__init_table ( st__compare_func_type, st__hash_func_type); +extern void st__free_table ( st__table *); +extern int st__lookup ( st__table *, const char *, char **); +extern int st__lookup_int ( st__table *, char *, int *); +extern int st__insert ( st__table *, const char *, char *); +extern int st__add_direct ( st__table *, char *, char *); +extern int st__find_or_add ( st__table *, char *, char ***); +extern int st__find ( st__table *, char *, char ***); +extern st__table * st__copy ( st__table *); +extern int st__delete ( st__table *, const char **, char **); +extern int st__delete_int ( st__table *, long *, char **); +extern int st__foreach ( st__table *, st__PFSR, char *); +extern int st__strhash (const char *, int); +extern int st__numhash (const char *, int); +extern int st__ptrhash (const char *, int); +extern int st__numcmp (const char *, const char *); +extern int st__ptrcmp (const char *, const char *); +extern st__generator * st__init_gen ( st__table *); +extern int st__gen ( st__generator *, const char **, char **); +extern int st__gen_int ( st__generator *, const char **, long *); +extern void st__free_gen ( st__generator *); -#define ST_DEFAULT_MAX_DENSITY 5 -#define ST_DEFAULT_INIT_TABLE_SIZE 11 -#define ST_DEFAULT_GROW_FACTOR 2.0 -#define ST_DEFAULT_REORDER_FLAG 0 +#define st__DEFAULT_MAX_DENSITY 5 +#define st__DEFAULT_INIT_TABLE_SIZE 11 +#define st__DEFAULT_GROW_FACTOR 2.0 +#define st__DEFAULT_REORDER_FLAG 0 -#define st_foreach_item(table, gen, key, value) \ - for(gen=st_init_gen(table); st_gen(gen,key,value) || (st_free_gen(gen),0);) +#define st__foreach_item(table, gen, key, value) \ + for(gen= st__init_gen(table); st__gen(gen,key,value) || ( st__free_gen(gen),0);) -#define st_foreach_item_int(table, gen, key, value) \ - for(gen=st_init_gen(table); st_gen_int(gen,key,value) || (st_free_gen(gen),0);) +#define st__foreach_item_int(table, gen, key, value) \ + for(gen= st__init_gen(table); st__gen_int(gen,key,value) || ( st__free_gen(gen),0);) -#define ST_OUT_OF_MEM -10000 +#define st__OUT_OF_MEM -10000 @@ -118,4 +118,4 @@ ABC_NAMESPACE_HEADER_END -#endif /* ST_INCLUDED */ +#endif /* st__INCLUDED */ diff --git a/src/misc/st/stmm.c b/src/misc/st/stmm.c index b7f5b87e..99d78ae1 100644 --- a/src/misc/st/stmm.c +++ b/src/misc/st/stmm.c @@ -499,7 +499,7 @@ stmm_foreach (stmm_table *table, enum stmm_retval (*func) (char *, char *, char return 0; case STMM_DELETE: *last = ptr->next; - table->num_entries--; /* cstevens@ic */ + table->num_entries--; /* cstevens@ic */ // ABC_FREE( ptr ); Extra_MmFixedEntryRecycle ((Extra_MmFixed_t *)table->pMemMan, (char *) ptr); @@ -578,7 +578,7 @@ stmm_gen (stmm_generator *gen, char **key_p, char **value_p) } } if (gen->entry == NULL) { - return 0; /* that's all folks ! */ + return 0; /* that's all folks ! */ } } *key_p = gen->entry->key; @@ -605,7 +605,7 @@ stmm_gen_int (stmm_generator *gen, char **key_p, long *value_p) } } if (gen->entry == NULL) { - return 0; /* that's all folks ! */ + return 0; /* that's all folks ! */ } } *key_p = gen->entry->key; diff --git a/src/misc/st/stmm.h b/src/misc/st/stmm.h index 87daea19..36c3b8c4 100644 --- a/src/misc/st/stmm.h +++ b/src/misc/st/stmm.h @@ -129,12 +129,12 @@ EXTERN void stmm_clean ARGS ((stmm_table *)); /* // consider adding these other other similar definitions -#define st_table stmm_table -#define st_insert stmm_insert -#define st_delete stmm_delete -#define st_lookup stmm_lookup -#define st_init_table stmm_init_table -#define st_free_table stmm_free_table +#define st__table stmm_table +#define st__insert stmm_insert +#define st__delete stmm_delete +#define st__lookup stmm_lookup +#define st__init_table stmm_init_table +#define st__free_table stmm_free_table */ -- cgit v1.2.3