abc_global.h 19.5 KB
Newer Older
Alan Mishchenko committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/**CFile****************************************************************

  FileName    [abc_global.h]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [Global declarations.]

  Synopsis    [Global declarations.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - Jan 30, 2009.]

  Revision    [$Id: abc_global.h,v 1.00 2009/01/30 00:00:00 alanmi Exp $]

***********************************************************************/
20

21 22
#ifndef ABC__misc__util__abc_global_h
#define ABC__misc__util__abc_global_h
Alan Mishchenko committed
23 24 25 26

////////////////////////////////////////////////////////////////////////
///                          INCLUDES                                ///
////////////////////////////////////////////////////////////////////////
27

28 29 30 31
#ifndef ABC_USE_BRIDGE
#define ABC_USE_BRIDGE
#endif

Alan Mishchenko committed
32
#ifdef _WIN32
33
#ifndef __MINGW32__
Alan Mishchenko committed
34 35
#define inline __inline // compatible with MS VS 6.0
#pragma warning(disable : 4152) // warning C4152: nonstandard extension, function/data pointer conversion in expression
36
#pragma warning(disable : 4200) // warning C4200: nonstandard extension used : zero-sized array in struct/union
Alan Mishchenko committed
37 38 39 40 41
#pragma warning(disable : 4244) // warning C4244: '+=' : conversion from 'int ' to 'unsigned short ', possible loss of data
#pragma warning(disable : 4514) // warning C4514: 'Vec_StrPop' : unreferenced inline function has been removed
#pragma warning(disable : 4710) // warning C4710: function 'Vec_PtrGrow' not inlined
//#pragma warning( disable : 4273 )
#endif
42
#endif
Alan Mishchenko committed
43 44

#ifdef WIN32
45 46 47 48 49 50 51
  #ifdef WIN32_NO_DLL
    #define ABC_DLLEXPORT
    #define ABC_DLLIMPORT
  #else
    #define ABC_DLLEXPORT __declspec(dllexport)
    #define ABC_DLLIMPORT __declspec(dllimport)
  #endif
Alan Mishchenko committed
52 53 54 55 56 57 58 59
#else  /* defined(WIN32) */
#define ABC_DLLIMPORT
#endif /* defined(WIN32) */

#ifndef ABC_DLL
#define ABC_DLL ABC_DLLIMPORT
#endif

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
#if !defined(___unused)
#if defined(__GNUC__)
#define ___unused __attribute__ ((__unused__))
#else
#define ___unused
#endif
#endif

/*
#ifdef __cplusplus
#error "C++ code"
#else
#error "C code"
#endif
*/

#include <time.h>
#include <stdarg.h>
78
#include <stdlib.h>
79
#include <assert.h>
80
#include <stdio.h>
81
#include <string.h>
82

83 84 85 86 87 88 89 90
// catch memory leaks in Visual Studio
#ifdef WIN32
  #ifdef _DEBUG
    #define _CRTDBG_MAP_ALLOC
    #include <crtdbg.h>
  #endif
#endif

91
#include "abc_namespaces.h"
92

93 94 95 96 97
////////////////////////////////////////////////////////////////////////
///                         PARAMETERS                               ///
////////////////////////////////////////////////////////////////////////

ABC_NAMESPACE_HEADER_START
Alan Mishchenko committed
98 99 100 101 102

////////////////////////////////////////////////////////////////////////
///                         BASIC TYPES                              ///
////////////////////////////////////////////////////////////////////////

103
#ifdef ABC_USE_STDINT_H
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
// If there is stdint.h, assume this is a reasonably-modern platform that
// would also have stddef.h and limits.h
#include <limits.h>
#include <stddef.h>
#include <stdint.h>

#if UINTPTR_MAX == 0xFFFFFFFFFFFFFFFF
#define SIZEOF_VOID_P 8
#ifdef _WIN32
#define NT64
#else
#define LIN64
#endif
#elif UINTPTR_MAX == 0xFFFFFFFF
#define SIZEOF_VOID_P 4
#ifdef _WIN32
#define NT
#else
#define LIN
#endif
#else
   #error unsupported platform
#endif

#if ULONG_MAX == 0xFFFFFFFFFFFFFFFF
#define SIZEOF_LONG 8
#elif ULONG_MAX == 0xFFFFFFFF
#define SIZEOF_LONG 4
#else
   #error unsupported platform
