aports/testing/abc/int128.patch
2026-03-19 02:39:31 +00:00

91 lines
3.3 KiB
Diff

diff --git a/src/misc/util/utilAigSim.c b/src/misc/util/utilAigSim.c
index 4d89b615f..99e3d75d9 100644
--- a/src/misc/util/utilAigSim.c
+++ b/src/misc/util/utilAigSim.c
@@ -34,6 +34,10 @@
#include <sys/stat.h>
#endif
+#if !defined(_WIN32) && defined(__SIZEOF_INT128__)
+#define ABC_HAS_INT128 1
+#endif
+
#ifdef _WIN32
// Windows doesn't have __builtin_ctzll, implement it using portable algorithm
static inline int __builtin_ctzll(uint64_t x) {
@@ -187,8 +191,8 @@ static inline uint64_t u64_mask_n(int nBits) {
return (nBits >= 64) ? ~0ull : ((nBits <= 0) ? 0ull : ((1ull << nBits) - 1ull));
}
-#ifdef _WIN32
-// Windows doesn't support __int128, so we limit to 32 variables on Windows
+#if !defined(ABC_HAS_INT128)
+// Targets without __int128 are limited to 32 variables
static void u128_to_dec(uint64_t x, char *buf, size_t cap) {
char tmp[64]; int n = 0;
if (!x) { snprintf(buf, cap, "0"); return; }
@@ -397,10 +401,10 @@ static int SimulateCompareAigAig(const AigMan *p1, const AigMan *p2,
const uint64_t inMask = u64_mask_n(p1->nCis);
const uint64_t outMask = u64_mask_n(p1->nCos);
-#ifdef _WIN32
- // Windows doesn't support __int128, limit to 32 variables
+#if !defined(ABC_HAS_INT128)
+ // Targets without __int128 are limited to 32 variables
if (nVars > 32) {
- fprintf(stderr, "Error: Windows build supports nVars<=32 (got nVars=%d)\n", nVars);
+ fprintf(stderr, "Error: this build supports nVars<=32 (got nVars=%d)\n", nVars);
return 0;
}
const uint64_t combs = ((uint64_t)1) << (unsigned)nVars;
@@ -420,7 +424,7 @@ static int SimulateCompareAigAig(const AigMan *p1, const AigMan *p2,
uint64_t inVec[BATCH], valid[NW];
unsigned long long rounds = 0;
-#ifdef _WIN32
+#if !defined(ABC_HAS_INT128)
uint64_t patsDone = 0;
#else
unsigned __int128 patsDone = 0;
@@ -428,7 +432,7 @@ static int SimulateCompareAigAig(const AigMan *p1, const AigMan *p2,
clock_t t0 = clock();
-#ifdef _WIN32
+#if !defined(ABC_HAS_INT128)
for (uint64_t base = 0; base < combs; base += BATCH) {
uint64_t remain = combs - base;
#else
@@ -535,10 +539,10 @@ static int SimulateCompareAigBin(const AigMan *p1, const char *bin,
const uint64_t inMask = u64_mask_n(p1->nCis);
const uint64_t outMask = u64_mask_n(p1->nCos);
-#ifdef _WIN32
- // Windows doesn't support __int128, limit to 32 variables
+#if !defined(ABC_HAS_INT128)
+ // Targets without __int128 are limited to 32 variables
if (nVars > 32) {
- fprintf(stderr, "Error: Windows build supports nVars<=32 (got nVars=%d)\n", nVars);
+ fprintf(stderr, "Error: this build supports nVars<=32 (got nVars=%d)\n", nVars);
return 0;
}
const uint64_t combs = ((uint64_t)1) << (unsigned)nVars;
@@ -565,7 +569,7 @@ static int SimulateCompareAigBin(const AigMan *p1, const char *bin,
uint64_t inVec[BATCH], valid[NW];
unsigned long long rounds = 0;
-#ifdef _WIN32
+#if !defined(ABC_HAS_INT128)
uint64_t patsDone = 0;
#else
unsigned __int128 patsDone = 0;
@@ -573,7 +577,7 @@ static int SimulateCompareAigBin(const AigMan *p1, const char *bin,
clock_t t0 = clock();
-#ifdef _WIN32
+#if !defined(ABC_HAS_INT128)
for (uint64_t base = 0; base < combs; base += BATCH) {
uint64_t remain = combs - base;
#else