diff options
Diffstat (limited to 'src/misc/util')
-rw-r--r-- | src/misc/util/abc_global.h | 178 | ||||
-rw-r--r-- | src/misc/util/port_type.h | 78 | ||||
-rw-r--r-- | src/misc/util/util_hack.h | 27 |
3 files changed, 183 insertions, 100 deletions
diff --git a/src/misc/util/abc_global.h b/src/misc/util/abc_global.h new file mode 100644 index 00000000..35a391ba --- /dev/null +++ b/src/misc/util/abc_global.h @@ -0,0 +1,178 @@ +/**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 $] + +***********************************************************************/ + +#ifndef __ABC_GLOBAL_H__ +#define __ABC_GLOBAL_H__ + +//////////////////////////////////////////////////////////////////////// +/// INCLUDES /// +//////////////////////////////////////////////////////////////////////// + +#ifdef _WIN32 +#define inline __inline // compatible with MS VS 6.0 +#pragma warning(disable : 4152) // warning C4152: nonstandard extension, function/data pointer conversion in expression +#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 + +#ifdef WIN32 +#define ABC_DLLEXPORT __declspec(dllexport) +#define ABC_DLLIMPORT __declspec(dllimport) +#else /* defined(WIN32) */ +#define ABC_DLLIMPORT +#endif /* defined(WIN32) */ + +#ifndef ABC_DLL +#define ABC_DLL ABC_DLLIMPORT +#endif + +// catch memory leaks in Visual Studio +#ifdef _DEBUG +#define _CRTDBG_MAP_ALLOC +#include <crtdbg.h> +#endif + +//////////////////////////////////////////////////////////////////////// +/// PARAMETERS /// +//////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif + +//////////////////////////////////////////////////////////////////////// +/// BASIC TYPES /// +//////////////////////////////////////////////////////////////////////// + +/** + * 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; +#elif defined(LIN64) +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; +#elif defined(LIN64) +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; +#elif defined(LIN64) +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; +#elif defined(LIN64) +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; +#elif defined(LIN64) +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) */ + +//////////////////////////////////////////////////////////////////////// +/// 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_ALLOC(type, num) ((type *) malloc(sizeof(type) * (num))) +#define ABC_CALLOC(type, num) ((type *) calloc((num), sizeof(type))) +#define ABC_FALLOC(type, num) ((type *) memset(malloc(sizeof(type) * (num)), 0xff, sizeof(type) * (num))) +#define ABC_FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0) +#define ABC_REALLOC(type, obj, num) \ + ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \ + ((type *) malloc(sizeof(type) * (num)))) + +#define ABC_PRT(a,t) (printf("%s = ", (a)), printf("%7.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))) +#define ABC_PRTn(a,t) (printf("%s = ", (a)), printf("%6.2f sec ", (float)(t)/(float)(CLOCKS_PER_SEC))) +#define ABC_PRTP(a,t,T) (printf("%s = ", (a)), printf("%7.2f sec (%6.2f %%)\n", (float)(t)/(float)(CLOCKS_PER_SEC), (T)? 100.0*(t)/(T) : 0.0)) +#define ABC_PRM(a,f) (printf("%s = ", (a)), printf("%7.2f Mb ", 1.0*(f)/(1<<20))) + +#ifdef __cplusplus +} +#endif + +#endif + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + diff --git a/src/misc/util/port_type.h b/src/misc/util/port_type.h deleted file mode 100644 index 67b7d454..00000000 --- a/src/misc/util/port_type.h +++ /dev/null @@ -1,78 +0,0 @@ -// Portable Data Types - -#ifndef __PORT_TYPE__ -#define __PORT_TYPE__ - -/** - * 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 PORT_PTRDIFF_T; -#elif defined(LIN64) -typedef long PORT_PTRDIFF_T; -#elif defined(NT64) -typedef long long PORT_PTRDIFF_T; -#elif defined(NT) || defined(LIN) || defined(WIN32) -typedef int PORT_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 PORT_PTRUINT_T; -#elif defined(LIN64) -typedef unsigned long PORT_PTRUINT_T; -#elif defined(NT64) -typedef unsigned long long PORT_PTRUINT_T; -#elif defined(NT) || defined(LIN) || defined(WIN32) -typedef unsigned int PORT_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 PORT_PTRINT_T; -#elif defined(LIN64) -typedef long PORT_PTRINT_T; -#elif defined(NT64) -typedef long long PORT_PTRINT_T; -#elif defined(NT) || defined(LIN) || defined(WIN32) -typedef int PORT_PTRINT_T; -#else - #error unknown platform -#endif /* defined(PLATFORM) */ - -/** - * 64-bit signed integral type. - */ -#if defined(__ccdoc__) -typedef platform_dependent_type PORT_INT64_T; -#elif defined(LIN64) -typedef long PORT_INT64_T; -#elif defined(NT64) || defined(LIN) -typedef long long PORT_INT64_T; -#elif defined(WIN32) || defined(NT) -typedef signed __int64 PORT_INT64_T; -#else - #error unknown platform -#endif /* defined(PLATFORM) */ - -#endif diff --git a/src/misc/util/util_hack.h b/src/misc/util/util_hack.h index 3fdb7ffb..825c8bee 100644 --- a/src/misc/util/util_hack.h +++ b/src/misc/util/util_hack.h @@ -21,16 +21,17 @@ #ifndef __UTIL_HACK_H__ #define __UTIL_HACK_H__ -#ifdef __cplusplus -extern "C" { -#endif - #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <time.h> #include <math.h> +#include "abc_global.h" + +#ifdef __cplusplus +extern "C" { +#endif #ifndef EXTERN #define EXTERN extern @@ -60,24 +61,6 @@ extern "C" { # endif #endif -#ifndef ABS -# define ABS(a) ((a) < 0 ? -(a) : (a)) -#endif - -#ifndef MAX -# define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef MIN -# define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - -#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num))) -#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0) -#define REALLOC(type, obj, num) \ - ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \ - ((type *) malloc(sizeof(type) * (num)))) - extern long Extra_CpuTime(); extern int Extra_GetSoftDataLimit(); extern void Extra_UtilGetoptReset(); |