summaryrefslogtreecommitdiffstats
path: root/src/sat/glucose2
diff options
context:
space:
mode:
Diffstat (limited to 'src/sat/glucose2')
-rw-r--r--src/sat/glucose2/Alloc.h8
-rw-r--r--src/sat/glucose2/IntTypes.h14
-rw-r--r--src/sat/glucose2/Vec.h8
-rw-r--r--src/sat/glucose2/XAlloc.h4
4 files changed, 26 insertions, 8 deletions
diff --git a/src/sat/glucose2/Alloc.h b/src/sat/glucose2/Alloc.h
index b7bebaca..427cd323 100644
--- a/src/sat/glucose2/Alloc.h
+++ b/src/sat/glucose2/Alloc.h
@@ -100,7 +100,11 @@ void RegionAllocator<T>::capacity(uint32_t min_cap)
cap += delta;
if (cap <= prev_cap)
+#ifdef __wasm
+ abort();
+#else
throw OutOfMemoryException();
+#endif
}
//printf(" .. (%p) cap = %u\n", this, cap);
@@ -122,7 +126,11 @@ RegionAllocator<T>::alloc(int size)
// Handle overflow:
if (sz < prev_sz)
+#ifdef __wasm
+ abort();
+#else
throw OutOfMemoryException();
+#endif
return prev_sz;
}
diff --git a/src/sat/glucose2/IntTypes.h b/src/sat/glucose2/IntTypes.h
index 3f75862b..5c4176b2 100644
--- a/src/sat/glucose2/IntTypes.h
+++ b/src/sat/glucose2/IntTypes.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_limits.h>
-#else
+#elif _WIN32
-#define __STDC_LIMIT_MACROS
# include "pstdint.h"
-//# include <inttypes.h>
-#endif
+#else
-#include <limits.h>
+# define __STDC_LIMIT_MACROS
+# include <limits.h>
+# include <inttypes.h>
-#ifndef PRIu64
-#define PRIu64 "lu"
-#define PRIi64 "ld"
#endif
+
//=================================================================================================
#include <misc/util/abc_namespaces.h>
diff --git a/src/sat/glucose2/Vec.h b/src/sat/glucose2/Vec.h
index eaeed207..bc989217 100644
--- a/src/sat/glucose2/Vec.h
+++ b/src/sat/glucose2/Vec.h
@@ -102,14 +102,22 @@ void vec<T>::capacity(int min_cap) {
if (cap >= min_cap) return;
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))
+#ifdef __wasm
+ abort();
+#else
throw OutOfMemoryException();
+#endif
}
template<class T>
void vec<T>::prelocate(int ext_cap) {
if (cap >= ext_cap) return;
if (ext_cap > INT_MAX || (((data = (T*)::realloc(data, ext_cap * sizeof(T))) == NULL) && errno == ENOMEM))
+#ifdef __wasm
+ abort();
+#else
throw OutOfMemoryException();
+#endif
cap = ext_cap;
}
diff --git a/src/sat/glucose2/XAlloc.h b/src/sat/glucose2/XAlloc.h
index 716643ef..86e65a49 100644
--- a/src/sat/glucose2/XAlloc.h
+++ b/src/sat/glucose2/XAlloc.h
@@ -39,7 +39,11 @@ static inline void* xrealloc(void *ptr, size_t size)
{
void* mem = realloc(ptr, size);
if (mem == NULL && errno == ENOMEM){
+#ifdef __wasm
+ abort();
+#else
throw OutOfMemoryException();
+#endif
}else {
return mem;
}