Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/aig/gia/giaStoch.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ Vec_Int_t * Gia_StochProcessArray( Vec_Ptr_t * vGias, char * pScript, int TimeSe
Gia_Man_t * Gia_StochProcessOne( Gia_Man_t * p, char * pScript, int Rand, int TimeSecs )
{
Gia_Man_t * pNew;
char FileName[100], Command[1000];
sprintf( FileName, "%06x.aig", Rand );
char FileName[1000], Command[2000];
sprintf( FileName, "%s/%06x.aig", Abc_GetTmpDir(), Rand );
Gia_AigerWrite( p, FileName, 0, 0, 0 );
sprintf( Command, "./abc -q \"&read %s; %s; &write %s\"", FileName, pScript, FileName );
#if defined(__wasm)
Expand Down
4 changes: 2 additions & 2 deletions src/base/abci/abcPart.c
Original file line number Diff line number Diff line change
Expand Up @@ -1296,10 +1296,10 @@ Abc_Ntk_t * Abc_NtkStochProcessOne( Abc_Ntk_t * p, char * pScript0, int Rand, in
extern int Abc_NtkWriteToFile( char * pFileName, Abc_Ntk_t * pNtk );
extern Abc_Ntk_t * Abc_NtkReadFromFile( char * pFileName );
Abc_Ntk_t * pNew, * pTemp;
char FileName[100], Command[1000], PreCommand[500] = {0};
char FileName[1000], Command[2000], PreCommand[500] = {0};
char * pLibFileName = Abc_NtkIsMappedLogic(p) ? Mio_LibraryReadFileName((Mio_Library_t *)p->pManFunc) : NULL;
if ( pLibFileName ) sprintf( PreCommand, "read_genlib %s; ", pLibFileName );
sprintf( FileName, "%06x.mm", Rand );
sprintf( FileName, "%s/%06x.mm", Abc_GetTmpDir(), Rand );
Abc_NtkWriteToFile( FileName, p );
char * pScript = Abc_UtilStrsav( pScript0 );
sprintf( Command, "./abc -q \"%sread_mm %s; %s; write_mm %s\"", PreCommand[0] ? PreCommand : "", FileName, pScript, FileName );
Expand Down
7 changes: 2 additions & 5 deletions src/base/sn/snCom.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,9 @@ static int Sn_TempPrefix( char * pBuffer, size_t nBuffer, const char * pStem )
{
int Written;
#if defined(_MSC_VER) || defined(__MINGW32__)
const char * pDirectory = getenv( "TEMP" );
if ( pDirectory == NULL )
pDirectory = ".";
Written = snprintf( pBuffer, nBuffer, "%s\\%s", pDirectory, pStem );
Written = snprintf( pBuffer, nBuffer, "%s\\%s", Abc_GetTmpDir(), pStem );
#else
Written = snprintf( pBuffer, nBuffer, "/tmp/%s", pStem );
Written = snprintf( pBuffer, nBuffer, "%s/%s", Abc_GetTmpDir(), pStem );
#endif
return Written >= 0 && (size_t)Written < nBuffer;
}
Expand Down
19 changes: 19 additions & 0 deletions src/misc/util/abc_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,25 @@ static inline void Abc_ReverseOrder( int * pA, int nA )
ABC_SWAP( int, pA[i], pA[nA-1-i] );
}

static inline const char * Abc_GetTmpDir()
{
const char * s;
#if defined(_MSC_VER) || defined(__MINGW32__)
s = getenv( "TMP" );
if ( s && *s )
return s;
s = getenv( "TEMP" );
if ( s && *s )
return s;
return ".";
#else
s = getenv( "TMPDIR" );
if ( s && *s )
return s;
return "/tmp";
#endif
}


// sorting
extern void Abc_MergeSort( int * pInput, int nSize );
Expand Down
11 changes: 9 additions & 2 deletions src/misc/util/utilAigSim.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <assert.h>
#include <ctype.h>
#include <time.h>
#include "abc_global.h"
#ifdef _WIN32
#include <io.h>
#define mkstemp(p) _mktemp_s(p, strlen(p)+1)
Expand Down Expand Up @@ -345,8 +346,11 @@ static int make_tmp_file(char *path, size_t cap, const char *prefix) {
static int seq = 0; // no risk of collision since we're in a sandbox
snprintf(path, cap, "%s%08d", prefix, seq++);
int fd = open(path, O_CREAT | O_EXCL | O_RDWR, S_IREAD | S_IWRITE);
#elif defined(_WIN32)
snprintf(path, cap, "%s\\%sXXXXXX", Abc_GetTmpDir(), prefix);
int fd = mkstemp(path);
#else
snprintf(path, cap, "/tmp/%sXXXXXX", prefix);
snprintf(path, cap, "%s/%sXXXXXX", Abc_GetTmpDir(), prefix);
int fd = mkstemp(path);
#endif
if (fd < 0) return 0;
Expand All @@ -360,8 +364,11 @@ static int make_tmp_path_noexist(char *path, size_t cap, const char *prefix) {
static int seq = 0; // no risk of collision since we're in a sandbox
snprintf(path, cap, "%s%08d", prefix, seq++);
int fd = open(path, O_CREAT | O_EXCL | O_RDWR, S_IREAD | S_IWRITE);
#elif defined(_WIN32)
snprintf(path, cap, "%s\\%sXXXXXX", Abc_GetTmpDir(), prefix);
int fd = mkstemp(path);
#else
snprintf(path, cap, "/tmp/%sXXXXXX", prefix);
snprintf(path, cap, "%s/%sXXXXXX", Abc_GetTmpDir(), prefix);
int fd = mkstemp(path);
#endif
if (fd < 0) return 0;
Expand Down
Loading