mirror of
https://github.com/debauchee/barrier.git
synced 2024-11-22 15:45:22 +03:00
Merge pull request #585 from chewi/pthread
Use -pthread flag and simplify pthread build logic
This commit is contained in:
commit
dbd10820c3
@ -123,12 +123,10 @@ if (UNIX)
|
|||||||
check_type_size (short SIZEOF_SHORT)
|
check_type_size (short SIZEOF_SHORT)
|
||||||
|
|
||||||
# pthread is used on both Linux and Mac
|
# pthread is used on both Linux and Mac
|
||||||
check_library_exists ("pthread" pthread_create "" HAVE_PTHREAD)
|
set (CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||||
if (HAVE_PTHREAD)
|
set (THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||||
list (APPEND libs pthread)
|
find_package (Threads REQUIRED)
|
||||||
else()
|
list (APPEND libs Threads::Threads)
|
||||||
message (FATAL_ERROR "Missing library: pthread")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# curl is used on both Linux and Mac
|
# curl is used on both Linux and Mac
|
||||||
find_package (CURL)
|
find_package (CURL)
|
||||||
@ -269,7 +267,6 @@ if (UNIX)
|
|||||||
set (HAVE_CXX_EXCEPTIONS 1)
|
set (HAVE_CXX_EXCEPTIONS 1)
|
||||||
set (HAVE_CXX_MUTABLE 1)
|
set (HAVE_CXX_MUTABLE 1)
|
||||||
set (HAVE_CXX_STDLIB 1)
|
set (HAVE_CXX_STDLIB 1)
|
||||||
set (HAVE_PTHREAD_SIGNAL 1)
|
|
||||||
set (SELECT_TYPE_ARG1 int)
|
set (SELECT_TYPE_ARG1 int)
|
||||||
set (SELECT_TYPE_ARG234 " (fd_set *)")
|
set (SELECT_TYPE_ARG234 " (fd_set *)")
|
||||||
set (SELECT_TYPE_ARG5 " (struct timeval *)")
|
set (SELECT_TYPE_ARG5 " (struct timeval *)")
|
||||||
|
@ -55,12 +55,6 @@
|
|||||||
/* Define if you have a POSIX `sigwait` function. */
|
/* Define if you have a POSIX `sigwait` function. */
|
||||||
#cmakedefine HAVE_POSIX_SIGWAIT ${HAVE_POSIX_SIGWAIT}
|
#cmakedefine HAVE_POSIX_SIGWAIT ${HAVE_POSIX_SIGWAIT}
|
||||||
|
|
||||||
/* Define if you have POSIX threads libraries and header files. */
|
|
||||||
#cmakedefine HAVE_PTHREAD ${HAVE_PTHREAD}
|
|
||||||
|
|
||||||
/* Define if you have `pthread_sigmask` and `pthread_kill` functions. */
|
|
||||||
#cmakedefine HAVE_PTHREAD_SIGNAL ${HAVE_PTHREAD_SIGNAL}
|
|
||||||
|
|
||||||
/* Define if your compiler defines socklen_t. */
|
/* Define if your compiler defines socklen_t. */
|
||||||
#cmakedefine HAVE_SOCKLEN_T ${HAVE_SOCKLEN_T}
|
#cmakedefine HAVE_SOCKLEN_T ${HAVE_SOCKLEN_T}
|
||||||
|
|
||||||
|
@ -54,9 +54,7 @@
|
|||||||
# include "arch/unix/ArchConsoleUnix.h"
|
# include "arch/unix/ArchConsoleUnix.h"
|
||||||
# include "arch/unix/ArchDaemonUnix.h"
|
# include "arch/unix/ArchDaemonUnix.h"
|
||||||
# include "arch/unix/ArchLogUnix.h"
|
# include "arch/unix/ArchLogUnix.h"
|
||||||
# if HAVE_PTHREAD
|
|
||||||
# include "arch/unix/ArchMultithreadPosix.h"
|
# include "arch/unix/ArchMultithreadPosix.h"
|
||||||
# endif
|
|
||||||
# include "arch/unix/ArchNetworkBSD.h"
|
# include "arch/unix/ArchNetworkBSD.h"
|
||||||
# include "arch/unix/ArchSleepUnix.h"
|
# include "arch/unix/ArchSleepUnix.h"
|
||||||
# include "arch/unix/ArchStringUnix.h"
|
# include "arch/unix/ArchStringUnix.h"
|
||||||
|
@ -36,17 +36,6 @@
|
|||||||
|
|
||||||
#define SIGWAKEUP SIGUSR1
|
#define SIGWAKEUP SIGUSR1
|
||||||
|
|
||||||
#if !HAVE_PTHREAD_SIGNAL
|
|
||||||
// boy, is this platform broken. forget about pthread signal
|
|
||||||
// handling and let signals through to every process. barrier
|
|
||||||
// will not terminate cleanly when it gets SIGTERM or SIGINT.
|
|
||||||
# define pthread_sigmask sigprocmask
|
|
||||||
# define pthread_kill(tid_, sig_) kill(0, (sig_))
|
|
||||||
# define sigwait(set_, sig_)
|
|
||||||
# undef HAVE_POSIX_SIGWAIT
|
|
||||||
# define HAVE_POSIX_SIGWAIT 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
setSignalSet(sigset_t* sigset)
|
setSignalSet(sigset_t* sigset)
|
||||||
@ -344,9 +333,7 @@ ArchMultithreadPosix::newThread(ThreadFunc func, void* data)
|
|||||||
// can't tell the difference.
|
// can't tell the difference.
|
||||||
if (!m_newThreadCalled) {
|
if (!m_newThreadCalled) {
|
||||||
m_newThreadCalled = true;
|
m_newThreadCalled = true;
|
||||||
#if HAVE_PTHREAD_SIGNAL
|
|
||||||
startSignalHandler();
|
startSignalHandler();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// note that the child thread will wait until we release this mutex
|
// note that the child thread will wait until we release this mutex
|
||||||
|
Loading…
Reference in New Issue
Block a user