Commit 123b4250 by Bruno Schmitt

Fixes to make xSAT compile with old compilers.

Small typos and variables renaming.
parent cb49c5d0
......@@ -24,7 +24,6 @@
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include "misc/util/abc_global.h"
ABC_NAMESPACE_HEADER_START
......@@ -32,7 +31,6 @@ ABC_NAMESPACE_HEADER_START
////////////////////////////////////////////////////////////////////////
/// STRUCTURE DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
typedef struct xSAT_BQueue_t_ xSAT_BQueue_t;
struct xSAT_BQueue_t_
{
......@@ -41,13 +39,12 @@ struct xSAT_BQueue_t_
int iFirst;
int iEmpty;
word nSum;
word * pData;
unsigned * pData;
};
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
......@@ -63,7 +60,7 @@ static inline xSAT_BQueue_t * xSAT_BQueueNew( int nCap )
{
xSAT_BQueue_t * p = ABC_CALLOC( xSAT_BQueue_t, 1 );
p->nCap = nCap;
p->pData = ABC_CALLOC( word, nCap );
p->pData = ABC_CALLOC( unsigned, nCap );
return p;
}
......@@ -95,7 +92,7 @@ static inline void xSAT_BQueueFree( xSAT_BQueue_t * p )
SeeAlso []
***********************************************************************/
static inline void xSAT_BQueuePush( xSAT_BQueue_t * p, word Value )
static inline void xSAT_BQueuePush( xSAT_BQueue_t * p, unsigned Value )
{
if ( p->nSize == p->nCap )
{
......@@ -128,8 +125,8 @@ static inline void xSAT_BQueuePush( xSAT_BQueue_t * p, word Value )
***********************************************************************/
static inline int xSAT_BQueuePop( xSAT_BQueue_t * p )
{
int RetValue = p->pData[p->iFirst];
assert( p->nSize >= 1 );
int RetValue = p->pData[p->iFirst];
p->nSum -= RetValue;
p->iFirst = ( p->iFirst + 1 ) % p->nCap;
p->nSize--;
......@@ -147,9 +144,9 @@ static inline int xSAT_BQueuePop( xSAT_BQueue_t * p )
SeeAlso []
***********************************************************************/
static inline word xSAT_BQueueAvg( xSAT_BQueue_t * p )
static inline unsigned xSAT_BQueueAvg( xSAT_BQueue_t * p )
{
return ( word )( p->nSum / ( ( word ) p->nSize ) );
return ( unsigned )( p->nSum / ( ( word ) p->nSize ) );
}
/**Function*************************************************************
......
......@@ -39,7 +39,7 @@ struct xSAT_Clause_t_
unsigned fReallocd : 1;
unsigned fCanBeDel : 1;
unsigned nLBD : 28;
unsigned nSize;
int nSize;
union {
int Lit;
unsigned Act;
......@@ -60,7 +60,7 @@ struct xSAT_Clause_t_
SeeAlso []
***********************************************************************/
static int xSAT_ClauseCompare( const void * p1, const void * p2 )
static inline int xSAT_ClauseCompare( const void * p1, const void * p2 )
{
xSAT_Clause_t * pC1 = ( xSAT_Clause_t * ) p1;
xSAT_Clause_t * pC2 = ( xSAT_Clause_t * ) p2;
......@@ -91,12 +91,12 @@ static int xSAT_ClauseCompare( const void * p1, const void * p2 )
SeeAlso []
***********************************************************************/
static void xSAT_ClausePrint( xSAT_Clause_t * pCla )
static inline void xSAT_ClausePrint( xSAT_Clause_t * pCla )
{
int i;
printf("{ ");
for ( i = 0; i < (int)pCla->nSize; i++ )
for ( i = 0; i < pCla->nSize; i++ )
printf("%d ", pCla->pData[i].Lit );
printf("}\n");
}
......
......@@ -48,7 +48,7 @@ struct xSAT_Heap_t_
SeeAlso []
***********************************************************************/
static inline int xSAT_HeapSize( xSAT_Heap_t * h )
inline int xSAT_HeapSize( xSAT_Heap_t * h )
{
return Vec_IntSize( h->vHeap );
}
......@@ -64,7 +64,7 @@ static inline int xSAT_HeapSize( xSAT_Heap_t * h )
SeeAlso []
***********************************************************************/
static inline int xSAT_HeapInHeap( xSAT_Heap_t * h, int Var )
inline int xSAT_HeapInHeap( xSAT_Heap_t * h, int Var )
{
return ( Var < Vec_IntSize( h->vIndices ) ) && ( Vec_IntEntry( h->vIndices, Var ) >= 0 );
}
......
......@@ -77,16 +77,14 @@ static inline void xSAT_MemGrow( xSAT_Mem_t * p, unsigned nCap )
unsigned nPrevCap = p->nCap;
if ( p->nCap >= nCap )
return;
while (p->nCap < nCap)
{
unsigned delta = ((p->nCap >> 1) + (p->nCap >> 3) + 2) & ~1;
unsigned delta = ( ( p->nCap >> 1 ) + ( p->nCap >> 3 ) + 2 ) & ~1;
p->nCap += delta;
assert(p->nCap >= nPrevCap);
}
assert(p->nCap > 0);
p->pData = ABC_REALLOC(unsigned, p->pData, p->nCap);
p->pData = ABC_REALLOC( unsigned, p->pData, p->nCap );
}
/**Function*************************************************************
......@@ -160,12 +158,10 @@ static inline unsigned xSAT_MemAppend( xSAT_Mem_t * p, int nSize )
{
unsigned nPrevSize;
assert(nSize > 0);
xSAT_MemGrow(p, p->nSize + nSize);
xSAT_MemGrow( p, p->nSize + nSize );
nPrevSize = p->nSize;
p->nSize += nSize;
assert(p->nSize > nPrevSize);
return nPrevSize;
}
......
......@@ -81,9 +81,9 @@ struct xSAT_SolverOptions_t_
char fVerbose;
// Limits
word nConfLimit; // external limit on the number of conflicts
word nInsLimit; // external limit on the number of implications
abctime nRuntimeLimit; // external limit on runtime
iword nConfLimit; // external limit on the number of conflicts
iword nInsLimit; // external limit on the number of implications
abctime nRuntimeLimit; // external limit on runtime
// Constants used for restart heuristic
double K; // Forces a restart
......@@ -105,13 +105,13 @@ struct xSAT_Stats_t_
unsigned nStarts;
unsigned nReduceDB;
word nDecisions;
word nPropagations;
word nInspects;
word nConflicts;
iword nDecisions;
iword nPropagations;
iword nInspects;
iword nConflicts;
word nClauseLits;
word nLearntLits;
iword nClauseLits;
iword nLearntLits;
};
struct xSAT_Solver_t_
......@@ -143,7 +143,7 @@ struct xSAT_Solver_t_
int nAssignSimplify; /* Number of top-level assignments since last
* execution of 'simplify()'. */
word nPropSimplify; /* Remaining number of propagations that must be
int64_t nPropSimplify; /* Remaining number of propagations that must be
* made before next execution of 'simplify()'. */
/* Temporary data used by Search method */
......@@ -203,10 +203,10 @@ static inline xSAT_Clause_t * xSAT_SolverReadClause( xSAT_Solver_t * s, unsigned
static inline int xSAT_SolverIsClauseSatisfied( xSAT_Solver_t * s, xSAT_Clause_t * pCla )
{
int i;
int * lits = &( pCla->pData[0].Lit );
int * Lits = &( pCla->pData[0].Lit );
for ( i = 0; i < (int)pCla->nSize; i++ )
if ( Vec_StrEntry( s->vAssigns, xSAT_Lit2Var( lits[i] ) ) == xSAT_LitSign( ( lits[i] ) ) )
for ( i = 0; i < pCla->nSize; i++ )
if ( Vec_StrEntry( s->vAssigns, xSAT_Lit2Var( Lits[i] ) ) == xSAT_LitSign( ( Lits[i] ) ) )
return true;
return false;
......
......@@ -51,6 +51,7 @@ xSAT_SolverOptions_t DefaultConfig =
30 //.nLBDFrozenClause = 30
};
/**Function*************************************************************
Synopsis []
......@@ -125,7 +126,6 @@ void xSAT_SolverDestroy( xSAT_Solver_t * s )
xSAT_VecWatchListFree( s->vWatches );
xSAT_VecWatchListFree( s->vBinWatches );
// delete vectors
xSAT_HeapFree(s->hOrder);
Vec_IntFree( s->vTrailLim );
Vec_IntFree( s->vTrail );
......
......@@ -118,9 +118,9 @@ static inline void xSAT_WatchListShrink( xSAT_WatchList_t * v, int k )
static inline void xSAT_WatchListPush( xSAT_WatchList_t * v, xSAT_Watcher_t e )
{
assert( v );
if (v->nSize == v->nCap)
if ( v->nSize == v->nCap )
{
int newsize = (v->nCap < 4) ? 4 : (v->nCap / 2) * 3;
int newsize = ( v->nCap < 4 ) ? 4 : ( v->nCap / 2 ) * 3;
v->pArray = ABC_REALLOC( xSAT_Watcher_t, v->pArray, newsize );
if ( v->pArray == NULL )
......@@ -167,9 +167,9 @@ static inline void xSAT_WatchListRemove( xSAT_WatchList_t * v, unsigned CRef )
xSAT_Watcher_t* ws = xSAT_WatchListArray(v);
int j = 0;
for (; ws[j].CRef != CRef; j++);
assert(j < xSAT_WatchListSize(v));
memmove(v->pArray + j, v->pArray + j + 1, (v->nSize - j - 1) * sizeof(xSAT_Watcher_t));
for ( ; ws[j].CRef != CRef; j++ );
assert( j < xSAT_WatchListSize( v ) );
memmove( v->pArray + j, v->pArray + j + 1, ( v->nSize - j - 1 ) * sizeof( xSAT_Watcher_t ) );
v->nSize -= 1;
}
......@@ -190,7 +190,7 @@ static inline xSAT_VecWatchList_t * xSAT_VecWatchListAlloc( int nCap )
v->nCap = 4;
v->nSize = 0;
v->pArray = (xSAT_WatchList_t *) ABC_CALLOC(xSAT_WatchList_t, sizeof( xSAT_WatchList_t ) * v->nCap);
v->pArray = ( xSAT_WatchList_t * ) ABC_CALLOC(xSAT_WatchList_t, sizeof( xSAT_WatchList_t ) * v->nCap);
return v;
}
......@@ -233,7 +233,7 @@ static inline void xSAT_VecWatchListPush( xSAT_VecWatchList_t* v )
int newsize = (v->nCap < 4) ? v->nCap * 2 : (v->nCap / 2) * 3;
v->pArray = ABC_REALLOC( xSAT_WatchList_t, v->pArray, newsize );
memset( v->pArray + v->nCap, 0, sizeof(xSAT_WatchList_t) * (newsize - v->nCap) );
memset( v->pArray + v->nCap, 0, sizeof( xSAT_WatchList_t ) * ( newsize - v->nCap ) );
if ( v->pArray == NULL )
{
printf( "Failed to realloc memory from %.1f MB to %.1f MB.\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment