mirror of https://github.com/YosysHQ/abc.git
Patch to support WASI builds
Co-authored-by: whitequark <whitequark@whitequark.org>
This commit is contained in:
parent
15ec302095
commit
57c3bd36f2
|
|
@ -114,7 +114,11 @@ Gia_Man_t * Gia_StochProcessOne( Gia_Man_t * p, char * pScript, int Rand, int Ti
|
||||||
sprintf( FileName, "%06x.aig", Rand );
|
sprintf( FileName, "%06x.aig", Rand );
|
||||||
Gia_AigerWrite( p, FileName, 0, 0, 0 );
|
Gia_AigerWrite( p, FileName, 0, 0, 0 );
|
||||||
sprintf( Command, "./abc -q \"&read %s; %s; &write %s\"", FileName, pScript, FileName );
|
sprintf( Command, "./abc -q \"&read %s; %s; &write %s\"", FileName, pScript, FileName );
|
||||||
|
#if defined(__wasm)
|
||||||
|
if ( 1 )
|
||||||
|
#else
|
||||||
if ( system( (char *)Command ) )
|
if ( system( (char *)Command ) )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fprintf( stderr, "The following command has returned non-zero exit status:\n" );
|
fprintf( stderr, "The following command has returned non-zero exit status:\n" );
|
||||||
fprintf( stderr, "\"%s\"\n", (char *)Command );
|
fprintf( stderr, "\"%s\"\n", (char *)Command );
|
||||||
|
|
|
||||||
|
|
@ -363,7 +363,11 @@ void Abc_ShowFile( char * FileNameDot, int fKeepDot )
|
||||||
|
|
||||||
// generate the PostScript file using DOT
|
// generate the PostScript file using DOT
|
||||||
sprintf( CommandDot, "%s -Tps -o %s %s", pDotName, FileNamePs, FileNameDot );
|
sprintf( CommandDot, "%s -Tps -o %s %s", pDotName, FileNamePs, FileNameDot );
|
||||||
|
#if defined(__wasm)
|
||||||
|
RetValue = -1;
|
||||||
|
#else
|
||||||
RetValue = system( CommandDot );
|
RetValue = system( CommandDot );
|
||||||
|
#endif
|
||||||
if ( RetValue == -1 )
|
if ( RetValue == -1 )
|
||||||
{
|
{
|
||||||
fprintf( stdout, "Command \"%s\" did not succeed.\n", CommandDot );
|
fprintf( stdout, "Command \"%s\" did not succeed.\n", CommandDot );
|
||||||
|
|
@ -401,7 +405,11 @@ void Abc_ShowFile( char * FileNameDot, int fKeepDot )
|
||||||
char CommandPs[1000];
|
char CommandPs[1000];
|
||||||
if ( !fKeepDot ) unlink( FileNameDot );
|
if ( !fKeepDot ) unlink( FileNameDot );
|
||||||
sprintf( CommandPs, "%s %s &", pGsNameUnix, FileNamePs );
|
sprintf( CommandPs, "%s %s &", pGsNameUnix, FileNamePs );
|
||||||
|
#if defined(__wasm)
|
||||||
|
if ( 1 )
|
||||||
|
#else
|
||||||
if ( system( CommandPs ) == -1 )
|
if ( system( CommandPs ) == -1 )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fprintf( stdout, "Cannot execute \"%s\".\n", CommandPs );
|
fprintf( stdout, "Cannot execute \"%s\".\n", CommandPs );
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -7295,7 +7295,11 @@ int Abc_CommandRunSat( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||||
sprintf( pCommand, "kissat -q --seed=%d %s", i, pFileCnf );
|
sprintf( pCommand, "kissat -q --seed=%d %s", i, pFileCnf );
|
||||||
else if ( fWalk )
|
else if ( fWalk )
|
||||||
sprintf( pCommand, "walk -s%d %s", i, pFileCnf );
|
sprintf( pCommand, "walk -s%d %s", i, pFileCnf );
|
||||||
|
#if defined(__wasm)
|
||||||
|
if (1) {
|
||||||
|
#else
|
||||||
if (system(pCommand) == -1) {
|
if (system(pCommand) == -1) {
|
||||||
|
#endif
|
||||||
fprintf(stdout, "Command \"%s\" did not succeed.\n", pCommand);
|
fprintf(stdout, "Command \"%s\" did not succeed.\n", pCommand);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2412,7 +2412,11 @@ void Gia_ManGnuplotShow( char * pPlotFileName )
|
||||||
{
|
{
|
||||||
char Command[1000];
|
char Command[1000];
|
||||||
sprintf( Command, "%s %s ", pProgNameGnuplot, pPlotFileName );
|
sprintf( Command, "%s %s ", pProgNameGnuplot, pPlotFileName );
|
||||||
|
#if defined(__wasm)
|
||||||
|
if ( 1 )
|
||||||
|
#else
|
||||||
if ( system( Command ) == -1 )
|
if ( system( Command ) == -1 )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fprintf( stdout, "Cannot execute \"%s\".\n", Command );
|
fprintf( stdout, "Cannot execute \"%s\".\n", Command );
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,9 @@ int cmdCheckShellEscape( Abc_Frame_t * pAbc, int argc, char ** argv)
|
||||||
int RetValue;
|
int RetValue;
|
||||||
if (argv[0][0] == '!')
|
if (argv[0][0] == '!')
|
||||||
{
|
{
|
||||||
|
#if defined(__wasm)
|
||||||
|
RetValue = -1;
|
||||||
|
#else
|
||||||
const int size = 4096;
|
const int size = 4096;
|
||||||
int i;
|
int i;
|
||||||
char * buffer = ABC_ALLOC(char, 10000);
|
char * buffer = ABC_ALLOC(char, 10000);
|
||||||
|
|
@ -71,7 +74,7 @@ int cmdCheckShellEscape( Abc_Frame_t * pAbc, int argc, char ** argv)
|
||||||
// the parts, we lose information. So a command like
|
// the parts, we lose information. So a command like
|
||||||
// `!ls "file name"` will be sent to the system as
|
// `!ls "file name"` will be sent to the system as
|
||||||
// `ls file name` which is a BUG
|
// `ls file name` which is a BUG
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,9 @@ SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||||
#include <sys/times.h>
|
#include <sys/times.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#if !defined(__wasm)
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,9 @@ char * Wln_GetYosysName()
|
||||||
}
|
}
|
||||||
int Wln_ConvertToRtl( char * pCommand, char * pFileTemp )
|
int Wln_ConvertToRtl( char * pCommand, char * pFileTemp )
|
||||||
{
|
{
|
||||||
|
#if defined(__wasm)
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
FILE * pFile;
|
FILE * pFile;
|
||||||
if ( system( pCommand ) == -1 )
|
if ( system( pCommand ) == -1 )
|
||||||
{
|
{
|
||||||
|
|
@ -134,6 +137,7 @@ int Wln_ConvertToRtl( char * pCommand, char * pFileTemp )
|
||||||
}
|
}
|
||||||
fclose( pFile );
|
fclose( pFile );
|
||||||
return 1;
|
return 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
Rtl_Lib_t * Wln_ReadSystemVerilog( char * pFileName, char * pTopModule, char * pDefines, int fCollapse, int fVerbose )
|
Rtl_Lib_t * Wln_ReadSystemVerilog( char * pFileName, char * pTopModule, char * pDefines, int fCollapse, int fVerbose )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -334,7 +334,7 @@ static inline abctime Abc_Clock()
|
||||||
#else
|
#else
|
||||||
#define APPLE_MACH 0
|
#define APPLE_MACH 0
|
||||||
#endif
|
#endif
|
||||||
#if (defined(LIN) || defined(LIN64)) && !APPLE_MACH && !defined(__MINGW32__)
|
#if (defined(LIN) || defined(LIN64)) && !APPLE_MACH && !defined(__MINGW32__) && !defined(__wasm)
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
if ( clock_gettime(CLOCK_MONOTONIC, &ts) < 0 )
|
if ( clock_gettime(CLOCK_MONOTONIC, &ts) < 0 )
|
||||||
return (abctime)-1;
|
return (abctime)-1;
|
||||||
|
|
@ -353,7 +353,7 @@ static inline abctime Abc_ThreadClock()
|
||||||
#else
|
#else
|
||||||
#define APPLE_MACH 0
|
#define APPLE_MACH 0
|
||||||
#endif
|
#endif
|
||||||
#if (defined(LIN) || defined(LIN64)) && !APPLE_MACH && !defined(__MINGW32__)
|
#if (defined(LIN) || defined(LIN64)) && !APPLE_MACH && !defined(__MINGW32__) && !defined(__wasm)
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
if ( clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) < 0 )
|
if ( clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) < 0 )
|
||||||
return (abctime)-1;
|
return (abctime)-1;
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,17 @@ int tmpFile(const char* prefix, const char* suffix, char** out_name)
|
||||||
}
|
}
|
||||||
assert(0); // -- could not open temporary file
|
assert(0); // -- could not open temporary file
|
||||||
return 0;
|
return 0;
|
||||||
|
#elif defined(__wasm)
|
||||||
|
static int seq = 0; // no risk of collision since we're in a sandbox
|
||||||
|
int fd;
|
||||||
|
*out_name = (char*)malloc(strlen(prefix) + strlen(suffix) + 9);
|
||||||
|
sprintf(*out_name, "%s%08d%s", prefix, seq++, suffix);
|
||||||
|
fd = open(*out_name, O_CREAT | O_EXCL | O_RDWR, S_IREAD | S_IWRITE);
|
||||||
|
if (fd == -1){
|
||||||
|
free(*out_name);
|
||||||
|
*out_name = NULL;
|
||||||
|
}
|
||||||
|
return fd;
|
||||||
#else
|
#else
|
||||||
int fd;
|
int fd;
|
||||||
*out_name = (char*)malloc(strlen(prefix) + strlen(suffix) + 7);
|
*out_name = (char*)malloc(strlen(prefix) + strlen(suffix) + 7);
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,11 @@ ABC_NAMESPACE_IMPL_START
|
||||||
|
|
||||||
int Util_SignalSystem(const char* cmd)
|
int Util_SignalSystem(const char* cmd)
|
||||||
{
|
{
|
||||||
|
#if defined(__wasm)
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
return system(cmd);
|
return system(cmd);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int tmpFile(const char* prefix, const char* suffix, char** out_name);
|
int tmpFile(const char* prefix, const char* suffix, char** out_name);
|
||||||
|
|
|
||||||
|
|
@ -1642,7 +1642,11 @@ Vec_Int_t * Exa4_ManSolve( char * pFileNameIn, char * pFileNameOut, int TimeOut,
|
||||||
sprintf( pCommand, "%s --time=%d %s %s > %s", pKissat, TimeOut, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut );
|
sprintf( pCommand, "%s --time=%d %s %s > %s", pKissat, TimeOut, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut );
|
||||||
else
|
else
|
||||||
sprintf( pCommand, "%s %s %s > %s", pKissat, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut );
|
sprintf( pCommand, "%s %s %s > %s", pKissat, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut );
|
||||||
|
#ifdef __wasm
|
||||||
|
if ( 1 )
|
||||||
|
#else
|
||||||
if ( system( pCommand ) == -1 )
|
if ( system( pCommand ) == -1 )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fprintf( stdout, "Command \"%s\" did not succeed.\n", pCommand );
|
fprintf( stdout, "Command \"%s\" did not succeed.\n", pCommand );
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,11 @@ void RegionAllocator<T>::capacity(uint32_t min_cap)
|
||||||
cap += delta;
|
cap += delta;
|
||||||
|
|
||||||
if (cap <= prev_cap)
|
if (cap <= prev_cap)
|
||||||
|
#ifdef __wasm
|
||||||
|
abort();
|
||||||
|
#else
|
||||||
throw OutOfMemoryException();
|
throw OutOfMemoryException();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
// printf(" .. (%p) cap = %u\n", this, cap);
|
// printf(" .. (%p) cap = %u\n", this, cap);
|
||||||
|
|
||||||
|
|
@ -121,7 +125,11 @@ RegionAllocator<T>::alloc(int size)
|
||||||
|
|
||||||
// Handle overflow:
|
// Handle overflow:
|
||||||
if (sz < prev_sz)
|
if (sz < prev_sz)
|
||||||
|
#ifdef __wasm
|
||||||
|
abort();
|
||||||
|
#else
|
||||||
throw OutOfMemoryException();
|
throw OutOfMemoryException();
|
||||||
|
#endif
|
||||||
|
|
||||||
return prev_sz;
|
return prev_sz;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,11 @@ void vec<T>::capacity(int min_cap) {
|
||||||
if (cap >= min_cap) return;
|
if (cap >= min_cap) return;
|
||||||
int add = imax((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1); // NOTE: grow by approximately 3/2
|
int add = imax((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1); // NOTE: grow by approximately 3/2
|
||||||
if (add > INT_MAX - cap || (((data = (T*)::realloc(data, (cap += add) * sizeof(T))) == NULL) && errno == ENOMEM))
|
if (add > INT_MAX - cap || (((data = (T*)::realloc(data, (cap += add) * sizeof(T))) == NULL) && errno == ENOMEM))
|
||||||
|
#ifdef __wasm
|
||||||
|
abort();
|
||||||
|
#else
|
||||||
throw OutOfMemoryException();
|
throw OutOfMemoryException();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,11 @@ static inline void* xrealloc(void *ptr, size_t size)
|
||||||
{
|
{
|
||||||
void* mem = realloc(ptr, size);
|
void* mem = realloc(ptr, size);
|
||||||
if (mem == NULL && errno == ENOMEM){
|
if (mem == NULL && errno == ENOMEM){
|
||||||
|
#ifdef __wasm
|
||||||
|
abort();
|
||||||
|
#else
|
||||||
throw OutOfMemoryException();
|
throw OutOfMemoryException();
|
||||||
|
#endif
|
||||||
}else
|
}else
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,11 @@ Vec_Int_t *Cnf_RunSolverOnce(int Id, int Rand, int TimeOut, int fVerbose)
|
||||||
FILE * pFile = fopen(FileNameIn, "rb");
|
FILE * pFile = fopen(FileNameIn, "rb");
|
||||||
if ( pFile != NULL ) {
|
if ( pFile != NULL ) {
|
||||||
fclose( pFile );
|
fclose( pFile );
|
||||||
|
#if defined(__wasm)
|
||||||
|
if ( 1 ) {
|
||||||
|
#else
|
||||||
if (system(pCommand) == -1) {
|
if (system(pCommand) == -1) {
|
||||||
|
#endif
|
||||||
fprintf(stdout, "Command \"%s\" did not succeed.\n", pCommand);
|
fprintf(stdout, "Command \"%s\" did not succeed.\n", pCommand);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -764,7 +768,11 @@ void Cnf_SplitCnfFile(char * pFileName, int nParts, int iVarBeg, int iVarEnd, in
|
||||||
char Command[1000];
|
char Command[1000];
|
||||||
sprintf(Command, "satelite --verbosity=0 -pre temp.cnf %s", FileName);
|
sprintf(Command, "satelite --verbosity=0 -pre temp.cnf %s", FileName);
|
||||||
Cnf_DataWriteIntoFile(pCnf, "temp.cnf", 0, NULL, NULL);
|
Cnf_DataWriteIntoFile(pCnf, "temp.cnf", 0, NULL, NULL);
|
||||||
|
#if defined(__wasm)
|
||||||
|
if ( 1 ) {
|
||||||
|
#else
|
||||||
if (system(Command) == -1) {
|
if (system(Command) == -1) {
|
||||||
|
#endif
|
||||||
fprintf(stdout, "Command \"%s\" did not succeed. Preprocessing skipped.\n", Command);
|
fprintf(stdout, "Command \"%s\" did not succeed. Preprocessing skipped.\n", Command);
|
||||||
Cnf_DataWriteIntoFile(pCnf, FileName, 0, NULL, NULL);
|
Cnf_DataWriteIntoFile(pCnf, FileName, 0, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,20 +28,18 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
|
||||||
# include <sys/int_fmtio.h>
|
# include <sys/int_fmtio.h>
|
||||||
# include <sys/int_limits.h>
|
# include <sys/int_limits.h>
|
||||||
|
|
||||||
|
#elif _WIN32
|
||||||
|
|
||||||
|
# include "pstdint.h"
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define __STDC_LIMIT_MACROS
|
# define __STDC_LIMIT_MACROS
|
||||||
# include "pstdint.h"
|
# include <limits.h>
|
||||||
//# include <inttypes.h>
|
# include <inttypes.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#ifndef PRIu64
|
|
||||||
#define PRIu64 "lu"
|
|
||||||
#define PRIi64 "ld"
|
|
||||||
#endif
|
|
||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
|
|
||||||
#include <misc/util/abc_namespaces.h>
|
#include <misc/util/abc_namespaces.h>
|
||||||
|
|
|
||||||
|
|
@ -28,20 +28,18 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
|
||||||
# include <sys/int_fmtio.h>
|
# include <sys/int_fmtio.h>
|
||||||
# include <sys/int_limits.h>
|
# include <sys/int_limits.h>
|
||||||
|
|
||||||
|
#elif _WIN32
|
||||||
|
|
||||||
|
# include "pstdint.h"
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define __STDC_LIMIT_MACROS
|
# define __STDC_LIMIT_MACROS
|
||||||
# include "pstdint.h"
|
# include <limits.h>
|
||||||
//# include <inttypes.h>
|
# include <inttypes.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#ifndef PRIu64
|
|
||||||
#define PRIu64 "lu"
|
|
||||||
#define PRIi64 "ld"
|
|
||||||
#endif
|
|
||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
|
|
||||||
#include <misc/util/abc_namespaces.h>
|
#include <misc/util/abc_namespaces.h>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue