From 5708379ebc3886c516b4b946116de9e88b8ed354 Mon Sep 17 00:00:00 2001
From: Philipp Paulweber
Date: Fri, 12 Apr 2019 14:52:00 +0200
Subject: [PATCH] MSYS2 and cmake based compilation support for clang and gcc
---
src/shell/main.cpp | 4 ++++
src/util/hwf.cpp | 14 ++++++++++++--
src/util/warning.cpp | 4 ++++
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/shell/main.cpp b/src/shell/main.cpp
index 1d22ce9b6..68b807f87 100644
--- a/src/shell/main.cpp
+++ b/src/shell/main.cpp
@@ -39,6 +39,10 @@ Revision History:
#include "util/file_path.h"
#include "shell/lp_frontend.h"
+#if defined( _WINDOWS ) && defined( __MINGW32__ ) && ( defined( __GNUG__ ) || defined( __clang__ ) )
+#include
+#endif
+
typedef enum { IN_UNSPECIFIED, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_WCNF, IN_OPB, IN_LP, IN_Z3_LOG, IN_MPS } input_kind;
static std::string g_aux_input_file;
diff --git a/src/util/hwf.cpp b/src/util/hwf.cpp
index 4a7a0b7e4..2c64ad7e3 100644
--- a/src/util/hwf.cpp
+++ b/src/util/hwf.cpp
@@ -21,10 +21,12 @@ Revision History:
#include
#ifdef _WINDOWS
+#if defined(_MSC_VER)
#pragma float_control( except, on ) // exception semantics; this does _not_ mean that exceptions are enabled (we want them off!)
#pragma float_control( precise, on ) // precise semantics (no guessing!)
#pragma fp_contract(off) // contractions off (`contraction' means x*y+z is turned into a fused-mul-add).
#pragma fenv_access(on) // fpu environment sensitivity (needed to be allowed to make FPU mode changes).
+#endif
#else
#include
#endif
@@ -267,6 +269,9 @@ void hwf_manager::fma(mpf_rounding_mode rm, hwf const & x, hwf const & y, hwf co
// IA64 (Itanium) will do it, if contractions are on.
o.value = x.value * y.value + z.value;
#else
+#if defined( __MINGW32__ ) && ( defined( __GNUG__ ) || defined( __clang__ ) )
+ o.value = ::fma(x.value, y.value, z.value);
+#else
#if defined(_WINDOWS)
#if _MSC_VER >= 1800
o.value = ::fma(x.value, y.value, z.value);
@@ -283,6 +288,7 @@ void hwf_manager::fma(mpf_rounding_mode rm, hwf const & x, hwf const & y, hwf co
o.value = ::fma(x.value, y.value, z.value);
#endif
#endif
+#endif
}
#ifdef _M_IA64
@@ -306,7 +312,10 @@ void hwf_manager::round_to_integral(mpf_rounding_mode rm, hwf const & x, hwf & o
// According to the Intel Architecture manual, the x87-instruction FRNDINT is the
// same in 32-bit and 64-bit mode. The _mm_round_* intrinsics are SSE4 extensions.
#ifdef _WINDOWS
-#if defined(USE_INTRINSICS) && \
+#if defined( __MINGW32__ ) && ( defined( __GNUG__ ) || defined( __clang__ ) )
+ o.value = nearbyint(x.value);
+#else
+ #if defined(USE_INTRINSICS) && \
(defined(_WINDOWS) && (defined(__AVX__) || defined(_M_X64))) || \
(!defined(_WINDOWS) && defined(__SSE4_1__))
switch (rm) {
@@ -320,7 +329,7 @@ void hwf_manager::round_to_integral(mpf_rounding_mode rm, hwf const & x, hwf & o
default:
UNREACHABLE(); // Unknown rounding mode.
}
-#else
+ #else
double xv = x.value;
double & ov = o.value;
@@ -329,6 +338,7 @@ void hwf_manager::round_to_integral(mpf_rounding_mode rm, hwf const & x, hwf & o
frndint
fstp ov // Store result away.
}
+ #endif
#endif
#else
// Linux, macOS.
diff --git a/src/util/warning.cpp b/src/util/warning.cpp
index 5ffc38527..7916115d9 100644
--- a/src/util/warning.cpp
+++ b/src/util/warning.cpp
@@ -25,6 +25,10 @@ Revision History:
#include "util/vector.h"
#ifdef _WINDOWS
+#if defined( __MINGW32__ ) && ( defined( __GNUG__ ) || defined( __clang__ ) )
+#include
+#endif
+
#define VPRF vsprintf_s
void STD_CALL myInvalidParameterHandler(