Skip to content

Commit

Permalink
fix: dev: address toolchain requirement changes in cmd.c
Browse files Browse the repository at this point in the history
* add missing #define for scandir and friends on win32
* use more specific MSC define in opening ifdef

Signed-off-by: Stephen L Arnold <[email protected]>
  • Loading branch information
sarnold committed Dec 1, 2023
1 parent eb45ee9 commit ce15089
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/base/cmd/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Synopsis [Command file.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Expand All @@ -18,11 +18,13 @@
***********************************************************************/

#ifdef WIN32
#ifdef _MSC_VER
#include <process.h>
#else
#include <unistd.h>
// implicit declarations are no longer allowed
#define _GNU_SOURCE
#include <dirent.h>
#include <unistd.h>
#endif

#include "base/abc/abc.h"
Expand Down Expand Up @@ -1836,7 +1838,7 @@ int CmdCommandScrGen( Abc_Frame_t * pAbc, int argc, char **argv )

#else

Vec_Ptr_t * CmdReturnFileNames( char * pDirStr )
Vec_Ptr_t * CmdReturnFileNames( char * pDirStr )
{
Vec_Ptr_t * vRes = Vec_PtrAlloc( 100 );
struct dirent **namelist;
Expand All @@ -1848,7 +1850,7 @@ Vec_Ptr_t * CmdReturnFileNames( char * pDirStr )
for (int i = 0; i < num_files; i++) {
char * pExt = strstr(namelist[i]->d_name, ".");
if ( !pExt || !strcmp(pExt, ".") || !strcmp(pExt, "..") || !strcmp(pExt, ".s") || !strcmp(pExt, ".txt") )
continue;
continue;
Vec_PtrPush( vRes, Abc_UtilStrsav(namelist[i]->d_name) );
free(namelist[i]);
}
Expand All @@ -1864,7 +1866,7 @@ int CmdCommandScrGenLinux( Abc_Frame_t * pAbc, int argc, char **argv )
char * pDirStr = (char *)".";
char * pComStr = (char *)"ps";
char * pWriteStr = NULL;
char * pWriteExt = NULL;
char * pWriteExt = NULL;
char Line[2000], * pName;
int nFileNameMax;
int fBatch = 0;
Expand Down Expand Up @@ -1919,7 +1921,7 @@ int CmdCommandScrGenLinux( Abc_Frame_t * pAbc, int argc, char **argv )
}
pWriteExt = argv[globalUtilOptind];
globalUtilOptind++;
break;
break;
case 'b':
fBatch ^= 1;
break;
Expand Down Expand Up @@ -1949,8 +1951,8 @@ int CmdCommandScrGenLinux( Abc_Frame_t * pAbc, int argc, char **argv )
int fAndSpace = pComStr[0] == '&';
fprintf( pFile, "# Script file produced by ABC on %s\n", Extra_TimeStamp() );
fprintf( pFile, "# Command line was: scrgen -F %s -D %s -C \"%s\"%s%s%s%s\n",
pFileStr, pDirStr, pComStr,
pWriteStr?" -W ":"", pWriteStr?pWriteStr:"",
pFileStr, pDirStr, pComStr,
pWriteStr?" -W ":"", pWriteStr?pWriteStr:"",
pWriteExt?" -E ":"", pWriteExt?pWriteExt:"" );
Vec_PtrForEachEntry( char *, vNames, pName, k ) {
char * pExt = strstr(pName, ".");
Expand Down Expand Up @@ -1988,7 +1990,7 @@ int CmdCommandScrGenLinux( Abc_Frame_t * pAbc, int argc, char **argv )
fprintf( pAbc->Err, "\t-C str : the sequence of commands to run [default = \"ps\"]\n" );
fprintf( pAbc->Err, "\t-W str : the directory to write the resulting files [default = no writing]\n" );
fprintf( pAbc->Err, "\t-E str : the output files extension (with \".\") [default = the same as input files]\n" );
fprintf( pAbc->Err, "\t-b : toggles adding batch mode support [default = %s]\n", fBatch? "yes": "no" );
fprintf( pAbc->Err, "\t-b : toggles adding batch mode support [default = %s]\n", fBatch? "yes": "no" );
fprintf( pAbc->Err, "\t-h : print the command usage\n\n");
fprintf( pAbc->Err, "\tExample : scrgen -F test1.s -R a/in -C \"ps; st; ps\" -W a/out -E .blif\n" );
return 1;
Expand Down Expand Up @@ -2541,7 +2543,7 @@ int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv )
Synopsis []
Description []
SideEffects []
SeeAlso []
Expand All @@ -2568,7 +2570,7 @@ int CmdCommandStarter( Abc_Frame_t * pAbc, int argc, char ** argv )
}
nCores = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nCores < 0 )
if ( nCores < 0 )
goto usage;
break;
case 'C':
Expand Down Expand Up @@ -2626,7 +2628,7 @@ int CmdCommandStarter( Abc_Frame_t * pAbc, int argc, char ** argv )
Synopsis []
Description []
SideEffects []
SeeAlso []
Expand Down Expand Up @@ -2654,7 +2656,7 @@ int CmdCommandAutoTuner( Abc_Frame_t * pAbc, int argc, char ** argv )
}
nCores = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nCores < 0 )
if ( nCores < 0 )
goto usage;
break;
case 'C':
Expand Down Expand Up @@ -2775,7 +2777,7 @@ int CmdCommandVersion( Abc_Frame_t * pAbc, int argc, char **argv )
Synopsis []
Description []
SideEffects []
SeeAlso []
Expand All @@ -2800,7 +2802,7 @@ int CmdCommandSGen( Abc_Frame_t * pAbc, int argc, char ** argv )
}
nParts = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nParts < 0 )
if ( nParts < 0 )
goto usage;
break;
case 'I':
Expand All @@ -2826,7 +2828,7 @@ int CmdCommandSGen( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -2, "There is no current network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(Abc_FrameReadNtk(pAbc)) )
if ( !Abc_NtkIsStrash(Abc_FrameReadNtk(pAbc)) )
{
Abc_Print( -2, "The current network is not an AIG.\n" );
return 1;
Expand Down

0 comments on commit ce15089

Please sign in to comment.