summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <wjp@usecode.org>2015-02-25 16:37:36 +0100
committerWillem Jan Palenstijn <wjp@usecode.org>2015-02-25 16:37:36 +0100
commit214a5429db07e3e18af5856e164f850fbabca427 (patch)
treeb9c72b87a1ad931c11153462206afb0464c85d12
parentf619aba4543de6b9a4fe6fb63b6f1840ef509846 (diff)
parent9a60acfc18e72b8aacdc7388617443e9854f4d3b (diff)
downloadastra-214a5429db07e3e18af5856e164f850fbabca427.tar.gz
astra-214a5429db07e3e18af5856e164f850fbabca427.tar.bz2
astra-214a5429db07e3e18af5856e164f850fbabca427.tar.xz
astra-214a5429db07e3e18af5856e164f850fbabca427.zip
Merge pull request #19 from wjp/osx-support
Improve support for OS X
-rwxr-xr-xbuild/linux/autogen.sh7
-rw-r--r--build/linux/configure.ac26
-rw-r--r--include/astra/AsyncAlgorithm.h8
-rw-r--r--include/astra/Globals.h7
-rw-r--r--matlab/mex/astra_mex_algorithm_c.cpp2
-rw-r--r--src/AsyncAlgorithm.cpp26
6 files changed, 14 insertions, 62 deletions
diff --git a/build/linux/autogen.sh b/build/linux/autogen.sh
index c856793..544fdeb 100755
--- a/build/linux/autogen.sh
+++ b/build/linux/autogen.sh
@@ -12,9 +12,12 @@ if test $? -ne 0; then
exit 1
fi
-libtoolize --install --force > /dev/null 2>&1
+case `uname` in Darwin*) LIBTOOLIZEBIN=glibtoolize ;;
+ *) LIBTOOLIZEBIN=libtoolize ;; esac
+
+$LIBTOOLIZEBIN --install --force > /dev/null 2>&1
if test $? -ne 0; then
- libtoolize --force
+ $LIBTOOLIZEBIN --force
if test $? -ne 0; then
echo "Error running libtoolize"
exit 1
diff --git a/build/linux/configure.ac b/build/linux/configure.ac
index cbf6016..24f0124 100644
--- a/build/linux/configure.ac
+++ b/build/linux/configure.ac
@@ -48,32 +48,6 @@ dnl Use iostream to check if the C++ compiler works
AC_CHECK_HEADER(iostream, , AC_MSG_ERROR([No working c++ compiler found]))
-# clock_gettime
-
-AC_MSG_CHECKING([for clock_gettime])
-AC_TRY_LINK([
-#include <ctime>
-],[
-struct timespec t; clock_gettime(CLOCK_REALTIME, &t);
-],astra_clock_gettime_ok=yes,astra_clock_gettime_ok=no)
-AC_MSG_RESULT($astra_clock_gettime_ok)
-if test x$astra_clock_gettime_ok = xno; then
- AC_MSG_CHECKING([for clock_gettime in librt])
- LIBS="$LIBS -lrt"
- AC_TRY_LINK([
- #include <ctime>
- ],[
- struct timespec t; clock_gettime(CLOCK_REALTIME, &t);
- ],astra_clock_gettime_ok=yes,astra_clock_gettime_ok=no)
- AC_MSG_RESULT($astra_clock_gettime_ok)
- if test x$astra_clock_gettime_ok = xno; then
- AC_MSG_ERROR([No clock_gettime found])
- else
- SAVED_LIBS="$SAVED_LIBS -lrt"
- fi
-fi
-
-
# boost-unit-test-framework
AC_MSG_CHECKING([for boost-unit-test-framework])
diff --git a/include/astra/AsyncAlgorithm.h b/include/astra/AsyncAlgorithm.h
index 2d5d31e..a3157fc 100644
--- a/include/astra/AsyncAlgorithm.h
+++ b/include/astra/AsyncAlgorithm.h
@@ -32,14 +32,12 @@ $Id$
#include "Config.h"
#include "Algorithm.h"
-#ifdef __linux__
-#define USE_PTHREADS
+#ifdef USE_PTHREADS
#include <pthread.h>
#else
#include <boost/thread.hpp>
#endif
-
namespace astra {
/**
@@ -75,10 +73,6 @@ public:
*/
virtual void run(int _iNrIterations = 0);
- /** Wait for thread to complete and delete thread.
- */
- virtual void timedJoin(int _milliseconds);
-
/** Return pointer to the wrapped algorithm.
*/
CAlgorithm* getWrappedAlgorithm() { return m_pAlg; }
diff --git a/include/astra/Globals.h b/include/astra/Globals.h
index fdeaa23..9c8ddfb 100644
--- a/include/astra/Globals.h
+++ b/include/astra/Globals.h
@@ -306,4 +306,11 @@ _AstraExport inline bool cudaEnabled() { return false; }
#endif
+//----------------------------------------------------------------------------------------
+// use pthreads on Linux and OSX
+#if defined(__linux__) || defined(__MACH__)
+#define USE_PTHREADS
+#endif
+
+
#endif
diff --git a/matlab/mex/astra_mex_algorithm_c.cpp b/matlab/mex/astra_mex_algorithm_c.cpp
index f719a6b..68342a7 100644
--- a/matlab/mex/astra_mex_algorithm_c.cpp
+++ b/matlab/mex/astra_mex_algorithm_c.cpp
@@ -38,7 +38,7 @@ $Id$
#ifdef USE_MATLAB_UNDOCUMENTED
extern "C" { bool utIsInterruptPending(); }
-#ifdef __linux__
+#ifdef USE_PTHREADS
#define USE_PTHREADS_CTRLC
#include <pthread.h>
#else
diff --git a/src/AsyncAlgorithm.cpp b/src/AsyncAlgorithm.cpp
index fcc4dcb..b265f59 100644
--- a/src/AsyncAlgorithm.cpp
+++ b/src/AsyncAlgorithm.cpp
@@ -160,32 +160,6 @@ void CAsyncAlgorithm::runWrapped(int _iNrIterations)
m_bDone = true;
}
-void CAsyncAlgorithm::timedJoin(int _milliseconds)
-{
-#ifndef USE_PTHREADS
- if (m_pThread) {
- boost::posix_time::milliseconds rel(_milliseconds);
- bool res = m_pThread->timed_join(rel);
- if (res) {
- delete m_pThread;
- m_pThread = 0;
- m_bThreadStarted = false;
- }
- }
-#else
- if (m_bThreadStarted) {
- struct timespec abstime;
- clock_gettime(CLOCK_REALTIME, &abstime);
- abstime.tv_sec += _milliseconds / 1000;
- abstime.tv_nsec += (_milliseconds % 1000) * 1000000L;
- int err = pthread_timedjoin_np(m_thread, 0, &abstime);
- if (err == 0) {
- m_bThreadStarted = false;
- }
- }
-#endif
-}
-
void CAsyncAlgorithm::signalAbort()
{
if (m_pAlg)