From 520fb5cda65d879596a7e52cd0ae9dc296e87cc9 Mon Sep 17 00:00:00 2001 From: aj Date: Mon, 5 May 2025 11:13:00 +0330 Subject: [PATCH 1/2] =?UTF-8?q?Fix=20error:=20=E2=80=98uint64=5Ft=E2=80=99?= =?UTF-8?q?=20was=20not=20declared=20in=20this=20scope?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/component_types/difference_packed_component.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/component_types/difference_packed_component.h b/src/component_types/difference_packed_component.h index 9a9719b..dd72c31 100644 --- a/src/component_types/difference_packed_component.h +++ b/src/component_types/difference_packed_component.h @@ -12,6 +12,7 @@ #include "component.h" #include +#include From 8f8f1a7c2b7c6e07a3372ba9bc0ff54128ac2ae9 Mon Sep 17 00:00:00 2001 From: aj Date: Mon, 5 May 2025 11:40:22 +0330 Subject: [PATCH 2/2] Support windows compilation --- CMakeLists.txt | 6 +++--- setupdev.sh | 4 +++- src/component_cache.cpp | 48 +++++++++++++++++++++++++---------------- src/main.cpp | 4 ++++ 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 009db2f..99a578f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required (VERSION 2.8) -project (SHARPSAT) +cmake_minimum_required (VERSION 3.5) +project (SHARPSAT) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11 -Wall") @@ -26,4 +26,4 @@ find_library(GMPXX_LIB gmpxx) add_subdirectory(src) add_executable (sharpSAT src/main.cpp) -target_link_libraries (sharpSAT libsharpSAT ${GMP_LIB} ${GMPXX_LIB}) +target_link_libraries (sharpSAT libsharpSAT ${GMP_LIB} ${GMPXX_LIB}) diff --git a/setupdev.sh b/setupdev.sh index f23dfc5..0bbd306 100755 --- a/setupdev.sh +++ b/setupdev.sh @@ -7,16 +7,18 @@ mkdir Release cd Release cmake -DCMAKE_BUILD_TYPE=Release ../.. +# cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DGMP_INCLUDE_DIR=C:\gmp\include -DGMP_LIB=C:\gmp\lib\libgmp.a -DGMPXX_LIB=C:\gmp\lib\libgmpxx.a ../.. cd .. mkdir Debug cd Debug cmake -DCMAKE_BUILD_TYPE=Debug ../.. +# cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DGMP_INCLUDE_DIR=C:\gmp\include -DGMP_LIB=C:\gmp\lib\libgmp.a -DGMPXX_LIB=C:\gmp\lib\libgmpxx.a ../.. cd .. mkdir Profiling cd Profiling cmake -DCMAKE_BUILD_TYPE=Profiling ../.. - +# cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Profiling -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DGMP_INCLUDE_DIR=C:\gmp\include -DGMP_LIB=C:\gmp\lib\libgmp.a -DGMPXX_LIB=C:\gmp\lib\libgmpxx.a ../.. diff --git a/src/component_cache.cpp b/src/component_cache.cpp index 1919639..6de3446 100644 --- a/src/component_cache.cpp +++ b/src/component_cache.cpp @@ -14,12 +14,10 @@ #include #include -uint64_t freeram() { - - struct sysinfo info; - sysinfo(&info); - - return info.freeram *(uint64_t) info.mem_unit; +uint64_t free_ram() { + struct sysinfo info; + sysinfo(&info); + return info.freeram * (uint64_t)info.mem_unit; } #elif __APPLE__ && __MACH__ @@ -27,21 +25,35 @@ uint64_t freeram() { #include #include +uint64_t free_ram() { + int mib[2]; + int64_t physical_memory; + mib[0] = CTL_HW; + mib[1] = HW_MEMSIZE; + size_t length = sizeof(int64_t); + sysctl(mib, 2, &physical_memory, &length, NULL, 0); + return physical_memory; +} -uint64_t freeram() { +#elif defined(_WIN32) - int mib[2]; - int64_t physical_memory; - mib[0] = CTL_HW; - mib[1] = HW_MEMSIZE; - size_t length = sizeof(int64_t); - sysctl(mib, 2, &physical_memory, &length, NULL, 0); +#include - return physical_memory; +uint64_t free_ram() { + MEMORYSTATUSEX memInfo; + memInfo.dwLength = sizeof(MEMORYSTATUSEX); + GlobalMemoryStatusEx(&memInfo); + return memInfo.ullAvailPhys; } #else +// If no OS detected, just return 0 or raise a compile error +uint64_t free_ram() { + return 0; + // or #error "No implementation of free_ram() for this platform" +} + #endif @@ -69,16 +81,16 @@ void ComponentCache::init(Component &super_comp) { free_entry_base_slots_.clear(); free_entry_base_slots_.reserve(10000); - uint64_t free_ram = freeram(); - uint64_t max_cache_bound = 95 * (free_ram / 100); + uint64_t freeram = free_ram(); + uint64_t max_cache_bound = 95 * (freeram / 100); if (statistics_.maximum_cache_size_bytes_ == 0) { statistics_.maximum_cache_size_bytes_ = max_cache_bound; } - if (statistics_.maximum_cache_size_bytes_ > free_ram) { + if (statistics_.maximum_cache_size_bytes_ > freeram) { cout << endl <<" WARNING: Maximum cache size larger than free RAM available" << endl; - cout << " Free RAM " << free_ram / 1000000 << "MB" << endl; + cout << " Free RAM " << freeram / 1000000 << "MB" << endl; } cout << "Maximum cache size:\t" diff --git a/src/main.cpp b/src/main.cpp index 1a95b3f..06f205c 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,7 +8,11 @@ #include #include + +#if defined(__linux__) || defined(__APPLE__) #include +#endif +//#include using namespace std;