--- /dev/null
+/**CFile****************************************************************\r
+\r
+ FileName [vec.h]\r
+\r
+ SystemName [ABC: Logic synthesis and verification system.]\r
+\r
+ PackageName [Resizable arrays.]\r
+\r
+ Synopsis [External declarations.]\r
+\r
+ Author [Alan Mishchenko]\r
+ \r
+ Affiliation [UC Berkeley]\r
+\r
+ Date [Ver. 1.0. Started - June 20, 2005.]\r
+\r
+ Revision [$Id: vec.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]\r
+\r
+***********************************************************************/\r
+ \r
+#ifndef __VEC_H__\r
+#define __VEC_H__\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+#ifdef _WIN32\r
+#define inline __inline // compatible with MS VS 6.0\r
+#pragma warning(disable : 4152) // warning C4152: nonstandard extension, function/data pointer conversion in expression\r
+#pragma warning(disable : 4244) // warning C4244: '+=' : conversion from 'int ' to 'unsigned short ', possible loss of data\r
+#pragma warning(disable : 4514) // warning C4514: 'Vec_StrPop' : unreferenced inline function has been removed\r
+#pragma warning(disable : 4710) // warning C4710: function 'Vec_PtrGrow' not inlined\r
+#endif\r
+\r
+////////////////////////////////////////////////////////////////////////\r
+/// INCLUDES ///\r
+////////////////////////////////////////////////////////////////////////\r
+\r
+// this include should be the first one in the list\r
+// it is used to catch memory leaks on Windows\r
+#include "leaks.h" \r
+\r
+////////////////////////////////////////////////////////////////////////\r
+/// MACRO DEFINITIONS ///\r
+////////////////////////////////////////////////////////////////////////\r
+\r
+#ifndef ABS\r
+#define ABS(a) ((a) < 0 ? -(a) : (a))\r
+#endif\r
+\r
+#ifndef MAX\r
+#define MAX(a,b) ((a) > (b) ? (a) : (b))\r
+#endif\r
+\r
+#ifndef MIN\r
+#define MIN(a,b) ((a) < (b) ? (a) : (b))\r
+#endif\r
+\r
+#ifndef ALLOC\r
+#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num)))\r
+#endif\r
+\r
+#ifndef FREE\r
+#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0)\r
+#endif\r
+\r
+#ifndef REALLOC\r
+#define REALLOC(type, obj, num) \\r
+ ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \\r
+ ((type *) malloc(sizeof(type) * (num))))\r
+#endif\r
+\r
+#ifndef PRT\r
+#define PRT(a,t) printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))\r
+#endif\r
+\r
+#ifndef PRTP\r
+#define PRTP(a,t,T) printf("%s = ", (a)); printf("%6.2f sec (%6.2f %%)\n", (float)(t)/(float)(CLOCKS_PER_SEC), (T)? 100.0*(t)/(T) : 0.0)\r
+#endif\r
+\r
+#include "vecInt.h"\r
+#include "vecFlt.h"\r
+#include "vecStr.h"\r
+#include "vecPtr.h"\r
+#include "vecVec.h"\r
+\r
+////////////////////////////////////////////////////////////////////////\r
+/// PARAMETERS ///\r
+////////////////////////////////////////////////////////////////////////\r
+\r
+////////////////////////////////////////////////////////////////////////\r
+/// BASIC TYPES ///\r
+////////////////////////////////////////////////////////////////////////\r
+\r
+////////////////////////////////////////////////////////////////////////\r
+/// FUNCTION DECLARATIONS ///\r
+////////////////////////////////////////////////////////////////////////\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif\r
+\r
+////////////////////////////////////////////////////////////////////////\r
+/// END OF FILE ///\r
+////////////////////////////////////////////////////////////////////////\r
+\r
+++ /dev/null
-/**CFile****************************************************************\r
-\r
- FileName [vecAtt.h]\r
-\r
- SystemName [ABC: Logic synthesis and verification system.]\r
-\r
- PackageName [Resizable arrays.]\r
-\r
- Synopsis [Array of user-specified attiributes.]\r
-\r
- Author [Alan Mishchenko]\r
- \r
- Affiliation [UC Berkeley]\r
-\r
- Date [Ver. 1.0. Started - June 20, 2005.]\r
-\r
- Revision [$Id: vecAtt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]\r
-\r
-***********************************************************************/\r
- \r
-#ifndef __Vec_Att_H__\r
-#define __Vec_Att_H__\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-/// INCLUDES ///\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-#include <stdio.h>\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-/// PARAMETERS ///\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-// various attributes\r
-typedef enum { \r
- VEC_ATTR_NONE = 0, // 0\r
- VEC_ATTR_COPY, // 1\r
- VEC_ATTR_LOCAL_AIG, // 2\r
- VEC_ATTR_LOCAL_SOP, // 3\r
- VEC_ATTR_LOCAL_BDD, // 4\r
- VEC_ATTR_GLOBAL_AIG, // 5\r
- VEC_ATTR_GLOBAL_SOP, // 6\r
- VEC_ATTR_GLOBAL_BDD, // 7\r
- VEC_ATTR_LEVEL, // 8\r
- VEC_ATTR_LEVEL_REV, // 9\r
- VEC_ATTR_RETIME_LAG, // 10\r
- VEC_ATTR_FRAIG, // 11\r
- VEC_ATTR_MVVAR, // 12\r
- VEC_ATTR_DATA1, // 13\r
- VEC_ATTR_DATA2, // 14\r
- VEC_ATTR_TOTAL_NUM // 15\r
-} Vec_AttrType_t;\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-/// BASIC TYPES ///\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-typedef struct Vec_Att_t_ Vec_Att_t;\r
-struct Vec_Att_t_ \r
-{\r
- // storage for attributes\r
- int nCap; // the size of array allocated\r
- int * pArrayInt; // the integer attribute array\r
- void ** pArrayPtr; // the pointer attribute array\r
- // attribute specific info\r
- void * pMan; // the manager for this attribute\r
- void (*pFuncFreeMan) (void *); // the procedure to free the manager\r
- void*(*pFuncStartObj)(void *); // the procedure to start one attribute\r
- void (*pFuncFreeObj) (void *, void *); // the procedure to free one attribute\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-/// MACRO DEFINITIONS ///\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-/// FUNCTION DEFINITIONS ///\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-/**Function*************************************************************\r
-\r
- Synopsis [Allocates a vector with the given capacity.]\r
-\r
- Description []\r
- \r
- SideEffects []\r
-\r
- SeeAlso []\r
-\r
-***********************************************************************/\r
-static inline Vec_Att_t * Vec_AttAlloc( \r
- int fInteger, int nSize, void * pMan, \r
- void (*pFuncFreeMan) (void *), \r
- void*(*pFuncStartObj)(void *), \r
- void (*pFuncFreeObj) (void *, void *) )\r
-{\r
- Vec_Att_t * p;\r
- p = ALLOC( Vec_Att_t, 1 );\r
- memset( p, 0, sizeof(Vec_Att_t) );\r
- p->pMan = pMan;\r
- p->pFuncFreeMan = pFuncFreeMan;\r
- p->pFuncStartObj = pFuncStartObj;\r
- p->pFuncFreeObj = pFuncFreeObj;\r
- p->nCap = nSize? nSize : 16;\r
- if ( fInteger )\r
- {\r
- p->pArrayInt = ALLOC( int, p->nCap );\r
- memset( p->pArrayInt, 0xff, sizeof(int) * p->nCap );\r
- }\r
- else\r
- {\r
- p->pArrayPtr = ALLOC( void *, p->nCap );\r
- memset( p->pArrayPtr, 0, sizeof(void *) * p->nCap );\r
- }\r
- return p;\r
-}\r
-\r
-/**Function*************************************************************\r
-\r
- Synopsis [Frees the vector.]\r
-\r
- Description []\r
- \r
- SideEffects []\r
-\r
- SeeAlso []\r
-\r
-***********************************************************************/\r
-static inline void * Vec_AttFree( Vec_Att_t * p, int fFreeMan )\r
-{\r
- void * pMan;\r
- if ( p == NULL )\r
- return NULL;\r
- // free the attributes of objects\r
- if ( p->pFuncFreeObj )\r
- {\r
- int i;\r
- if ( p->pArrayInt )\r
- {\r
- /* This code would not work on a 64-bit platform,\r
- so let's hope it's unused. Though I've added a (long)\r
- cast below to silence a relevant GCC warning. */\r
- assert(sizeof(int) == sizeof(void *));\r
- for ( i = 0; i < p->nCap; i++ )\r
- if ( p->pArrayInt[i] )\r
- p->pFuncFreeObj( p->pMan, (void *)(long)p->pArrayInt[i] );\r
- }\r
- else\r
- {\r
- for ( i = 0; i < p->nCap; i++ )\r
- if ( p->pArrayPtr[i] )\r
- p->pFuncFreeObj( p->pMan, p->pArrayPtr[i] );\r
- }\r
- }\r
- // free the memory manager\r
- pMan = fFreeMan? NULL : p->pMan;\r
- if ( p->pMan && fFreeMan ) \r
- p->pFuncFreeMan( p->pMan );\r
- FREE( p->pArrayInt );\r
- FREE( p->pArrayPtr );\r
- FREE( p );\r
- return pMan;\r
-}\r
-\r
-/**Function*************************************************************\r
-\r
- Synopsis [Clears the vector.]\r
-\r
- Description []\r
- \r
- SideEffects []\r
-\r
- SeeAlso []\r
-\r
-***********************************************************************/\r
-static inline void Vec_AttClear( Vec_Att_t * p )\r
-{\r
- // free the attributes of objects\r
- if ( p->pFuncFreeObj )\r
- {\r
- int i;\r
- if ( p->pArrayInt )\r
- {\r
- if ( p->pFuncFreeObj ) {\r
- /* This code would not work on a 64-bit platform,\r
- so let's hope it's unused. Though I've added a (long)\r
- cast below to silence a relevant GCC warning. */\r
- assert(sizeof(int) == sizeof(void *));\r
- for ( i = 0; i < p->nCap; i++ )\r
- if ( p->pArrayInt[i] )\r
- p->pFuncFreeObj( p->pMan, (void *)(long)p->pArrayInt[i] );\r
- }\r
- }\r
- else\r
- {\r
- if ( p->pFuncFreeObj )\r
- for ( i = 0; i < p->nCap; i++ )\r
- if ( p->pArrayPtr[i] )\r
- p->pFuncFreeObj( p->pMan, p->pArrayPtr[i] );\r
- }\r
- }\r
- if ( p->pArrayInt )\r
- memset( p->pArrayInt, 0xff, sizeof(int) * p->nCap );\r
- else\r
- memset( p->pArrayPtr, 0, sizeof(void *) * p->nCap );\r
-\r
-}\r
-\r
-/**Function*************************************************************\r
-\r
- Synopsis [Deletes one entry from the attribute manager.]\r
-\r
- Description []\r
- \r
- SideEffects []\r
-\r
- SeeAlso []\r
-\r
-***********************************************************************/\r
-static inline void Vec_AttFreeEntry( Vec_Att_t * p, int i )\r
-{\r
- if ( i >= p->nCap )\r
- return;\r
- if ( p->pMan )\r
- {\r
- if ( p->pArrayInt[i] && p->pFuncFreeObj ) {\r
- /* This code would not work on a 64-bit platform,\r
- so let's hope it's unused. Though I've added a (long)\r
- cast below to silence a relevant GCC warning. */\r
- assert(sizeof(int) == sizeof(void *));\r
- p->pFuncFreeObj( p->pMan, (void *)(long)p->pArrayInt[i] );\r
- }\r
- if ( p->pArrayPtr[i] && p->pFuncFreeObj )\r
- p->pFuncFreeObj( p->pMan, (void *)p->pArrayPtr[i] );\r
- }\r
- if ( p->pArrayInt )\r
- p->pArrayInt[i] = ~(unsigned)0;\r
- else\r
- p->pArrayPtr[i] = NULL;\r
-}\r
-\r
-/**Function*************************************************************\r
-\r
- Synopsis [Resizes the vector to the given capacity.]\r
-\r
- Description []\r
- \r
- SideEffects []\r
-\r
- SeeAlso []\r
-\r
-***********************************************************************/\r
-static inline void Vec_AttGrow( Vec_Att_t * p, int nCapMin )\r
-{\r
- if ( p->nCap >= nCapMin )\r
- return;\r
- if ( p->pArrayInt )\r
- {\r
- p->pArrayInt = REALLOC( int, p->pArrayInt, nCapMin ); \r
- memset( p->pArrayInt + p->nCap, 0xff, sizeof(int) * (nCapMin - p->nCap) );\r
- }\r
- else\r
- {\r
- p->pArrayPtr = REALLOC( void *, p->pArrayPtr, nCapMin ); \r
- memset( p->pArrayPtr + p->nCap, 0, sizeof(void *) * (nCapMin - p->nCap) );\r
- }\r
- p->nCap = nCapMin;\r
-}\r
-\r
-/**Function*************************************************************\r
-\r
- Synopsis [Writes the entry into its place.]\r
-\r
- Description [Only works if the manager is not defined.]\r
- \r
- SideEffects []\r
-\r
- SeeAlso []\r
-\r
-***********************************************************************/\r
-static inline void Vec_AttWriteEntry( Vec_Att_t * p, int i, void * pEntry )\r
-{\r
- assert( p->pArrayPtr );\r
- assert( p->pFuncStartObj == NULL );\r
- if ( i >= p->nCap )\r
- Vec_AttGrow( p, (2 * p->nCap > i)? 2 * p->nCap : i + 10 );\r
- p->pArrayPtr[i] = pEntry;\r
-}\r
-\r
-/**Function*************************************************************\r
-\r
- Synopsis [Writes the entry into its place.]\r
-\r
- Description [Only works if the manager is not defined.]\r
- \r
- SideEffects []\r
-\r
- SeeAlso []\r
-\r
-***********************************************************************/\r
-static inline void Vec_AttWriteEntryInt( Vec_Att_t * p, int i, int Entry )\r
-{\r
- assert( p->pArrayInt );\r
- assert( p->pFuncStartObj == NULL );\r
- if ( i >= p->nCap )\r
- Vec_AttGrow( p, (2 * p->nCap > i)? 2 * p->nCap : i + 10 );\r
- p->pArrayInt[i] = Entry;\r
-}\r
-\r
-/**Function*************************************************************\r
-\r
- Synopsis [Returns the entry.]\r
-\r
- Description []\r
- \r
- SideEffects []\r
-\r
- SeeAlso []\r
-\r
-***********************************************************************/\r
-static inline void * Vec_AttEntry( Vec_Att_t * p, int i )\r
-{\r
- assert( p->pArrayPtr );\r
- if ( i >= p->nCap )\r
- Vec_AttGrow( p, (2 * p->nCap > i)? 2 * p->nCap : i + 10 );\r
- if ( p->pArrayPtr[i] == NULL && p->pFuncStartObj )\r
- p->pArrayPtr[i] = p->pFuncStartObj( p->pMan );\r
- return p->pArrayPtr[i];\r
-}\r
-\r
-/**Function*************************************************************\r
-\r
- Synopsis [Returns the entry.]\r
-\r
- Description []\r
- \r
- SideEffects []\r
-\r
- SeeAlso []\r
-\r
-***********************************************************************/\r
-static inline int Vec_AttEntryInt( Vec_Att_t * p, int i )\r
-{\r
- assert( p->pArrayInt );\r
- assert( p->pMan == NULL );\r
- if ( i >= p->nCap )\r
- Vec_AttGrow( p, (2 * p->nCap > i)? 2 * p->nCap : i + 10 );\r
- return p->pArrayInt[i];\r
-}\r
-\r
-/**Function*************************************************************\r
-\r
- Synopsis [Returns the entry.]\r
-\r
- Description []\r
- \r
- SideEffects []\r
-\r
- SeeAlso []\r
-\r
-***********************************************************************/\r
-static inline void * Vec_AttMan( Vec_Att_t * p )\r
-{\r
- return p->pMan;\r
-}\r
-\r
-/**Function*************************************************************\r
-\r
- Synopsis [Returns the array of attributes.]\r
-\r
- Description []\r
- \r
- SideEffects []\r
-\r
- SeeAlso []\r
-\r
-***********************************************************************/\r
-static inline void ** Vec_AttArray( Vec_Att_t * p )\r
-{\r
- return p->pArrayPtr;\r
-}\r
-\r
-/**Function*************************************************************\r
-\r
- Synopsis [Returns the array of attributes.]\r
-\r
- Description []\r
- \r
- SideEffects []\r
-\r
- SeeAlso []\r
-\r
-***********************************************************************/\r
-static inline int * Vec_AttArrayInt( Vec_Att_t * p )\r
-{\r
- return p->pArrayInt;\r
-}\r
-\r
-#endif\r
-\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-/// END OF FILE ///\r
-////////////////////////////////////////////////////////////////////////\r
-\r