diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2009-02-15 08:01:00 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2009-02-15 08:01:00 -0800 |
commit | 0871bffae307e0553e0c5186336189e8b55cf6a6 (patch) | |
tree | 4571d1563fe33a53a57fea1c35fb668b9d33265f /src/base/main | |
parent | f936cc0680c98ffe51b3a1716c996072d5dbf76c (diff) | |
download | abc-0871bffae307e0553e0c5186336189e8b55cf6a6.tar.gz abc-0871bffae307e0553e0c5186336189e8b55cf6a6.tar.bz2 abc-0871bffae307e0553e0c5186336189e8b55cf6a6.zip |
Version abc90215
Diffstat (limited to 'src/base/main')
-rw-r--r-- | src/base/main/libSupport.c | 15 | ||||
-rw-r--r-- | src/base/main/main.c | 10 | ||||
-rw-r--r-- | src/base/main/main.h | 27 | ||||
-rw-r--r-- | src/base/main/mainFrame.c | 4 | ||||
-rw-r--r-- | src/base/main/mainInt.h | 13 | ||||
-rw-r--r-- | src/base/main/mainUtils.c | 28 |
6 files changed, 38 insertions, 59 deletions
diff --git a/src/base/main/libSupport.c b/src/base/main/libSupport.c index 471ea09e..6bffc2bd 100644 --- a/src/base/main/libSupport.c +++ b/src/base/main/libSupport.c @@ -18,9 +18,10 @@ ***********************************************************************/ -#include "mainInt.h" #include <stdio.h> #include <string.h> +#include "mainInt.h" +#include "abc_global.h" #ifndef WIN32 # include <sys/types.h> @@ -50,10 +51,10 @@ void open_libs() { env = getenv ("ABC_LIB_PATH"); if (env == NULL) { // printf("Warning: ABC_LIB_PATH not defined. Looking into the current directory.\n"); - init_p = malloc (2*sizeof(char)); + init_p = ABC_ALLOC( char, (2*sizeof(char)) ); init_p[0]='.'; init_p[1] = 0; } else { - init_p = malloc ((strlen(env)+1)*sizeof(char)); + init_p = ABC_ALLOC( char, ((strlen(env)+1)*sizeof(char)) ); strcpy (init_p, env); } @@ -84,8 +85,8 @@ void open_libs() { // attempt to load it else { - char* szPrefixed = malloc((strlen(dp->d_name) + strlen(p) + 2) * - sizeof(char)); + char* szPrefixed = ABC_ALLOC( char, ((strlen(dp->d_name) + strlen(p) + 2) * + sizeof(char)) ); sprintf(szPrefixed, "%s/", p); strcat(szPrefixed, dp->d_name); libHandles[curr_lib] = dlopen(szPrefixed, RTLD_NOW | RTLD_LOCAL); @@ -98,7 +99,7 @@ void open_libs() { printf("Warning: failed to load ABC library %s:\n\t%s\n", szPrefixed, dlerror()); } - free(szPrefixed); + ABC_FREE(szPrefixed); } } } @@ -106,7 +107,7 @@ void open_libs() { p = endp+1; } - free(init_p); + ABC_FREE(init_p); #endif // null terminate the list of handles diff --git a/src/base/main/main.c b/src/base/main/main.c index a9d610fd..3aee2e44 100644 --- a/src/base/main/main.c +++ b/src/base/main/main.c @@ -21,7 +21,7 @@ #include "mainInt.h" // this line should be included in the library project -//#define _LIB +//#define ABC_LIB //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// @@ -33,7 +33,7 @@ static int TypeCheck( Abc_Frame_t * pAbc, char * s); /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// -#ifndef _LIB +#ifndef ABC_LIB /**Function************************************************************* @@ -55,7 +55,7 @@ int main( int argc, char * argv[] ) bool fBatch, fInitSource, fInitRead, fFinalWrite; // added to detect memory leaks: -#if defined(_DEBUG) && defined(_MSC_VER) && (_MSC_VER <= 1200) // 1200 = MSVC 6.0 +#if defined(_DEBUG) && defined(_MSC_VER) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif @@ -190,7 +190,7 @@ int main( int argc, char * argv[] ) } } - else + else { // start interactive mode // print the hello line @@ -254,7 +254,7 @@ void Abc_Start() { Abc_Frame_t * pAbc; // added to detect memory leaks: -#if defined(_DEBUG) && defined(_MSC_VER) && (_MSC_VER <= 1200) // 1200 = MSVC 6.0 +#if defined(_DEBUG) && defined(_MSC_VER) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif // start the glocal frame diff --git a/src/base/main/main.h b/src/base/main/main.h index 159122d2..0c5aeb3e 100644 --- a/src/base/main/main.h +++ b/src/base/main/main.h @@ -21,18 +21,10 @@ #ifndef __MAIN_H__ #define __MAIN_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// TYPEDEFS /// //////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// -/// STRUCTURE DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - // the framework containing all data typedef struct Abc_Frame_t_ Abc_Frame_t; @@ -54,11 +46,19 @@ typedef struct Abc_Frame_t_ Abc_Frame_t; /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// GLOBAL VARIABLES /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// +/// STRUCTURE DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// /// MACRO DEFINITIONS /// //////////////////////////////////////////////////////////////////////// @@ -66,17 +66,6 @@ typedef struct Abc_Frame_t_ Abc_Frame_t; /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// -#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 - /*=== main.c ===========================================================*/ extern ABC_DLL void Abc_Start(); extern ABC_DLL void Abc_Stop(); diff --git a/src/base/main/mainFrame.c b/src/base/main/mainFrame.c index 23e9184e..31e0afa9 100644 --- a/src/base/main/mainFrame.c +++ b/src/base/main/mainFrame.c @@ -102,7 +102,7 @@ Abc_Frame_t * Abc_FrameAllocate() extern void define_cube_size( int n ); extern void set_espresso_flags(); // allocate and clean - p = ALLOC( Abc_Frame_t, 1 ); + p = ABC_ALLOC( Abc_Frame_t, 1 ); memset( p, 0, sizeof(Abc_Frame_t) ); // get version p->sVersion = Abc_UtilsGetVersion( p ); @@ -149,7 +149,7 @@ void Abc_FrameDeallocate( Abc_Frame_t * p ) if ( p->dd ) Extra_StopManager( p->dd ); if ( p->vStore ) Vec_PtrFree( p->vStore ); Abc_FrameDeleteAllNetworks( p ); - free( p ); + ABC_FREE( p ); s_GlobalFrame = NULL; } diff --git a/src/base/main/mainInt.h b/src/base/main/mainInt.h index cfd945b7..e234d674 100644 --- a/src/base/main/mainInt.h +++ b/src/base/main/mainInt.h @@ -26,7 +26,6 @@ //////////////////////////////////////////////////////////////////////// #include "main.h" -#include "port_type.h" //////////////////////////////////////////////////////////////////////// /// PARAMETERS /// @@ -80,6 +79,7 @@ struct Abc_Frame_t_ void * pAbc8Nwk; // the current mapped network void * pAbc8Aig; // the current AIG void * pAbc8Lib; // the current LUT library + void * pAig; // the addition to keep the best Ntl that can be used to restore void * pAbc8NtlBestDelay; // the best delay, Ntl @@ -99,17 +99,6 @@ struct Abc_Frame_t_ /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// -#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 - /*=== mvMain.c ===========================================================*/ extern ABC_DLL int main( int argc, char * argv[] ); /*=== mvInit.c ===================================================*/ diff --git a/src/base/main/mainUtils.c b/src/base/main/mainUtils.c index 46469490..f6751b6b 100644 --- a/src/base/main/mainUtils.c +++ b/src/base/main/mainUtils.c @@ -76,7 +76,7 @@ char * Abc_UtilsGetUsersInput( Abc_Frame_t * pAbc ) fgets( Prompt, 999, stdin ); return Prompt; #else - if (line != NULL) free(line); + if (line != NULL) ABC_FREE(line); line = readline(Prompt); if (line == NULL){ printf("***EOF***\n"); exit(0); } add_history(line); @@ -173,8 +173,8 @@ void Abc_UtilsSource( Abc_Frame_t * pAbc ) (void) Cmd_CommandExecute(pAbc, "source -s .rc"); } } - if ( sPath1 ) FREE(sPath1); - if ( sPath2 ) FREE(sPath2); + if ( sPath1 ) ABC_FREE(sPath1); + if ( sPath2 ) ABC_FREE(sPath2); /* execute the abc script which can be open with the "open_path" */ Cmd_CommandExecute( pAbc, "source -s abc.rc" ); @@ -189,10 +189,10 @@ void Abc_UtilsSource( Abc_Frame_t * pAbc ) // it from the home directory. Otherwise, read it from wherever it's located. home = getenv("HOME"); if (home){ - char * sPath3 = ALLOC(char, strlen(home) + 2); + char * sPath3 = ABC_ALLOC(char, strlen(home) + 2); (void) sprintf(sPath3, "%s/", home); sPath1 = Extra_UtilFileSearch(".abc.rc", sPath3, "r"); - FREE(sPath3); + ABC_FREE(sPath3); }else sPath1 = NULL; @@ -200,30 +200,30 @@ void Abc_UtilsSource( Abc_Frame_t * pAbc ) if ( sPath1 && sPath2 ) { /* ~/.rc == .rc : Source the file only once */ - char *tmp_cmd = ALLOC(char, strlen(sPath1)+12); + char *tmp_cmd = ABC_ALLOC(char, strlen(sPath1)+12); (void) sprintf(tmp_cmd, "source -s %s", sPath1); // (void) Cmd_CommandExecute(pAbc, "source -s ~/.abc.rc"); (void) Cmd_CommandExecute(pAbc, tmp_cmd); - FREE(tmp_cmd); + ABC_FREE(tmp_cmd); } else { if (sPath1) { - char *tmp_cmd = ALLOC(char, strlen(sPath1)+12); + char *tmp_cmd = ABC_ALLOC(char, strlen(sPath1)+12); (void) sprintf(tmp_cmd, "source -s %s", sPath1); // (void) Cmd_CommandExecute(pAbc, "source -s ~/.abc.rc"); (void) Cmd_CommandExecute(pAbc, tmp_cmd); - FREE(tmp_cmd); + ABC_FREE(tmp_cmd); } if (sPath2) { - char *tmp_cmd = ALLOC(char, strlen(sPath2)+12); + char *tmp_cmd = ABC_ALLOC(char, strlen(sPath2)+12); (void) sprintf(tmp_cmd, "source -s %s", sPath2); // (void) Cmd_CommandExecute(pAbc, "source -s .abc.rc"); (void) Cmd_CommandExecute(pAbc, tmp_cmd); - FREE(tmp_cmd); + ABC_FREE(tmp_cmd); } } - if ( sPath1 ) FREE(sPath1); - if ( sPath2 ) FREE(sPath2); + if ( sPath1 ) ABC_FREE(sPath1); + if ( sPath2 ) ABC_FREE(sPath2); /* execute the abc script which can be open with the "open_path" */ Cmd_CommandExecute( pAbc, "source -s abc.rc" ); @@ -235,7 +235,7 @@ void Abc_UtilsSource( Abc_Frame_t * pAbc ) char * pName; int i; Vec_PtrForEachEntry( pAbc->aHistory, pName, i ) - free( pName ); + ABC_FREE( pName ); pAbc->aHistory->nSize = 0; } } |