Explicitly allow enabling of pthreads (rather than Qt) using HAVE_PTHREADS on qmake

This commit is contained in:
Matthias Köfferlein 2018-09-09 16:51:20 +02:00
parent 4821b12780
commit a543950316
3 changed files with 32 additions and 23 deletions

View File

@ -67,6 +67,15 @@ equals(HAVE_EXPAT, "1") {
DEFINES += HAVE_EXPAT
}
equals(HAVE_PTHREADS, "1") {
!isEmpty(BITS_PATH) {
include($$BITS_PATH/ptw/ptw.pri)
} else {
LIBS += -lpthread
}
DEFINES += HAVE_PTHREADS
}
equals(HAVE_RUBY, "1") {
!isEmpty(BITS_PATH) {
include($$BITS_PATH/ruby/ruby.pri)
@ -113,12 +122,17 @@ msvc {
-Wno-deprecated-declarations \
-Wno-reserved-user-defined-literal \
win32 {
QMAKE_LFLAGS += -Wl,--exclude-all-symbols
} else {
QMAKE_CXXFLAGS += -fvisibility=hidden
}
}
equals(HAVE_QT, "0") {
QT =
LIBS += -lpthread
} else {
@ -137,17 +151,6 @@ equals(HAVE_QT, "0") {
}
# only support the required symbols for shared object load performance
msvc {
# ...
} else {
win32 {
QMAKE_LFLAGS += -Wl,--exclude-all-symbols
} else {
QMAKE_CXXFLAGS += -fvisibility=hidden
}
}
VERSION_STRING = $$KLAYOUT_VERSION
VERSION_STRING_WITH_BLANKS = $$replace(VERSION_STRING, "\\.", " ")
eval(VERSION_ARRAY = $$VERSION_STRING_WITH_BLANKS)

View File

@ -20,7 +20,7 @@
*/
#if !defined(HAVE_QT)
#if !defined(HAVE_QT) || defined(HAVE_PTHREADS)
#include "tlThreads.h"
#include "tlUtils.h"
@ -29,11 +29,14 @@
#include "tlInternational.h"
#include <map>
#define _TIMESPEC_DEFINED // avoids errors with pthread-win and MSVC2017
#include <pthread.h>
#include <errno.h>
#include <unistd.h>
#if defined(_WIN32)
# include <windows.h>
# define NOMINMAX
# include <Windows.h>
#else
# include <unistd.h>
#endif
namespace tl
@ -291,7 +294,7 @@ bool Thread::wait (unsigned long time)
return false;
}
#if defined(__WIN32)
#if defined(_WIN32)
Sleep (1);
#else
usleep (1000);

View File

@ -27,7 +27,7 @@
#include <limits>
#if defined(HAVE_QT)
#if defined(HAVE_QT) && !defined(HAVE_PTHREADS)
# include <QMutex>
# include <QWaitCondition>
# include <QThread>
@ -46,7 +46,7 @@ namespace tl
* available.
*/
#if defined(HAVE_QT)
#if defined(HAVE_QT) && !defined(HAVE_PTHREADS)
class TL_PUBLIC Mutex
: public QMutex
@ -59,10 +59,13 @@ public:
// The non-Qt version is a dummy implementation as threading is not supported (yet)
class TL_PUBLIC Mutex
: public atomic::spinlock
{
public:
Mutex () : atomic::spinlock () { }
Mutex () : m_spinlock () { }
void lock() { m_spinlock.lock(); }
void unlock() { m_spinlock.unlock(); }
private:
atomic::spinlock m_spinlock;
};
#endif
@ -73,7 +76,7 @@ public:
* available.
*/
#if defined(HAVE_QT)
#if defined(HAVE_QT) && !defined(HAVE_PTHREADS)
class TL_PUBLIC WaitCondition
: public QWaitCondition
@ -131,7 +134,7 @@ private:
* available.
*/
#if defined(HAVE_QT)
#if defined(HAVE_QT) && !defined(HAVE_PTHREADS)
class TL_PUBLIC Thread
: public QThread
@ -177,7 +180,7 @@ private:
* available.
*/
#if defined(HAVE_QT)
#if defined(HAVE_QT) && !defined(HAVE_PTHREADS)
template <class T>
class ThreadStorage