#endif

#if UINT_MAX == 0xFFFFFFFFFFFFFFFF
#define SIZEOF_INT 8
#elif UINT_MAX == 0xFFFFFFFF
#define SIZEOF_INT 4
#else
   #error unsupported platform
#endif

#endif

Alan Mishchenko committed
146 147 148 149 150 151 152
/**
 * Pointer difference type; replacement for ptrdiff_t.
 * This is a signed integral type that is the same size as a pointer.
 * NOTE: This type may be different sizes on different platforms.
 */
#if       defined(__ccdoc__)
typedef platform_dependent_type ABC_PTRDIFF_T;
153
#elif     defined(ABC_USE_STDINT_H)
154
typedef ptrdiff_t ABC_PTRDIFF_T;
155
#elif     defined(LIN64)
Alan Mishchenko committed
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
typedef long ABC_PTRDIFF_T;
#elif     defined(NT64)
typedef long long ABC_PTRDIFF_T;
#elif     defined(NT) || defined(LIN) || defined(WIN32)
typedef int ABC_PTRDIFF_T;
#else
   #error unknown platform
#endif /* defined(PLATFORM) */

/**
 * Unsigned integral type that can contain a pointer.
 * This is an unsigned integral type that is the same size as a pointer.
 * NOTE: This type may be different sizes on different platforms.
 */
#if       defined(__ccdoc__)
typedef platform_dependent_type ABC_PTRUINT_T;
172
#elif     defined(ABC_USE_STDINT_H)
173
typedef uintptr_t ABC_PTRUINT_T;
174
#elif     defined(LIN64)
Alan Mishchenko committed
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
typedef unsigned long ABC_PTRUINT_T;
#elif     defined(NT64)
typedef unsigned long long ABC_PTRUINT_T;
#elif     defined(NT) || defined(LIN) || defined(WIN32)
typedef unsigned int ABC_PTRUINT_T;
#else
   #error unknown platform
#endif /* defined(PLATFORM) */

/**
 * Signed integral type that can contain a pointer.
 * This is a signed integral type that is the same size as a pointer.
 * NOTE: This type may be different sizes on different platforms.
 */
#if       defined(__ccdoc__)
typedef platform_dependent_type ABC_PTRINT_T;
191
#elif     defined(ABC_USE_STDINT_H)
192
typedef intptr_t ABC_PTRINT_T;
193
#elif     defined(LIN64)
Alan Mishchenko committed
194 195 196 197 198 199 200 201 202 203 204 205 206 207
typedef long ABC_PTRINT_T;
#elif     defined(NT64)
typedef long long ABC_PTRINT_T;
#elif     defined(NT) || defined(LIN) || defined(WIN32)
typedef int ABC_PTRINT_T;
#else
   #error unknown platform
#endif /* defined(PLATFORM) */

/**
 * 64-bit signed integral type.
 */
#if       defined(__ccdoc__)
typedef platform_dependent_type ABC_INT64_T;
208
#elif     defined(ABC_USE_STDINT_H)
209
typedef int64_t ABC_INT64_T;
210
#elif     defined(LIN64)
Alan Mishchenko committed
211 212 213 214 215 216 217 218 219 220 221 222 223 224
typedef long ABC_INT64_T;
#elif     defined(NT64) || defined(LIN)
typedef long long ABC_INT64_T;
#elif     defined(WIN32) || defined(NT)
typedef signed __int64 ABC_INT64_T;
#else
   #error unknown platform
#endif /* defined(PLATFORM) */

/**
 * 64-bit unsigned integral type.
 */
#if       defined(__ccdoc__)
typedef platform_dependent_type ABC_UINT64_T;
225
#elif     defined(ABC_USE_STDINT_H)
226
typedef uint64_t ABC_UINT64_T;
227
#elif     defined(LIN64)
Alan Mishchenko committed
228 229 230 231 232 233 234 235 236
typedef unsigned long ABC_UINT64_T;
#elif     defined(NT64) || defined(LIN)
typedef unsigned long long ABC_UINT64_T;
#elif     defined(WIN32) || defined(NT)
typedef unsigned __int64 ABC_UINT64_T;
#else
   #error unknown platform
#endif /* defined(PLATFORM) */

237 238 239 240 241 242
#ifdef LIN
  #define ABC_CONST(number) number ## ULL 
