diff options
Diffstat (limited to 'src/misc')
-rw-r--r-- | src/misc/util/abc_global.h | 27 | ||||
-rw-r--r-- | src/misc/vec/vecFlt.h | 10 | ||||
-rw-r--r-- | src/misc/vec/vecInt.h | 10 | ||||
-rw-r--r-- | src/misc/vec/vecPtr.h | 10 | ||||
-rw-r--r-- | src/misc/vec/vecStr.h | 10 | ||||
-rw-r--r-- | src/misc/vec/vecWec.h | 10 | ||||
-rw-r--r-- | src/misc/vec/vecWrd.h | 10 |
7 files changed, 79 insertions, 8 deletions
diff --git a/src/misc/util/abc_global.h b/src/misc/util/abc_global.h index b798961e..6e112bb8 100644 --- a/src/misc/util/abc_global.h +++ b/src/misc/util/abc_global.h @@ -80,6 +80,7 @@ #include <time.h> #include <stdarg.h> #include <stdlib.h> +#include <assert.h> //////////////////////////////////////////////////////////////////////// /// NAMESPACES /// @@ -260,20 +261,30 @@ static inline void Abc_InfoSetBit( unsigned * p, int i ) { p[(i)>>5] |= (1< static inline void Abc_InfoXorBit( unsigned * p, int i ) { p[(i)>>5] ^= (1<<((i) & 31)); } static inline unsigned Abc_InfoMask( int nVar ) { return (~(unsigned)0) >> (32-nVar); } -static inline int Abc_Var2Lit( int Var, int fCompl ) { return Var + Var + fCompl; } -static inline int Abc_Lit2Var( int Lit ) { return Lit >> 1; } -static inline int Abc_LitIsCompl( int Lit ) { return Lit & 1; } -static inline int Abc_LitNot( int Lit ) { return Lit ^ 1; } -static inline int Abc_LitNotCond( int Lit, int c ) { return Lit ^ (int)(c > 0); } -static inline int Abc_LitRegular( int Lit ) { return Lit & ~01; } -static inline int Abc_Lit2LitV( int * pMap, int Lit ) { return Abc_Var2Lit( pMap[Abc_Lit2Var(Lit)], Abc_LitIsCompl(Lit) ); } -static inline int Abc_Lit2LitL( int * pMap, int Lit ) { return Abc_LitNotCond( pMap[Abc_Lit2Var(Lit)], Abc_LitIsCompl(Lit) ); } +static inline int Abc_Var2Lit( int Var, int c ) { assert(Var >= 0 && !(c >> 1)); return Var + Var + c; } +static inline int Abc_Lit2Var( int Lit ) { assert(Lit >= 0); return Lit >> 1; } +static inline int Abc_LitIsCompl( int Lit ) { assert(Lit >= 0); return Lit & 1; } +static inline int Abc_LitNot( int Lit ) { assert(Lit >= 0); return Lit ^ 1; } +static inline int Abc_LitNotCond( int Lit, int c ) { assert(Lit >= 0); return Lit ^ (int)(c > 0); } +static inline int Abc_LitRegular( int Lit ) { assert(Lit >= 0); return Lit & ~01; } +static inline int Abc_Lit2LitV( int * pMap, int Lit ) { assert(Lit >= 0); return Abc_Var2Lit( pMap[Abc_Lit2Var(Lit)], Abc_LitIsCompl(Lit) ); } +static inline int Abc_Lit2LitL( int * pMap, int Lit ) { assert(Lit >= 0); return Abc_LitNotCond( pMap[Abc_Lit2Var(Lit)], Abc_LitIsCompl(Lit) ); } static inline int Abc_Ptr2Int( void * p ) { return (int)(ABC_PTRINT_T)p; } static inline void * Abc_Int2Ptr( int i ) { return (void *)(ABC_PTRINT_T)i; } static inline word Abc_Ptr2Wrd( void * p ) { return (word)(ABC_PTRUINT_T)p; } static inline void * Abc_Wrd2Ptr( word i ) { return (void *)(ABC_PTRUINT_T)i; } +static inline int Abc_Var2Lit2( int Var, int Att ) { assert(!(Att >> 2)); return (Var << 2) + Att; } +static inline int Abc_Lit2Var2( int Lit ) { assert(Lit >= 0); return Lit >> 2; } +static inline int Abc_Lit2Att2( int Lit ) { assert(Lit >= 0); return Lit & 3; } +static inline int Abc_Var2Lit3( int Var, int Att ) { assert(!(Att >> 3)); return (Var << 3) + Att; } +static inline int Abc_Lit2Var3( int Lit ) { assert(Lit >= 0); return Lit >> 3; } +static inline int Abc_Lit2Att3( int Lit ) { assert(Lit >= 0); return Lit & 7; } +static inline int Abc_Var2Lit4( int Var, int Att ) { assert(!(Att >> 4)); return (Var << 4) + Att; } +static inline int Abc_Lit2Var4( int Lit ) { assert(Lit >= 0); return Lit >> 4; } +static inline int Abc_Lit2Att4( int Lit ) { assert(Lit >= 0); return Lit & 15; } + // time counting typedef ABC_INT64_T abctime; static inline abctime Abc_Clock() diff --git a/src/misc/vec/vecFlt.h b/src/misc/vec/vecFlt.h index 8f3005a4..482973f7 100644 --- a/src/misc/vec/vecFlt.h +++ b/src/misc/vec/vecFlt.h @@ -86,6 +86,16 @@ static inline Vec_Flt_t * Vec_FltAlloc( int nCap ) p->pArray = p->nCap? ABC_ALLOC( float, p->nCap ) : NULL; return p; } +static inline Vec_Flt_t * Vec_FltAllocExact( int nCap ) +{ + Vec_Flt_t * p; + assert( nCap >= 0 ); + p = ABC_ALLOC( Vec_Flt_t, 1 ); + p->nSize = 0; + p->nCap = nCap; + p->pArray = p->nCap? ABC_ALLOC( float, p->nCap ) : NULL; + return p; +} /**Function************************************************************* diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h index 3e195bd3..e37743c5 100644 --- a/src/misc/vec/vecInt.h +++ b/src/misc/vec/vecInt.h @@ -96,6 +96,16 @@ static inline Vec_Int_t * Vec_IntAlloc( int nCap ) p->pArray = p->nCap? ABC_ALLOC( int, p->nCap ) : NULL; return p; } +static inline Vec_Int_t * Vec_IntAllocExact( int nCap ) +{ + Vec_Int_t * p; + assert( nCap >= 0 ); + p = ABC_ALLOC( Vec_Int_t, 1 ); + p->nSize = 0; + p->nCap = nCap; + p->pArray = p->nCap? ABC_ALLOC( int, p->nCap ) : NULL; + return p; +} /**Function************************************************************* diff --git a/src/misc/vec/vecPtr.h b/src/misc/vec/vecPtr.h index 516429ff..5fa40112 100644 --- a/src/misc/vec/vecPtr.h +++ b/src/misc/vec/vecPtr.h @@ -91,6 +91,16 @@ static inline Vec_Ptr_t * Vec_PtrAlloc( int nCap ) p->pArray = p->nCap? ABC_ALLOC( void *, p->nCap ) : NULL; return p; } +static inline Vec_Ptr_t * Vec_PtrAllocExact( int nCap ) +{ + Vec_Ptr_t * p; + assert( nCap >= 0 ); + p = ABC_ALLOC( Vec_Ptr_t, 1 ); + p->nSize = 0; + p->nCap = nCap; + p->pArray = p->nCap? ABC_ALLOC( void *, p->nCap ) : NULL; + return p; +} /**Function************************************************************* diff --git a/src/misc/vec/vecStr.h b/src/misc/vec/vecStr.h index 5f04615c..4198ac82 100644 --- a/src/misc/vec/vecStr.h +++ b/src/misc/vec/vecStr.h @@ -80,6 +80,16 @@ static inline Vec_Str_t * Vec_StrAlloc( int nCap ) p->pArray = p->nCap? ABC_ALLOC( char, p->nCap ) : NULL; return p; } +static inline Vec_Str_t * Vec_StrAllocExact( int nCap ) +{ + Vec_Str_t * p; + assert( nCap >= 0 ); + p = ABC_ALLOC( Vec_Str_t, 1 ); + p->nSize = 0; + p->nCap = nCap; + p->pArray = p->nCap? ABC_ALLOC( char, p->nCap ) : NULL; + return p; +} /**Function************************************************************* diff --git a/src/misc/vec/vecWec.h b/src/misc/vec/vecWec.h index f2fe3216..b09852ff 100644 --- a/src/misc/vec/vecWec.h +++ b/src/misc/vec/vecWec.h @@ -95,6 +95,16 @@ static inline Vec_Wec_t * Vec_WecAlloc( int nCap ) p->pArray = p->nCap? ABC_CALLOC( Vec_Int_t, p->nCap ) : NULL; return p; } +static inline Vec_Wec_t * Vec_WecAllocExact( int nCap ) +{ + Vec_Wec_t * p; + assert( nCap >= 0 ); + p = ABC_ALLOC( Vec_Wec_t, 1 ); + p->nSize = 0; + p->nCap = nCap; + p->pArray = p->nCap? ABC_CALLOC( Vec_Int_t, p->nCap ) : NULL; + return p; +} static inline Vec_Wec_t * Vec_WecStart( int nSize ) { Vec_Wec_t * p; diff --git a/src/misc/vec/vecWrd.h b/src/misc/vec/vecWrd.h index 5688d7b2..5227fec5 100644 --- a/src/misc/vec/vecWrd.h +++ b/src/misc/vec/vecWrd.h @@ -88,6 +88,16 @@ static inline Vec_Wrd_t * Vec_WrdAlloc( int nCap ) p->pArray = p->nCap? ABC_ALLOC( word, p->nCap ) : NULL; return p; } +static inline Vec_Wrd_t * Vec_WrdAllocExact( int nCap ) +{ + Vec_Wrd_t * p; + assert( nCap >= 0 ); + p = ABC_ALLOC( Vec_Wrd_t, 1 ); + p->nSize = 0; + p->nCap = nCap; + p->pArray = p->nCap? ABC_ALLOC( word, p->nCap ) : NULL; + return p; +} /**Function************************************************************* |