diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2012-01-21 04:30:10 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2012-01-21 04:30:10 -0800 |
commit | 8014f25f6db719fa62336f997963532a14c568f6 (patch) | |
tree | c691ee91a3a2d452a2bd24ac89a8c717beaa7af7 /src/misc/util | |
parent | c44cc5de9429e6b4f1c05045fcf43c9cb96437b5 (diff) | |
download | abc-8014f25f6db719fa62336f997963532a14c568f6.tar.gz abc-8014f25f6db719fa62336f997963532a14c568f6.tar.bz2 abc-8014f25f6db719fa62336f997963532a14c568f6.zip |
Major restructuring of the code.
Diffstat (limited to 'src/misc/util')
-rw-r--r-- | src/misc/util/abc_global.h | 52 | ||||
-rw-r--r-- | src/misc/util/utilCex.c | 4 | ||||
-rw-r--r-- | src/misc/util/utilCex.h | 4 | ||||
-rw-r--r-- | src/misc/util/utilMem.h | 4 | ||||
-rw-r--r-- | src/misc/util/utilNam.c | 4 | ||||
-rw-r--r-- | src/misc/util/utilNam.h | 4 | ||||
-rw-r--r-- | src/misc/util/utilSignal.c | 2 | ||||
-rw-r--r-- | src/misc/util/utilSignal.h | 4 | ||||
-rw-r--r-- | src/misc/util/util_hack.h | 4 |
9 files changed, 48 insertions, 34 deletions
diff --git a/src/misc/util/abc_global.h b/src/misc/util/abc_global.h index 61aa9327..83c86f28 100644 --- a/src/misc/util/abc_global.h +++ b/src/misc/util/abc_global.h @@ -18,8 +18,8 @@ ***********************************************************************/ -#ifndef __ABC_GLOBAL_H__ -#define __ABC_GLOBAL_H__ +#ifndef ABC__misc__util__abc_global_h +#define ABC__misc__util__abc_global_h //////////////////////////////////////////////////////////////////////// /// INCLUDES /// @@ -200,11 +200,7 @@ typedef ABC_UINT64_T word; /// MACRO DEFINITIONS /// //////////////////////////////////////////////////////////////////////// - -#define ABC_ABS(a) ((a) < 0 ? -(a) : (a)) -#define ABC_MAX(a,b) ((a) > (b) ? (a) : (b)) -#define ABC_MIN(a,b) ((a) < (b) ? (a) : (b)) -#define ABC_INFINITY (100000000) +#define ABC_INFINITY (100000000) #define ABC_PRT(a,t) (printf("%s = ", (a)), printf("%7.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))) #define ABC_PRTr(a,t) (printf("%s = ", (a)), printf("%7.2f sec\r", (float)(t)/(float)(CLOCKS_PER_SEC))) @@ -236,17 +232,37 @@ ABC_NAMESPACE_HEADER_START ((type *) Util_MemRecAlloc(malloc(sizeof(type) * (num))))) #endif -static inline int Abc_AbsInt( int a ) { return a < 0 ? -a : a; } -static inline int Abc_MaxInt( int a, int b ) { return a > b ? a : b; } -static inline int Abc_MinInt( int a, int b ) { return a < b ? a : b; } -static inline word Abc_MaxWord( word a, word b ) { return a > b ? a : b; } -static inline word Abc_MinWord( word a, word b ) { return a < b ? a : b; } -static inline float Abc_AbsFloat( float a ) { return a < 0 ? -a : a; } -static inline float Abc_MaxFloat( float a, float b ) { return a > b ? a : b; } -static inline float Abc_MinFloat( float a, float b ) { return a < b ? a : b; } -static inline double Abc_AbsDouble( double a ) { return a < 0 ? -a : a; } -static inline double Abc_MaxDouble( double a, double b ) { return a > b ? a : b; } -static inline double Abc_MinDouble( double a, double b ) { return a < b ? a : b; } +static inline int Abc_AbsInt( int a ) { return a < 0 ? -a : a; } +static inline int Abc_MaxInt( int a, int b ) { return a > b ? a : b; } +static inline int Abc_MinInt( int a, int b ) { return a < b ? a : b; } +static inline word Abc_MaxWord( word a, word b ) { return a > b ? a : b; } +static inline word Abc_MinWord( word a, word b ) { return a < b ? a : b; } +static inline float Abc_AbsFloat( float a ) { return a < 0 ? -a : a; } +static inline float Abc_MaxFloat( float a, float b ) { return a > b ? a : b; } +static inline float Abc_MinFloat( float a, float b ) { return a < b ? a : b; } +static inline double Abc_AbsDouble( double a ) { return a < 0 ? -a : a; } +static inline double Abc_MaxDouble( double a, double b ) { return a > b ? a : b; } +static inline double Abc_MinDouble( double a, double b ) { return a < b ? a : b; } + +static inline int Abc_Float2Int( float Val ) { union { int x; float y; } v; v.y = Val; return v.x; } +static inline float Abc_Int2Float( int Num ) { union { int x; float y; } v; v.x = Num; return v.y; } +static inline int Abc_Base2Log( unsigned n ) { int r; if ( n < 2 ) return n; for ( r = 0, n--; n; n >>= 1, r++ ); return r; } +static inline int Abc_Base10Log( unsigned n ) { int r; if ( n < 2 ) return n; for ( r = 0, n--; n; n /= 10, r++ ); return r; } +static inline int Abc_Base16Log( unsigned n ) { int r; if ( n < 2 ) return n; for ( r = 0, n--; n; n /= 16, r++ ); return r; } +static inline char * Abc_UtilStrsav( char * s ) { return s ? strcpy(ABC_ALLOC(char, strlen(s)+1), s) : NULL; } +static inline int Abc_BitWordNum( int nBits ) { return (nBits>>5) + ((nBits&31) > 0); } +static inline int Abc_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); } +static inline int Abc_InfoHasBit( unsigned * p, int i ) { return (p[(i)>>5] & (1<<((i) & 31))) > 0; } +static inline void Abc_InfoSetBit( unsigned * p, int i ) { p[(i)>>5] |= (1<<((i) & 31)); } +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; } enum Abc_VerbLevel { diff --git a/src/misc/util/utilCex.c b/src/misc/util/utilCex.c index 37205543..80d8e141 100644 --- a/src/misc/util/utilCex.c +++ b/src/misc/util/utilCex.c @@ -32,10 +32,6 @@ ABC_NAMESPACE_IMPL_START /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// -static inline int Abc_BitWordNum( int nBits ) { return (nBits>>5) + ((nBits&31) > 0); } -static inline int Abc_InfoHasBit( unsigned * p, int i ) { return (p[(i)>>5] & (1<<((i) & 31))) > 0; } -static inline void Abc_InfoSetBit( unsigned * p, int i ) { p[(i)>>5] |= (1<<((i) & 31)); } - //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// diff --git a/src/misc/util/utilCex.h b/src/misc/util/utilCex.h index 556f2268..b45cd27b 100644 --- a/src/misc/util/utilCex.h +++ b/src/misc/util/utilCex.h @@ -18,8 +18,8 @@ ***********************************************************************/ -#ifndef __UTIL_CEX_H__ -#define __UTIL_CEX_H__ +#ifndef ABC__misc__util__utilCex_h +#define ABC__misc__util__utilCex_h //////////////////////////////////////////////////////////////////////// /// INCLUDES /// diff --git a/src/misc/util/utilMem.h b/src/misc/util/utilMem.h index 1f8432c1..af5873c0 100644 --- a/src/misc/util/utilMem.h +++ b/src/misc/util/utilMem.h @@ -18,8 +18,8 @@ ***********************************************************************/ -#ifndef __UTIL_INT_H__ -#define __UTIL_INT_H__ +#ifndef ABC__misc__util__utilMem_h +#define ABC__misc__util__utilMem_h //////////////////////////////////////////////////////////////////////// diff --git a/src/misc/util/utilNam.c b/src/misc/util/utilNam.c index 79565186..c6399818 100644 --- a/src/misc/util/utilNam.c +++ b/src/misc/util/utilNam.c @@ -25,7 +25,7 @@ #include <assert.h> #include "abc_global.h" -#include "vec.h" +#include "src/misc/vec/vec.h" #include "utilNam.h" ABC_NAMESPACE_IMPL_START @@ -304,7 +304,7 @@ void Abc_NamStrHashResize( Abc_Nam_t * p ) char * pThis; int * piPlace, * pBinsOld, iHandleOld, i;//, clk = clock(); assert( p->pBins != NULL ); -// Abc_Print( 1, "Resizing names manager hash table from %6d to %6d. ", p->nBins, Gia_PrimeCudd( 3 * p->nBins ) ); +// Abc_Print( 1, "Resizing names manager hash table from %6d to %6d. ", p->nBins, Abc_PrimeCudd( 3 * p->nBins ) ); // replace the table pBinsOld = p->pBins; p->nBins = Abc_PrimeCudd( 3 * p->nBins ); diff --git a/src/misc/util/utilNam.h b/src/misc/util/utilNam.h index ae2c099c..fd29e537 100644 --- a/src/misc/util/utilNam.h +++ b/src/misc/util/utilNam.h @@ -18,8 +18,8 @@ ***********************************************************************/ -#ifndef __UTIL_NAM_H__ -#define __UTIL_NAM_H__ +#ifndef ABC__misc__util__utilNam_h +#define ABC__misc__util__utilNam_h //////////////////////////////////////////////////////////////////////// diff --git a/src/misc/util/utilSignal.c b/src/misc/util/utilSignal.c index 2886f69b..af0948bd 100644 --- a/src/misc/util/utilSignal.c +++ b/src/misc/util/utilSignal.c @@ -20,6 +20,8 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> + #include "abc_global.h" #include "utilSignal.h" diff --git a/src/misc/util/utilSignal.h b/src/misc/util/utilSignal.h index 0ac87290..b29def80 100644 --- a/src/misc/util/utilSignal.h +++ b/src/misc/util/utilSignal.h @@ -18,8 +18,8 @@ ***********************************************************************/ -#ifndef __UTIL_SIGNAL_H__ -#define __UTIL_SIGNAL_H__ +#ifndef ABC__misc__util__utilSignal_h +#define ABC__misc__util__utilSignal_h //////////////////////////////////////////////////////////////////////// /// INCLUDES /// diff --git a/src/misc/util/util_hack.h b/src/misc/util/util_hack.h index 1a734f03..9c702bfe 100644 --- a/src/misc/util/util_hack.h +++ b/src/misc/util/util_hack.h @@ -18,8 +18,8 @@ ***********************************************************************/ -#ifndef __UTIL_HACK_H__ -#define __UTIL_HACK_H__ +#ifndef ABC__misc__util__util_hack_h +#define ABC__misc__util__util_hack_h #include <stdio.h> #include <stdlib.h> |