From 83e34638e677ce9c429362ef442b65a27ed17fca Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 24 Mar 2016 15:39:18 +0000 Subject: [PATCH] add support to build with MSVC /Gr (fastcall mode for x86) not enabled by default nor exposed at the moment --- src/shell/datalog_frontend.cpp | 2 +- src/shell/dimacs_frontend.cpp | 2 +- src/shell/main.cpp | 2 +- src/shell/opt_frontend.cpp | 2 +- src/shell/smtlib_frontend.cpp | 2 +- src/util/scoped_ctrl_c.h | 5 +++-- src/util/util.h | 6 ++++++ src/util/warning.cpp | 2 +- 8 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/shell/datalog_frontend.cpp b/src/shell/datalog_frontend.cpp index e802112b2..43ef383d2 100644 --- a/src/shell/datalog_frontend.cpp +++ b/src/shell/datalog_frontend.cpp @@ -109,7 +109,7 @@ static void on_timeout() { exit(0); } -static void on_ctrl_c(int) { +static void STD_CALL on_ctrl_c(int) { signal (SIGINT, SIG_DFL); display_statistics(); raise(SIGINT); diff --git a/src/shell/dimacs_frontend.cpp b/src/shell/dimacs_frontend.cpp index 54e78ac8f..09645a25a 100644 --- a/src/shell/dimacs_frontend.cpp +++ b/src/shell/dimacs_frontend.cpp @@ -47,7 +47,7 @@ static void on_timeout() { exit(0); } -static void on_ctrl_c(int) { +static void STD_CALL on_ctrl_c(int) { signal (SIGINT, SIG_DFL); display_statistics(); raise(SIGINT); diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 22e9770e0..d1a9d21c6 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -291,7 +291,7 @@ char const * get_extension(char const * file_name) { } } -int main(int argc, char ** argv) { +int STD_CALL main(int argc, char ** argv) { try{ unsigned return_value = 0; memory::initialize(0); diff --git a/src/shell/opt_frontend.cpp b/src/shell/opt_frontend.cpp index 0c1a1f1fa..a45800c62 100644 --- a/src/shell/opt_frontend.cpp +++ b/src/shell/opt_frontend.cpp @@ -305,7 +305,7 @@ static void display_statistics() { display_results(); } -static void on_ctrl_c(int) { +static void STD_CALL on_ctrl_c(int) { if (g_opt && g_first_interrupt) { g_opt->get_manager().limit().cancel(); g_first_interrupt = false; diff --git a/src/shell/smtlib_frontend.cpp b/src/shell/smtlib_frontend.cpp index 6c4c01ab0..31c964ae0 100644 --- a/src/shell/smtlib_frontend.cpp +++ b/src/shell/smtlib_frontend.cpp @@ -62,7 +62,7 @@ static void on_timeout() { } } -static void on_ctrl_c(int) { +static void STD_CALL on_ctrl_c(int) { signal (SIGINT, SIG_DFL); #pragma omp critical (g_display_stats) { diff --git a/src/util/scoped_ctrl_c.h b/src/util/scoped_ctrl_c.h index 4459362ac..b79db28fe 100644 --- a/src/util/scoped_ctrl_c.h +++ b/src/util/scoped_ctrl_c.h @@ -20,16 +20,17 @@ Revision History: #define SCOPED_CTRL_C_H_ #include"event_handler.h" +#include"util.h" struct scoped_ctrl_c { event_handler & m_cancel_eh; bool m_first; bool m_once; bool m_enabled; - void (*m_old_handler)(int); + void (STD_CALL *m_old_handler)(int); scoped_ctrl_c * m_old_scoped_ctrl_c; static scoped_ctrl_c * g_obj; - static void on_ctrl_c(int); + static void STD_CALL on_ctrl_c(int); public: // If once == true, then the cancel_eh is invoked only at the first Ctrl-C. // The next time, the old signal handler will take over. diff --git a/src/util/util.h b/src/util/util.h index 39fcb0122..0dfa8ac8c 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -69,6 +69,12 @@ COMPILE_TIME_ASSERT(sizeof(int64) == 8); #define THREAD_LOCAL #endif +#ifdef _MSC_VER +# define STD_CALL __cdecl +#else +# define STD_CALL +#endif + #ifdef __fallthrough # define Z3_fallthrough __fallthrough #elif defined(__has_cpp_attribute) diff --git a/src/util/warning.cpp b/src/util/warning.cpp index 88f807e3c..1105a12f7 100644 --- a/src/util/warning.cpp +++ b/src/util/warning.cpp @@ -28,7 +28,7 @@ Revision History: #define PRF sprintf_s #define VPRF vsprintf_s -void myInvalidParameterHandler( +void STD_CALL myInvalidParameterHandler( const wchar_t* expression, const wchar_t* function, const wchar_t* file,