From 05500bf7596fab9dc4f995b2f4b87d9188ee3417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Tue, 25 Aug 2015 09:51:16 -0400 Subject: [PATCH] Add local pthread changes. - Move the 3 public headers to a include directory. + pthreads ships a config.h therefore leaving them in the top dir pollutes the include path. - Starting with VS2015, MS defines timespec. Declare to only have it if _MSC_VER >= 1900. - On Linux pthread_t is an integer and you can easily do ==. On Windows pthread_t is a structure and ==/!= have to be overloaded or every use of those operator must be guaded with #ifdef's. --- 3rdparty/pthreads4w/config.h | 4 ++++ 3rdparty/pthreads4w/{ => include}/pthread.h | 21 ++++++++++++++++++- 3rdparty/pthreads4w/{ => include}/sched.h | 0 3rdparty/pthreads4w/{ => include}/semaphore.h | 0 4 files changed, 24 insertions(+), 1 deletion(-) rename 3rdparty/pthreads4w/{ => include}/pthread.h (98%) rename 3rdparty/pthreads4w/{ => include}/sched.h (100%) rename 3rdparty/pthreads4w/{ => include}/semaphore.h (100%) diff --git a/3rdparty/pthreads4w/config.h b/3rdparty/pthreads4w/config.h index e231724e33..32fd3c9f11 100644 --- a/3rdparty/pthreads4w/config.h +++ b/3rdparty/pthreads4w/config.h @@ -137,6 +137,10 @@ #define HAVE_MODE_T #endif +#if _MSC_VER >= 1900 +#define HAVE_STRUCT_TIMESPEC +#endif + #if defined(__BORLANDC__) #endif diff --git a/3rdparty/pthreads4w/pthread.h b/3rdparty/pthreads4w/include/pthread.h similarity index 98% rename from 3rdparty/pthreads4w/pthread.h rename to 3rdparty/pthreads4w/include/pthread.h index b4072f72c6..699a72f36f 100644 --- a/3rdparty/pthreads4w/pthread.h +++ b/3rdparty/pthreads4w/include/pthread.h @@ -116,6 +116,10 @@ # pragma comment(lib, "pthread") #endif +#if _MSC_VER >= 1900 +# define HAVE_STRUCT_TIMESPEC 1 +#endif + /* * ------------------------------------------------------------- * @@ -577,9 +581,24 @@ extern "C" * that available with a simple pointer. It should scale for either * IA-32 or IA-64. */ -typedef struct { +typedef struct ptw32_handle_t { void * p; /* Pointer to actual object */ unsigned int x; /* Extra information - reuse count etc */ + +#ifdef __cplusplus + // Added support for various operators so that the struct is + // more pthreads-compliant in behavior. (air) + const bool operator ==( const struct ptw32_handle_t rightside ) const + { + return p == rightside.p; + } + + const bool operator !=( const struct ptw32_handle_t rightside ) const + { + return p != rightside.p; + } +#endif + } ptw32_handle_t; typedef ptw32_handle_t pthread_t; diff --git a/3rdparty/pthreads4w/sched.h b/3rdparty/pthreads4w/include/sched.h similarity index 100% rename from 3rdparty/pthreads4w/sched.h rename to 3rdparty/pthreads4w/include/sched.h diff --git a/3rdparty/pthreads4w/semaphore.h b/3rdparty/pthreads4w/include/semaphore.h similarity index 100% rename from 3rdparty/pthreads4w/semaphore.h rename to 3rdparty/pthreads4w/include/semaphore.h