From feedbbbea5aafdec05b614a45c0e5e9cdb3a3e6d Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Tue, 6 Dec 2016 21:47:39 +0100 Subject: [PATCH] more fixes related to GH #1453 Conflicts: Foundation/include/Poco/AtomicCounter.h --- Foundation/include/Poco/AtomicCounter.h | 10 ++++++++++ Foundation/src/Clock.cpp | 11 ++++++++++- Foundation/src/Event_POSIX.cpp | 15 ++++++++++++--- Foundation/src/Mutex_POSIX.cpp | 15 ++++++++++++--- Foundation/src/Semaphore_POSIX.cpp | 15 ++++++++++++--- Foundation/src/Timestamp.cpp | 10 +++++----- 6 files changed, 61 insertions(+), 15 deletions(-) diff --git a/Foundation/include/Poco/AtomicCounter.h b/Foundation/include/Poco/AtomicCounter.h index 0554558bb..fd3eb34d9 100644 --- a/Foundation/include/Poco/AtomicCounter.h +++ b/Foundation/include/Poco/AtomicCounter.h @@ -24,7 +24,17 @@ #if POCO_OS == POCO_OS_WINDOWS_NT #include "Poco/UnWindows.h" #elif POCO_OS == POCO_OS_MAC_OS_X +<<<<<<< HEAD #include +======= + #if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12 || __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 || __TV_OS_VERSION_MAX_ALLOWED >= __TVOS_10_0 || __WATCH_OS_VERSION_MAX_ALLOWED >= __WATCHOS_3_0 + #ifndef POCO_HAVE_STD_ATOMICS + #define POCO_HAVE_STD_ATOMICS + #endif + #else + #include + #endif +>>>>>>> c8aa273... more fixes related to GH #1453 #elif ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2) || __GNUC__ > 4) && (defined(__x86_64__) || defined(__i386__)) #if !defined(POCO_HAVE_GCC_ATOMICS) && !defined(POCO_NO_GCC_ATOMICS) #define POCO_HAVE_GCC_ATOMICS diff --git a/Foundation/src/Clock.cpp b/Foundation/src/Clock.cpp index ac95bfc80..abef10a9a 100644 --- a/Foundation/src/Clock.cpp +++ b/Foundation/src/Clock.cpp @@ -34,6 +34,15 @@ #include +#ifndef POCO_HAVE_CLOCK_GETTIME + #if (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) || defined(__QNX__) + #ifndef __APPLE__ // See GitHub issue #1453 - not available before Mac OS 10.12/iOS 10 + #define POCO_HAVE_CLOCK_GETTIME + #endif + #endif +#endif + + namespace Poco { @@ -120,7 +129,7 @@ void Clock::update() #endif _clock = ClockVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000; -#elif (defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)) || defined(__QNX__) +#elif defined(POCO_HAVE_CLOCK_GETTIME) struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) diff --git a/Foundation/src/Event_POSIX.cpp b/Foundation/src/Event_POSIX.cpp index d2fc8c0f5..450f114bf 100644 --- a/Foundation/src/Event_POSIX.cpp +++ b/Foundation/src/Event_POSIX.cpp @@ -31,9 +31,18 @@ // availability of non-standard pthread_cond_timedwait_monotonic(). // #ifndef POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT -#if (defined(__linux__) || defined(__QNX__)) && !(defined(__ANDROID__) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)) -#define POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT 1 + #if (defined(__linux__) || defined(__QNX__)) && !(defined(__ANDROID__) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)) + #define POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT 1 + #endif #endif + + +#ifndef POCO_HAVE_CLOCK_GETTIME + #if (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) || defined(__QNX__) + #ifndef __APPLE__ // See GitHub issue #1453 - not available before Mac OS 10.12/iOS 10 + #define POCO_HAVE_CLOCK_GETTIME + #endif + #endif #endif @@ -127,7 +136,7 @@ bool EventImpl::waitImpl(long milliseconds) abstime.tv_nsec -= 1000000000; abstime.tv_sec++; } -#elif (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) +#elif defined(POCO_HAVE_CLOCK_GETTIME) clock_gettime(CLOCK_REALTIME, &abstime); abstime.tv_sec += milliseconds / 1000; abstime.tv_nsec += (milliseconds % 1000)*1000000; diff --git a/Foundation/src/Mutex_POSIX.cpp b/Foundation/src/Mutex_POSIX.cpp index 26c220383..213375cc1 100644 --- a/Foundation/src/Mutex_POSIX.cpp +++ b/Foundation/src/Mutex_POSIX.cpp @@ -29,9 +29,18 @@ #if defined(_POSIX_TIMEOUTS) && (_POSIX_TIMEOUTS - 200112L) >= 0L -#if defined(_POSIX_THREADS) && (_POSIX_THREADS - 200112L) >= 0L -#define POCO_HAVE_MUTEX_TIMEOUT + #if defined(_POSIX_THREADS) && (_POSIX_THREADS - 200112L) >= 0L + #define POCO_HAVE_MUTEX_TIMEOUT + #endif #endif + + +#ifndef POCO_HAVE_CLOCK_GETTIME + #if (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) || defined(__QNX__) + #ifndef __APPLE__ // See GitHub issue #1453 - not available before Mac OS 10.12/iOS 10 + #define POCO_HAVE_CLOCK_GETTIME + #endif + #endif #endif @@ -73,7 +82,7 @@ bool MutexImpl::tryLockImpl(long milliseconds) { #if defined(POCO_HAVE_MUTEX_TIMEOUT) struct timespec abstime; -#if defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME) +#if defined(POCO_HAVE_CLOCK_GETTIME) clock_gettime(CLOCK_REALTIME, &abstime); abstime.tv_sec += milliseconds / 1000; abstime.tv_nsec += (milliseconds % 1000)*1000000; diff --git a/Foundation/src/Semaphore_POSIX.cpp b/Foundation/src/Semaphore_POSIX.cpp index 57c5dae15..e602410db 100644 --- a/Foundation/src/Semaphore_POSIX.cpp +++ b/Foundation/src/Semaphore_POSIX.cpp @@ -31,9 +31,18 @@ // availability of non-standard pthread_cond_timedwait_monotonic(). // #ifndef POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT -#if (defined(__linux__) || defined(__QNX__)) && !(defined(__ANDROID__) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)) -#define POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT 1 + #if (defined(__linux__) || defined(__QNX__)) && !(defined(__ANDROID__) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)) + #define POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT 1 + #endif #endif + + +#ifndef POCO_HAVE_CLOCK_GETTIME + #if (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) || defined(__QNX__) + #ifndef __APPLE__ // See GitHub issue #1453 - not available before Mac OS 10.12/iOS 10 + #define POCO_HAVE_CLOCK_GETTIME + #endif + #endif #endif @@ -127,7 +136,7 @@ bool SemaphoreImpl::waitImpl(long milliseconds) abstime.tv_nsec -= 1000000000; abstime.tv_sec++; } -#elif (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) +#elif defined(POCO_HAVE_CLOCK_GETTIME) clock_gettime(CLOCK_REALTIME, &abstime); abstime.tv_sec += milliseconds / 1000; abstime.tv_nsec += (milliseconds % 1000)*1000000; diff --git a/Foundation/src/Timestamp.cpp b/Foundation/src/Timestamp.cpp index 62c4c8187..64cce810a 100644 --- a/Foundation/src/Timestamp.cpp +++ b/Foundation/src/Timestamp.cpp @@ -40,11 +40,11 @@ #ifndef POCO_HAVE_CLOCK_GETTIME -#if (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) || defined(__QNX__) -#ifndef __APPLE__ // See GitHub issue #1453 - not available before Mac OS 10.12/iOS 10 -#define POCO_HAVE_CLOCK_GETTIME -#endif -#endif + #if (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) || defined(__QNX__) + #ifndef __APPLE__ // See GitHub issue #1453 - not available before Mac OS 10.12/iOS 10 + #define POCO_HAVE_CLOCK_GETTIME + #endif + #endif #endif