diff --git a/src/opt/eslim/synthesisEngine.tpp b/src/opt/eslim/synthesisEngine.tpp index 6a8485f7f..ef94d9226 100644 --- a/src/opt/eslim/synthesisEngine.tpp +++ b/src/opt/eslim/synthesisEngine.tpp @@ -614,7 +614,11 @@ namespace eSLIM { // sprintf( pCommand, "%s -q %s > %s", pKissat, pFileNameIn, pFileNameOut ); sprintf( pCommand, "%s -q %s > %s", pKissat, pFileNameIn, pFileNameOut ); +#ifdef __wasm + if ( 1 ) { +#else if ( system( pCommand ) == -1 ) { +#endif std::cerr << "Command " << pCommand << " failed\n"; return nullptr; } diff --git a/src/sat/cadical/cadical_congruence.cpp b/src/sat/cadical/cadical_congruence.cpp index 8fbceee24..dd5f30b7a 100644 --- a/src/sat/cadical/cadical_congruence.cpp +++ b/src/sat/cadical/cadical_congruence.cpp @@ -5981,7 +5981,7 @@ void Closure::rewrite_ite_gate (Gate *g, int dst, int src) { #endif } else { CADICAL_assert (false); -#ifdef WIN32 +#if defined(WIN32) && !defined(__MINGW32__) __assume(false); #else __builtin_unreachable (); diff --git a/src/sat/cadical/cadical_file.cpp b/src/sat/cadical/cadical_file.cpp index 98f19f752..d48193e93 100644 --- a/src/sat/cadical/cadical_file.cpp +++ b/src/sat/cadical/cadical_file.cpp @@ -33,7 +33,9 @@ extern "C" { #else extern "C" { +#if !defined(__wasm) #include +#endif #include } @@ -245,6 +247,7 @@ void File::delete_str_vector (std::vector &argv) { FILE *File::open_pipe (Internal *internal, const char *fmt, const char *path, const char *mode) { +#if !defined(__wasm) #ifdef CADICAL_QUIET (void) internal; #endif @@ -269,6 +272,9 @@ FILE *File::open_pipe (Internal *internal, const char *fmt, FILE *res = popen (cmd, mode); delete[] cmd; return res; +#else + return 0; +#endif } FILE *File::read_pipe (Internal *internal, const char *fmt, const int *sig, @@ -285,7 +291,7 @@ FILE *File::read_pipe (Internal *internal, const char *fmt, const int *sig, return open_pipe (internal, fmt, path, "r"); } -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__wasm) #if defined(__APPLE__) || defined(__MACH__) static std::mutex compressed_file_writing_mutex; @@ -420,7 +426,7 @@ File *File::read (Internal *internal, const char *path) { File *File::write (Internal *internal, const char *path) { FILE *file; int close_output = 3, child_pid = 0; -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__wasm) if (has_suffix (path, ".xz")) file = write_pipe (internal, "xz -c", path, child_pid); else if (has_suffix (path, ".bz2")) @@ -456,12 +462,14 @@ void File::close (bool print) { MSG ("closing file '%s'", name ()); fclose (file); } +#if !defined(__wasm) if (close_file == 2) { if (print) MSG ("closing input pipe to read '%s'", name ()); pclose (file); } -#ifndef _WIN32 +#endif +#if !defined(_WIN32) && !defined(__wasm) if (close_file == 3) { if (print) MSG ("closing output pipe to write '%s'", name ()); diff --git a/src/sat/cadical/cadical_random.cpp b/src/sat/cadical/cadical_random.cpp index 85d022e8f..044f6aba0 100644 --- a/src/sat/cadical/cadical_random.cpp +++ b/src/sat/cadical/cadical_random.cpp @@ -84,7 +84,7 @@ ABC_NAMESPACE_IMPL_END // work. As an additional measure to increase the possibility to get // different seeds we are now also using network addresses (explicitly). -#ifndef WIN32 +#if !defined(_WIN32) && !defined(__wasm) extern "C" { #include @@ -110,7 +110,7 @@ static uint64_t hash_network_addresses () { // you really need to run 'mobical' on a Windows cluster where each node // has identical IP addresses. -#ifndef WIN32 +#if !defined(_WIN32) && !defined(__wasm) struct ifaddrs *addrs; if (!getifaddrs (&addrs)) { for (struct ifaddrs *addr = addrs; addr; addr = addr->ifa_next) { diff --git a/src/sat/cadical/cadical_resources.cpp b/src/sat/cadical/cadical_resources.cpp index 9a2b421e5..912a40568 100644 --- a/src/sat/cadical/cadical_resources.cpp +++ b/src/sat/cadical/cadical_resources.cpp @@ -131,10 +131,14 @@ uint64_t maximum_resident_set_size () { // This seems to work on Linux (man page says since Linux 2.6.32). uint64_t maximum_resident_set_size () { +#ifdef __wasm + return 0; +#else struct rusage u; if (getrusage (RUSAGE_SELF, &u)) return 0; return ((uint64_t) u.ru_maxrss) << 10; +#endif } // Unfortunately 'getrusage' on Linux does not support current resident set diff --git a/src/sat/cadical/cadical_signal.cpp b/src/sat/cadical/cadical_signal.cpp index 099277f03..7e8fc965b 100644 --- a/src/sat/cadical/cadical_signal.cpp +++ b/src/sat/cadical/cadical_signal.cpp @@ -7,11 +7,13 @@ /*------------------------------------------------------------------------*/ #include +#if !defined(__wasm) #include +#endif /*------------------------------------------------------------------------*/ -#ifndef WIN32 +#if !defined(_WIN32) && !defined(__wasm) extern "C" { #include } @@ -28,7 +30,7 @@ namespace CaDiCaL { static volatile bool caught_signal = false; static Handler *signal_handler; -#ifndef WIN32 +#if !defined(_WIN32) && !defined(__wasm) static volatile bool caught_alarm = false; static volatile bool alarm_set = false; @@ -38,6 +40,7 @@ void Handler::catch_alarm () { catch_signal (SIGALRM); } #endif +#if !defined(__wasm) #define SIGNALS \ SIGNAL (SIGABRT) \ SIGNAL (SIGINT) \ @@ -47,8 +50,9 @@ void Handler::catch_alarm () { catch_signal (SIGALRM); } #define SIGNAL(SIG) static void (*SIG##_handler) (int); SIGNALS #undef SIGNAL +#endif -#ifndef WIN32 +#if !defined(_WIN32) && !defined(__wasm) static void (*SIGALRM_handler) (int); @@ -66,6 +70,7 @@ void Signal::reset_alarm () { void Signal::reset () { signal_handler = 0; +#if !defined(__wasm) #define SIGNAL(SIG) \ (void) signal (SIG, SIG##_handler); \ SIG##_handler = 0; @@ -73,11 +78,13 @@ void Signal::reset () { #undef SIGNAL #ifndef WIN32 reset_alarm (); +#endif #endif caught_signal = false; } const char *Signal::name (int sig) { +#if !defined(__wasm) #define SIGNAL(SIG) \ if (sig == SIG) \ return #SIG; @@ -86,6 +93,7 @@ const char *Signal::name (int sig) { #ifndef WIN32 if (sig == SIGALRM) return "SIGALRM"; +#endif #endif return "UNKNOWN"; } @@ -97,6 +105,7 @@ const char *Signal::name (int sig) { // exclusive access to. All these solutions are painful and not elegant. static void catch_signal (int sig) { +#if !defined(__wasm) #ifndef WIN32 if (sig == SIGALRM && absolute_real_time () >= alarm_time) { if (!caught_alarm) { @@ -116,16 +125,19 @@ static void catch_signal (int sig) { Signal::reset (); ::raise (sig); } +#endif } void Signal::set (Handler *h) { +#if !defined(__wasm) signal_handler = h; #define SIGNAL(SIG) SIG##_handler = signal (SIG, catch_signal); SIGNALS #undef SIGNAL +#endif } -#ifndef WIN32 +#if !defined(_WIN32) && !defined(__wasm) void Signal::alarm (int seconds) { CADICAL_assert (seconds >= 0); diff --git a/src/sat/cadical/cadical_vivify.cpp b/src/sat/cadical/cadical_vivify.cpp index 8d99c2932..5ec6401cf 100644 --- a/src/sat/cadical/cadical_vivify.cpp +++ b/src/sat/cadical/cadical_vivify.cpp @@ -1501,7 +1501,7 @@ inline std::vector ¤t_refs_schedule (Vivifier &vivifier) { return vivifier.refs_schedule_irred; break; } -#ifdef WIN32 +#if defined(WIN32) && !defined(__MINGW32__) __assume(false); #else __builtin_unreachable (); @@ -1523,7 +1523,7 @@ inline std::vector ¤t_schedule (Vivifier &vivifier) { return vivifier.schedule_irred; break; } -#ifdef WIN32 +#if defined(WIN32) && !defined(__MINGW32__) __assume(false); #else __builtin_unreachable (); diff --git a/src/sat/cadical/file.hpp b/src/sat/cadical/file.hpp index 860e9613a..a8baf82b9 100644 --- a/src/sat/cadical/file.hpp +++ b/src/sat/cadical/file.hpp @@ -66,7 +66,7 @@ class File { const char *mode); static FILE *read_pipe (Internal *, const char *fmt, const int *sig, const char *path); -#ifndef WIN32 +#if !defined(_WIN32) && !defined(__wasm) static FILE *write_pipe (Internal *, const char *fmt, const char *path, int &child_pid); #endif diff --git a/src/sat/cadical/internal.hpp b/src/sat/cadical/internal.hpp index d86479a52..53c698c58 100644 --- a/src/sat/cadical/internal.hpp +++ b/src/sat/cadical/internal.hpp @@ -17,7 +17,9 @@ #include #include #include +#if !defined(__wasm) #include +#endif #include #include #include diff --git a/src/sat/kissat/colors.c b/src/sat/kissat/colors.c index f45260b29..c6141b749 100644 --- a/src/sat/kissat/colors.c +++ b/src/sat/kissat/colors.c @@ -1,6 +1,6 @@ #include "colors.h" -#ifdef WIN32 +#if defined(WIN32) && !defined(__MINGW32__) #define isatty _isatty #else #include