#else // LIN64 and windows
  #define ABC_CONST(number) number
#endif

243
typedef ABC_UINT64_T word;
244
typedef ABC_INT64_T iword;
245

Alan Mishchenko committed
246 247 248 249
////////////////////////////////////////////////////////////////////////
///                      MACRO DEFINITIONS                           ///
////////////////////////////////////////////////////////////////////////

250
#define ABC_INFINITY    (1000000000)
Alan Mishchenko committed
251

252 253
#define ABC_SWAP(Type, a, b)  { Type t = a; a = b; b = t; }

254 255 256 257 258 259 260 261
#define ABC_PRT(a,t)    (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%9.2f sec\n", 1.0*((double)(t))/((double)CLOCKS_PER_SEC)))
#define ABC_PRTr(a,t)   (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%9.2f sec\r", 1.0*((double)(t))/((double)CLOCKS_PER_SEC)))
#define ABC_PRTn(a,t)   (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%9.2f sec  ", 1.0*((double)(t))/((double)CLOCKS_PER_SEC)))
#define ABC_PRTP(a,t,T) (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%9.2f sec (%6.2f %%)\n", 1.0*((double)(t))/((double)CLOCKS_PER_SEC), ((double)(T))? 100.0*((double)(t))/((double)(T)) : 0.0))
#define ABC_PRM(a,f)    (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%10.3f MB\n",    1.0*((double)(f))/(1<<20)))
#define ABC_PRMr(a,f)   (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%10.3f MB\r",    1.0*((double)(f))/(1<<20)))
#define ABC_PRMn(a,f)   (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%10.3f MB  ",    1.0*((double)(f))/(1<<20)))
#define ABC_PRMP(a,f,F) (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%10.3f MB (%6.2f %%)\n",  (1.0*((double)(f))/(1<<20)), (((double)(F))? 100.0*((double)(f))/((double)(F)) : 0.0) ) )
Alan Mishchenko committed
262

263 264 265
#define ABC_ALLOC(type, num)     ((type *) malloc(sizeof(type) * (size_t)(num)))
#define ABC_CALLOC(type, num)    ((type *) calloc((size_t)(num), sizeof(type)))
#define ABC_FALLOC(type, num)    ((type *) memset(malloc(sizeof(type) * (size_t)(num)), 0xff, sizeof(type) * (size_t)(num)))
266 267
#define ABC_FREE(obj)            ((obj) ? (free((char *) (obj)), (obj) = 0) : 0)
#define ABC_REALLOC(type, obj, num) \
268 269
        ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (size_t)(num))) : \
         ((type *) malloc(sizeof(type) * (size_t)(num))))
Alan Mishchenko committed
270

271 272 273 274 275 276 277 278 279 280 281 282 283 284
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;         }
285 286
static inline word     Abc_Dbl2Word( double Dbl )             { union { word x; double y; } v; v.y = Dbl; return v.x;       }
static inline double   Abc_Word2Dbl( word Num )               { union { word x; double y; } v; v.x = Num; return v.y;       }
287 288 289
static inline int      Abc_Base2Log( unsigned n )             { int r; if ( n < 2 ) return (int)n; for ( r = 0, n--; n; n >>= 1, r++ ) {}; return r; }
static inline int      Abc_Base10Log( unsigned n )            { int r; if ( n < 2 ) return (int)n; for ( r = 0, n--; n; n /= 10, r++ ) {}; return r; }
static inline int      Abc_Base16Log( unsigned n )            { int r; if ( n < 2 ) return (int)n; for ( r = 0, n--; n; n /= 16, r++ ) {}; return r; }
290
static inline char *   Abc_UtilStrsav( char * s )             { return s ? strcpy(ABC_ALLOC(char, strlen(s)+1), s) : NULL;  }
291
static inline int      Abc_BitByteNum( int nBits )            { return (nBits>>3) + ((nBits&7)  > 0);                       }
292
static inline int      Abc_BitWordNum( int nBits )            { return (nBits>>5) + ((nBits&31) > 0);                       }
293
static inline int      Abc_Bit6WordNum( int nBits )           { return (nBits>>6) + ((nBits&63) > 0);                       }
294
static inline int      Abc_TruthByteNum( int nVars )          { return nVars <= 3 ? 1 : (1 << (nVars - 3));                 }
295
static inline int      Abc_TruthWordNum( int nVars )          { return nVars <= 5 ? 1 : (1 << (nVars - 5));                 }
296
static inline int      Abc_Truth6WordNum( int nVars )         { return nVars <= 6 ? 1 : (1 << (nVars - 6));                 }
297 298 299
static inline int      Abc_InfoHasBit( unsigned * p, int i )  { return (p[(i)>>5] & (unsigned)(1<<((i) & 31))) > 0;         }
static inline void     Abc_InfoSetBit( unsigned * p, int i )  { p[(i)>>5] |= (unsigned)(1<<((i) & 31));                     }
static inline void     Abc_InfoXorBit( unsigned * p, int i )  { p[(i)>>5] ^= (unsigned)(1<<((i) & 31));                     }
300 301
static inline unsigned Abc_InfoMask( int nVar )               { return (~(unsigned)0) >> (32-nVar);                         }

