Skip to content

Commit

Permalink
libint-compiler: Fix build on mingw-w64
Browse files Browse the repository at this point in the history
There are still some remaining issues but they need a more changes to configure.ac and Makefiles
  • Loading branch information
MehdiChinoune authored Jun 15, 2024
1 parent d443cee commit 1f86cdd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
3 changes: 0 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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 --------------
Expand Down
4 changes: 2 additions & 2 deletions src/bin/libint/tactic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 7 additions & 2 deletions src/bin/libint/tactic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<unsigned int>(std::floor(nrrs * scale_ * rand / range));
static_cast<unsigned int>(std::floor(nrrs * scale_ * rand_ / range));
return result;
}

Expand Down

0 comments on commit 1f86cdd

Please sign in to comment.