3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-14 18:06:15 +00:00

Added support for FreeBSD

This commit is contained in:
Leonardo de Moura 2012-11-18 00:04:53 -08:00 committed by Leonardo de Moura
parent 89c1785b73
commit 1a3eb3a2ed
4 changed files with 56 additions and 29 deletions

View file

@ -101,15 +101,15 @@ AC_PROG_SED
AS_IF([test "$CXX" = "g++"], [ AS_IF([test "$CXX" = "g++"], [
# Enable OpenMP # Enable OpenMP
CXXFLAGS+=" -fopenmp" CXXFLAGS="$CXXFLAGS -fopenmp"
LDFLAGS+=" -fopenmp" LDFLAGS="$LDFLAGS -fopenmp"
SLIBEXTRAFLAGS+=" -fopenmp" SLIBEXTRAFLAGS="$SLIBEXTRAFLAGS -fopenmp"
# Use -mfpmath=sse # Use -mfpmath=sse
CXXFLAGS+=" -mfpmath=sse" CXXFLAGS="$CXXFLAGS -mfpmath=sse"
], ],
[test "$CXX" = "clang++"], [ [test "$CXX" = "clang++"], [
# OpenMP is not supported in clang++ # OpenMP is not supported in clang++
CXXFLAGS+=" -D _NO_OMP_" CXXFLAGS="$CXXFLAGS -D _NO_OMP_"
], ],
[ [
AC_MSG_ERROR([Unsupported compiler: $CXX]) AC_MSG_ERROR([Unsupported compiler: $CXX])
@ -128,28 +128,38 @@ host_os=`uname -s`
AS_IF([test "$host_os" = "Darwin"], [ AS_IF([test "$host_os" = "Darwin"], [
PLATFORM=osx PLATFORM=osx
SO_EXT=.dylib SO_EXT=.dylib
SLIBFLAGS+="-dynamiclib" SLIBFLAGS="$SLIBFLAGS -dynamiclib"
COMP_VERSIONS="-compatibility_version \$(Z3_VERSION) -current_version \$(Z3_VERSION)" COMP_VERSIONS="-compatibility_version \$(Z3_VERSION) -current_version \$(Z3_VERSION)"
STATIC_FLAGS= STATIC_FLAGS=
], [test "$host_os" = "Linux"], [ ], [test "$host_os" = "Linux"], [
CXXFLAGS=$CXXFLAGS -D _LINUX_
PLATFORM=linux PLATFORM=linux
SO_EXT=.so SO_EXT=.so
LDFLAGS+=" -lrt" LDFLAGS="$LDFLAGS -lrt"
SLIBFLAGS+=" -shared" SLIBFLAGS="$SLIBFLAGS -shared"
COMP_VERSIONS= COMP_VERSIONS=
STATIC_FLAGS=-static STATIC_FLAGS=-static
CXXFLAGS+=" -fno-strict-aliasing" CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
if test "$CXX" = "clang++"; then if test "$CXX" = "clang++"; then
# More flags for clang++ for Linux # More flags for clang++ for Linux
CXXFLAGS+=" -Wno-unknown-pragmas -Wno-overloaded-virtual -Wno-unused-value" CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas -Wno-overloaded-virtual -Wno-unused-value"
fi fi
SLIBEXTRAFLAGS+=" -lrt" SLIBEXTRAFLAGS="$SLIBEXTRAFLAGS -lrt"
], [test "$host_os" = "FreeBSD"], [
CXXFLAGS="$CXXFLAGS -D _FREEBSD_"
PLATFORM=bsd
SO_EXT=.so
LDFLAGS="$LDFLAGS -lrt"
SLIBFLAGS="$SLIBFLAGS -shared"
COMP_VERSIONS=
STATIC_FLAGS=-static
SLIBEXTRAFLAGS="$SLIBEXTRAFLAGS -lrt"
], [test "${host_os:0:6}" = "CYGWIN"], [ ], [test "${host_os:0:6}" = "CYGWIN"], [
PLATFORM=win PLATFORM=win
SO_EXT=.dll SO_EXT=.dll
SLIBFLAGS+="-shared" SLIBFLAGS="$SLIBFLAGS -shared"
COMP_VERSIONS= COMP_VERSIONS=
CXXFLAGS+=" -D_CYGWIN -fno-strict-aliasing" CXXFLAGS="$CXXFLAGS -D_CYGWIN -fno-strict-aliasing"
], ],
[ [
AC_MSG_ERROR([Unknown host platform: $host_os]) AC_MSG_ERROR([Unknown host platform: $host_os])
@ -169,11 +179,11 @@ AC_CHECK_SIZEOF(int *)
if test $ac_cv_sizeof_int_p -eq 8; then if test $ac_cv_sizeof_int_p -eq 8; then
dnl In 64-bit systems we have to compile using -fPIC dnl In 64-bit systems we have to compile using -fPIC
CXXFLAGS+=" -fPIC" CXXFLAGS="$CXXFLAGS -fPIC"
CPPFLAGS+=" -D_AMD64_" CPPFLAGS="$CPPFLAGS -D_AMD64_"
dnl Only enable use of thread local storage for 64-bit Linux. It is disabled for OSX and 32-bit Linux dnl Only enable use of thread local storage for 64-bit Linux. It is disabled for OSX and 32-bit Linux
if test $PLATFORM = "linux"; then if test $PLATFORM = "linux"; then
CPPFLAGS+=" -D_USE_THREAD_LOCAL" CPPFLAGS="$CPPFLAGS -D_USE_THREAD_LOCAL"
fi fi
IS_X64="yes" IS_X64="yes"
else else

View file

@ -197,4 +197,4 @@ protected:
void convert(model * bv_mdl, model * float_mdl); void convert(model * bv_mdl, model * float_mdl);
}; };
#endif #endif

View file

@ -35,4 +35,4 @@ tactic * mk_qffpa_tactic(ast_manager & m, params_ref const & p) {
using_params(mk_simplify_tactic(m, p), sat_simp_p), using_params(mk_simplify_tactic(m, p), sat_simp_p),
mk_sat_tactic(m, p), mk_sat_tactic(m, p),
mk_fail_if_undecided_tactic()); mk_fail_if_undecided_tactic());
} }

View file

@ -33,15 +33,22 @@ Revision History:
#include<sys/time.h> #include<sys/time.h>
#include<sys/errno.h> #include<sys/errno.h>
#include<pthread.h> #include<pthread.h>
#else #elif defined(_LINUX_) || defined(_FREEBSD_)
// Linux // Linux
#include<csignal> #include<csignal>
#include<ctime> #include<ctime>
#include<memory.h> #include<memory.h>
#include"warning.h" #include"warning.h"
#define CLOCKID CLOCK_PROCESS_CPUTIME_ID #ifdef _LINUX_
#define CLOCKID CLOCK_PROCESS_CPUTIME_ID
#else
// FreeBSD does not support CLOCK_PROCESS_CPUTIME_ID
#define CLOCKID CLOCK_PROF
#endif
#define SIG SIGRTMIN #define SIG SIGRTMIN
// --------- // ---------
#else
// Other platforms
#endif #endif
#include"scoped_timer.h" #include"scoped_timer.h"
@ -63,12 +70,14 @@ struct scoped_timer::imp {
pthread_attr_t m_attributes; pthread_attr_t m_attributes;
unsigned m_interval; unsigned m_interval;
pthread_cond_t m_condition_var; pthread_cond_t m_condition_var;
#else #elif defined(_LINUX_) || defined(_FREEBSD_)
// Linux // Linux & FreeBSD
static void * g_timer; static void * g_timer;
void (*m_old_handler)(int); void (*m_old_handler)(int);
void * m_old_timer; void * m_old_timer;
timer_t m_timerid; timer_t m_timerid;
#else
// Other
#endif #endif
#if defined(_WINDOWS) || defined(_CYGWIN) #if defined(_WINDOWS) || defined(_CYGWIN)
@ -117,10 +126,12 @@ struct scoped_timer::imp {
throw default_exception("failed to destroy pthread condition variable"); throw default_exception("failed to destroy pthread condition variable");
return st; return st;
} }
#else #elif defined(_LINUX_)
static void sig_handler(int) { static void sig_handler(int) {
static_cast<imp*>(g_timer)->m_eh->operator()(); static_cast<imp*>(g_timer)->m_eh->operator()();
} }
#else
// Other
#endif #endif
@ -142,8 +153,8 @@ struct scoped_timer::imp {
throw default_exception("failed to initialize timer thread attributes"); throw default_exception("failed to initialize timer thread attributes");
if (pthread_create(&m_thread_id, &m_attributes, &thread_func, this) != 0) if (pthread_create(&m_thread_id, &m_attributes, &thread_func, this) != 0)
throw default_exception("failed to start timer thread"); throw default_exception("failed to start timer thread");
#else #elif defined(_LINUX_) || defined(_FREEBSD_)
// Linux version // Linux & FreeBSD
if (omp_in_parallel()) { if (omp_in_parallel()) {
// It doesn't work in with more than one thread. // It doesn't work in with more than one thread.
// SIGEV_SIGNAL: the event is handled by the process not by the thread that installed the handler. // SIGEV_SIGNAL: the event is handled by the process not by the thread that installed the handler.
@ -172,6 +183,8 @@ struct scoped_timer::imp {
its.it_interval.tv_nsec = 0; its.it_interval.tv_nsec = 0;
if (timer_settime(m_timerid, 0, &its, NULL) == -1) if (timer_settime(m_timerid, 0, &its, NULL) == -1)
throw default_exception("failed to set timer"); throw default_exception("failed to set timer");
#else
// Other platforms
#endif #endif
} }
@ -187,14 +200,16 @@ struct scoped_timer::imp {
throw default_exception("failed to join thread"); throw default_exception("failed to join thread");
if (pthread_attr_destroy(&m_attributes) != 0) if (pthread_attr_destroy(&m_attributes) != 0)
throw default_exception("failed to destroy pthread attributes object"); throw default_exception("failed to destroy pthread attributes object");
#else #elif defined(_LINUX_) || defined(_FREEBSD_)
// Linux version // Linux & FreeBSD
if (omp_in_parallel()) if (omp_in_parallel())
return; // see comments in the constructor. return; // see comments in the constructor.
timer_delete(m_timerid); timer_delete(m_timerid);
if (m_old_handler != SIG_ERR) if (m_old_handler != SIG_ERR)
signal(SIG, m_old_handler); signal(SIG, m_old_handler);
g_timer = m_old_timer; g_timer = m_old_timer;
#else
// Other Platforms
#endif #endif
} }
@ -203,9 +218,11 @@ struct scoped_timer::imp {
#if defined(_WINDOWS) || defined(_CYGWIN) #if defined(_WINDOWS) || defined(_CYGWIN)
#elif defined(__APPLE__) && defined(__MACH__) #elif defined(__APPLE__) && defined(__MACH__)
// Mac OS X // Mac OS X
#else #elif defined(_LINUX_) || defined(_FREEBSD_)
// Linux // Linux & FreeBSD
void * scoped_timer::imp::g_timer = 0; void * scoped_timer::imp::g_timer = 0;
#else
// Other platforms
#endif #endif
scoped_timer::scoped_timer(unsigned ms, event_handler * eh) { scoped_timer::scoped_timer(unsigned ms, event_handler * eh) {