From 560b797d79d967a69aa89e2445376d1f555eb18b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?= =?UTF-8?q?=20=28Mehdi=20Chinoune=29?= <79349457+MehdiChinoune@users.noreply.github.com> Date: Sat, 15 Jun 2024 06:28:42 +0100 Subject: [PATCH] libint-compiler: Fix build on mingw-w64 There are still some remaining issues but they need a more changes to configure.ac and Makefiles --- configure.ac | 3 --- src/bin/libint/tactic.cc | 4 ++-- src/bin/libint/tactic.h | 9 +++++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 007753e51..df6ed9fce 100644 --- a/configure.ac +++ b/configure.ac @@ -1269,9 +1269,6 @@ if test "X$have_posix_memalign" != "X0"; then LIBINT_ALIGN_SIZE=0 fi AC_DEFINE_UNQUOTED(LIBINT_ALIGN_SIZE, $LIBINT_ALIGN_SIZE) -else # no posix_memalign = death - echo "did not find posix_memalign ... this SHOULD NOT happen. Cannot proceed." - exit 1 fi dnl ------------------ Check for support for C++11 standard features -------------- diff --git a/src/bin/libint/tactic.cc b/src/bin/libint/tactic.cc index 4650d4a63..08dc1b2bb 100644 --- a/src/bin/libint/tactic.cc +++ b/src/bin/libint/tactic.cc @@ -109,9 +109,9 @@ RandomChoiceTactic::RR RandomChoiceTactic::optimal_rr( const rr_stack& stack) const { if (!stack.empty()) { unsigned int size = stack.size(); - unsigned long rand = random(); + unsigned long rand_ = random(); const unsigned long range = RAND_MAX; - long choice = (long)(rand * size - 1) / range; + long choice = (long)(rand_ * size - 1) / range; return stack[choice]; } else return RR(); diff --git a/src/bin/libint/tactic.h b/src/bin/libint/tactic.h index 4cdec983d..e8327a9f1 100644 --- a/src/bin/libint/tactic.h +++ b/src/bin/libint/tactic.h @@ -27,6 +27,11 @@ #ifndef _libint2_src_bin_libint_tactic_h_ #define _libint2_src_bin_libint_tactic_h_ +#ifdef _WIN32 +#define random rand +#define srandom srand +#endif + namespace libint2 { class DirectedGraph; @@ -208,10 +213,10 @@ class StdRandomizePolicy { } unsigned int noise(unsigned int nrrs) const { - unsigned long rand = random(); + unsigned long rand_ = random(); const unsigned long range = RAND_MAX; const unsigned int result = - static_cast(std::floor(nrrs * scale_ * rand / range)); + static_cast(std::floor(nrrs * scale_ * rand_ / range)); return result; }