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
* unhide dirent include for gnu-on-windows

Signed-off-by: Stephen L Arnold <[email protected]>
  • Loading branch information
sarnold committed Dec 1, 2023
1 parent eb45ee9 commit 2afc153
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 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,14 @@
***********************************************************************/

// implicit declarations are no longer allowed
#define _GNU_SOURCE

#include <dirent.h>
#ifdef WIN32
#include <process.h>
#else
#include <unistd.h>
#include <dirent.h>
#endif

#include "base/abc/abc.h"
Expand Down Expand Up @@ -1836,7 +1839,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 +1851,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 +1867,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 +1922,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 +1952,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 +1991,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 +2544,7 @@ int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv )
Synopsis []
Description []
SideEffects []
SeeAlso []
Expand All @@ -2568,7 +2571,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 +2629,7 @@ int CmdCommandStarter( Abc_Frame_t * pAbc, int argc, char ** argv )
Synopsis []
Description []
SideEffects []
SeeAlso []
Expand Down Expand Up @@ -2654,7 +2657,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 +2778,7 @@ int CmdCommandVersion( Abc_Frame_t * pAbc, int argc, char **argv )
Synopsis []
Description []
SideEffects []
SeeAlso []
Expand All @@ -2800,7 +2803,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 +2829,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 2afc153

Please sign in to comment.