302 303 304 305 306 307 308 309
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) );   }
310

311 312 313 314
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;  }
315

316 317 318 319 320 321 322 323 324 325
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;         }

326
// time counting
327
typedef ABC_INT64_T abctime;
328
static inline abctime Abc_Clock()
329
{
330
#if (defined(LIN) || defined(LIN64)) && !(__APPLE__ & __MACH__) && !defined(__MINGW32__)
331 332 333 334 335 336 337 338 339
    struct timespec ts;
    if ( clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) < 0 ) 
        return (abctime)-1;
    abctime res = ((abctime) ts.tv_sec) * CLOCKS_PER_SEC;
    res += (((abctime) ts.tv_nsec) * CLOCKS_PER_SEC) / 1000000000;
    return res;
#else
    return (abctime) clock();
#endif
340
}
341

342 343

// misc printing procedures
344 345 346 347 348 349 350 351
enum Abc_VerbLevel
{
    ABC_PROMPT   = -2,
    ABC_ERROR    = -1,
    ABC_WARNING  =  0,
    ABC_STANDARD =  1,
    ABC_VERBOSE  =  2
};
352 353 354 355 356 357 358 359 360 361 362 363 364 365


#ifdef ABC_USE_BRIDGE

// bridge communication
#define BRIDGE_NETLIST           106
#define BRIDGE_ABS_NETLIST       107
extern int Gia_ManToBridgeText( FILE * pFile, int Size, unsigned char * pBuffer );
extern int Gia_ManToBridgeAbsNetlist( FILE * pFile, void * p, int pkg_type );

// string printing
extern char * vnsprintf(const char* format, va_list args);
extern char * nsprintf(const char* format, ...);

366
static inline void Abc_Print( int level, const char * format, ... )
367
{
368
    extern ABC_DLL int Abc_FrameIsBridgeMode();
369
    va_list args;
370 371 372
    extern unsigned enable_dbg_outs;  
    if ( !enable_dbg_outs )
        return;
373 374 375 376 377 378 379 380

    if ( ! Abc_FrameIsBridgeMode() ){
        if ( level == ABC_ERROR )
            printf( "Error: " );
        else if ( level == ABC_WARNING )
            printf( "Warning: " );
    }else{
        if ( level == ABC_ERROR )
Alan Mishchenko committed
381
            Gia_ManToBridgeText( stdout, (int)strlen("Error: "), (unsigned char*)"Error: " );
382
        else if ( level == ABC_WARNING )
Alan Mishchenko committed
383
            Gia_ManToBridgeText( stdout, (int)strlen("Warning: "), (unsigned char*)"Warning: " );
384 385
    }

386
    va_start( args, format );
387
    if ( Abc_FrameIsBridgeMode() )
388
    {
389
        char * tmp = vnsprintf( format, args );
Alan Mishchenko committed
390
        Gia_ManToBridgeText( stdout, (int)strlen(tmp), (unsigned char*)tmp );
391 392 393 394
        free( tmp );
    }
    else
        vprintf( format, args );
395
    va_end( args );
396
}
397

398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
#else

static inline void Abc_Print( int level, const char * format, ... )
{
    va_list args;
    va_start( args, format );
    if ( level == ABC_ERROR )
        printf( "Error: " );
    else if ( level == ABC_WARNING )
        printf( "Warning: " );
    vprintf( format, args );
    va_end( args );
}

#endif


