mirror of https://github.com/YosysHQ/abc.git
WASI fixes
This commit is contained in:
parent
3b36aa1573
commit
ef74590ebd
|
|
@ -26,6 +26,8 @@
|
|||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h> // mkstemp(), close(), unlink()
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define AIGSIM_LIBRARY_ONLY
|
||||
|
||||
|
|
@ -284,8 +286,14 @@ static int ends_with(const char *s, const char *suf) {
|
|||
|
||||
static int make_tmp_file(char *path, size_t cap, const char *prefix) {
|
||||
// Creates an existing temp file (for input)
|
||||
#if defined(__wasm)
|
||||
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);
|
||||
#else
|
||||
snprintf(path, cap, "/tmp/%sXXXXXX", prefix);
|
||||
int fd = mkstemp(path);
|
||||
#endif
|
||||
if (fd < 0) return 0;
|
||||
close(fd);
|
||||
return 1;
|
||||
|
|
@ -293,8 +301,14 @@ static int make_tmp_file(char *path, size_t cap, const char *prefix) {
|
|||
|
||||
static int make_tmp_path_noexist(char *path, size_t cap, const char *prefix) {
|
||||
// Creates a unique temp path that does not exist (for output)
|
||||
#if defined(__wasm)
|
||||
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);
|
||||
#else
|
||||
snprintf(path, cap, "/tmp/%sXXXXXX", prefix);
|
||||
int fd = mkstemp(path);
|
||||
#endif
|
||||
if (fd < 0) return 0;
|
||||
close(fd);
|
||||
unlink(path);
|
||||
|
|
@ -527,7 +541,11 @@ static int SimulateCompareAigBin(const AigMan *p1, const char *bin,
|
|||
// Run external binary: "<bin> <inFile> <outFile>"
|
||||
remove(outFile);
|
||||
snprintf(cmd, sizeof(cmd), "%s %s %s", bin, inFile, outFile);
|
||||
#if defined(__wasm)
|
||||
int rc = -1;
|
||||
#else
|
||||
int rc = system(cmd);
|
||||
#endif
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "Error: system() failed (rc=%d): %s\n", rc, cmd);
|
||||
goto fail;
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@
|
|||
#include <array>
|
||||
#include <regex>
|
||||
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <base/wlc/wlc.h>
|
||||
#include <sat/cnf/cnf.h>
|
||||
#include <aig/gia/giaAig.h>
|
||||
|
|
|
|||
|
|
@ -184,6 +184,10 @@ class PDRWLA : public Solver {
|
|||
Wlc_Par_t _Pars;
|
||||
};
|
||||
|
||||
#if defined(__wasm)
|
||||
static void pthread_exit(void *retval) __attribute__((noreturn)) { }
|
||||
#endif
|
||||
|
||||
void KillOthers() {
|
||||
pthread_cond_signal( &g_cond );
|
||||
++g_nRunIds;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <fstream>
|
||||
|
||||
#include <base/wlc/wlc.h>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@
|
|||
*/
|
||||
|
||||
#include <iomanip>
|
||||
#if !defined(__wasm)
|
||||
#include <csignal>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __linux__
|
||||
|
|
|
|||
Loading…
Reference in New Issue