415 416
static inline void Abc_PrintInt( int i )
{
417 418 419
    double v3 = (double)i/1000;
    double v6 = (double)i/1000000;

420
    Abc_Print( 1,  "  " );
421

422 423
    if ( i > -1000 && i < 1000 )
        Abc_Print( 1, " %4d", i );
424

425
    else if ( v3 > -9.995 && v3 < 9.995 )
426
        Abc_Print( 1, "%4.2fk", v3 );
427
    else if ( v3 > -99.95 && v3 < 99.95 )
428
        Abc_Print( 1, "%4.1fk", v3 );
429
    else if ( v3 > -999.5 && v3 < 999.5 )
430
        Abc_Print( 1, "%4.0fk", v3 );
431 432

    else if ( v6 > -9.995 && v6 < 9.995 )
433
        Abc_Print( 1, "%4.2fm", v6 );
434
    else if ( v6 > -99.95 && v6 < 99.95 )
435
        Abc_Print( 1, "%4.1fm", v6 );
436
    else if ( v6 > -999.5 && v6 < 999.5 )
437
        Abc_Print( 1, "%4.0fm", v6 );
438 439
}

440

441
static inline void Abc_PrintTime( int level, const char * pStr, abctime time )
442 443
{
    ABC_PRT( pStr, time );
Alan Mishchenko committed
444
}
445

446
static inline void Abc_PrintTimeP( int level, const char * pStr, abctime time, abctime Time )
447 448 449 450
{
    ABC_PRTP( pStr, time, Time );
}

451
static inline void Abc_PrintMemoryP( int level, const char * pStr, int mem, int Mem )
452
{
453
    ABC_PRMP( pStr, mem, Mem );
454 455
}

456 457 458 459 460 461 462
// Returns the next prime >= p
static inline int Abc_PrimeCudd( unsigned int p )
{
    int i,pn;
    p--;
    do {
        p++;
463
        if (p&1)
464 465 466
        {
            pn = 1;
            i = 3;
467
            while ((unsigned) (i * i) <= p)
468
            {
469
                if (p % (unsigned)i == 0) {
470 471 472 473 474
                    pn = 0;
                    break;
                }
                i += 2;
            }
475 476
        }
        else
477 478
            pn = 0;
    } while (!pn);
479
    return (int)(p);
480 481 482

} // end of Cudd_Prime 

483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504
// the returned buffer has 32 unused bytes at the end, filled with zeros
static inline void * Abc_FileReadContents( char * pFileName, int * pnFileSize )
{
    int RetValue, nFileSize;
    char * pBuffer;
    FILE * pFile = fopen( pFileName, "rb" );
    if ( pFile == NULL )
        return NULL;
    // get the file size, in bytes
    fseek( pFile, 0, SEEK_END );
    nFileSize = ftell( pFile );
    if ( pnFileSize )
        *pnFileSize = nFileSize;
    rewind( pFile );
    // load the contents of the file into memory
    pBuffer = ABC_ALLOC( char, nFileSize + 32 );
    RetValue = fread( pBuffer, 1, nFileSize, pFile );
    memset( pBuffer + nFileSize, 0, 32 );
    assert( RetValue == nFileSize );
    fclose( pFile );
    return (void *)pBuffer;
}
Alan Mishchenko committed
505 506 507 508 509 510
static inline void Abc_ReverseOrder( int * pA, int nA )
{
    int i;
    for ( i = 0; i < nA/2; i++ )
        ABC_SWAP( int, pA[i], pA[nA-1-i] );
}
511

512

513 514 515
// sorting
extern void   Abc_MergeSort( int * pInput, int nSize );
extern int *  Abc_MergeSortCost( int * pCosts, int nSize );
516 517 518 519 520
extern void   Abc_QuickSort1( word * pData, int nSize, int fDecrease );
extern void   Abc_QuickSort2( word * pData, int nSize, int fDecrease );
extern void   Abc_QuickSort3( word * pData, int nSize, int fDecrease );
extern void   Abc_QuickSortCostData( int * pCosts, int nSize, int fDecrease, word * pData, int * pResult );
extern int *  Abc_QuickSortCost( int * pCosts, int nSize, int fDecrease );
521

522 523
extern unsigned Abc_Random( int fReset );
extern word     Abc_RandomW( int fReset );
524

525
ABC_NAMESPACE_HEADER_END
Alan Mishchenko committed
526 527 528 529 530 531

#endif

////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////