Files
MINGW-packages/mingw-w64-intel-tbb/tbb-disable_windows_api.patch
2013-12-11 22:52:19 +04:00

815 lines
24 KiB
Diff

diff -ur tbb42_20131003oss.orig/include/tbb/critical_section.h tbb42_20131003oss/include/tbb/critical_section.h
--- tbb42_20131003oss.orig/include/tbb/critical_section.h 2013-11-10 17:41:41.238628564 +0100
+++ tbb42_20131003oss/include/tbb/critical_section.h 2013-11-10 18:20:55.000000000 +0100
@@ -29,12 +29,12 @@
#ifndef _TBB_CRITICAL_SECTION_H_
#define _TBB_CRITICAL_SECTION_H_
-#if _WIN32||_WIN64
+#if USE_WIN32_API
#include "machine/windows_api.h"
#else
#include <pthread.h>
#include <errno.h>
-#endif // _WIN32||WIN64
+#endif // USE_WIN32_API
#include "tbb_stddef.h"
#include "tbb_thread.h"
@@ -46,7 +46,7 @@
namespace internal {
class critical_section_v4 : internal::no_copy {
-#if _WIN32||_WIN64
+#if USE_WIN32_API
CRITICAL_SECTION my_impl;
#else
pthread_mutex_t my_impl;
@@ -57,7 +57,7 @@
void __TBB_EXPORTED_METHOD internal_construct();
critical_section_v4() {
-#if _WIN32||_WIN64
+#if USE_WIN32_API
InitializeCriticalSectionEx( &my_impl, 4000, 0 );
#else
pthread_mutex_init(&my_impl, NULL);
@@ -67,7 +67,7 @@
~critical_section_v4() {
__TBB_ASSERT(my_tid == tbb_thread::id(), "Destroying a still-held critical section");
-#if _WIN32||_WIN64
+#if USE_WIN32_API
DeleteCriticalSection(&my_impl);
#else
pthread_mutex_destroy(&my_impl);
@@ -90,7 +90,7 @@
void lock() {
tbb_thread::id local_tid = this_tbb_thread::get_id();
if(local_tid == my_tid) throw_exception( eid_improper_lock );
-#if _WIN32||_WIN64
+#if USE_WIN32_API
EnterCriticalSection( &my_impl );
#else
int rval = pthread_mutex_lock(&my_impl);
@@ -104,7 +104,7 @@
bool gotlock;
tbb_thread::id local_tid = this_tbb_thread::get_id();
if(local_tid == my_tid) return false;
-#if _WIN32||_WIN64
+#if USE_WIN32_API
gotlock = TryEnterCriticalSection( &my_impl ) != 0;
#else
int rval = pthread_mutex_trylock(&my_impl);
@@ -121,7 +121,7 @@
void unlock() {
__TBB_ASSERT(this_tbb_thread::get_id() == my_tid, "thread unlocking critical_section is not thread that locked it");
my_tid = tbb_thread::id();
-#if _WIN32||_WIN64
+#if USE_WIN32_API
LeaveCriticalSection( &my_impl );
#else
int rval = pthread_mutex_unlock(&my_impl);
diff -ur tbb42_20131003oss.orig/include/tbb/enumerable_thread_specific.h tbb42_20131003oss/include/tbb/enumerable_thread_specific.h
--- tbb42_20131003oss.orig/include/tbb/enumerable_thread_specific.h 2013-11-10 17:41:41.238628564 +0100
+++ tbb42_20131003oss/include/tbb/enumerable_thread_specific.h 2013-11-10 18:59:12.276765061 +0100
@@ -37,7 +37,7 @@
#include "aligned_space.h"
#include <string.h> // for memcpy
-#if _WIN32||_WIN64
+#if USE_WIN32_API
#include "machine/windows_api.h"
#else
#include <pthread.h>
@@ -58,7 +58,7 @@
template<ets_key_usage_type ETS_key_type>
class ets_base: tbb::internal::no_copy {
protected:
-#if _WIN32||_WIN64
+#if USE_WIN32_API
typedef DWORD key_type;
#else
typedef pthread_t key_type;
@@ -245,7 +245,7 @@
template <>
class ets_base<ets_key_per_instance>: protected ets_base<ets_no_key> {
typedef ets_base<ets_no_key> super;
-#if _WIN32||_WIN64
+#if USE_WIN32_API
#if __TBB_WIN8UI_SUPPORT
typedef DWORD tls_key_t;
void create_key() { my_key = FlsAlloc(NULL); }
diff -ur tbb42_20131003oss.orig/include/tbb/mutex.h tbb42_20131003oss/include/tbb/mutex.h
--- tbb42_20131003oss.orig/include/tbb/mutex.h 2013-11-10 17:41:41.238628564 +0100
+++ tbb42_20131003oss/include/tbb/mutex.h 2013-11-10 18:17:24.250352206 +0100
@@ -29,11 +29,11 @@
#ifndef __TBB_mutex_H
#define __TBB_mutex_H
-#if _WIN32||_WIN64
+#if USE_WIN32_API
#include "machine/windows_api.h"
#else
#include <pthread.h>
-#endif /* _WIN32||_WIN64 */
+#endif /* USE_WIN32_API */
#include <new>
#include "aligned_space.h"
@@ -52,13 +52,13 @@
#if TBB_USE_ASSERT || TBB_USE_THREADING_TOOLS
internal_construct();
#else
- #if _WIN32||_WIN64
+ #if USE_WIN32_API
InitializeCriticalSectionEx(&impl, 4000, 0);
#else
int error_code = pthread_mutex_init(&impl,NULL);
if( error_code )
tbb::internal::handle_perror(error_code,"mutex: pthread_mutex_init failed");
- #endif /* _WIN32||_WIN64*/
+ #endif /* USE_WIN32_API*/
#endif /* TBB_USE_ASSERT */
};
@@ -66,12 +66,12 @@
#if TBB_USE_ASSERT
internal_destroy();
#else
- #if _WIN32||_WIN64
+ #if USE_WIN32_API
DeleteCriticalSection(&impl);
#else
pthread_mutex_destroy(&impl);
- #endif /* _WIN32||_WIN64 */
+ #endif /* USE_WIN32_API */
#endif /* TBB_USE_ASSERT */
};
@@ -158,11 +158,11 @@
aligned_space<scoped_lock,1> tmp;
new(tmp.begin()) scoped_lock(*this);
#else
- #if _WIN32||_WIN64
+ #if USE_WIN32_API
EnterCriticalSection(&impl);
#else
pthread_mutex_lock(&impl);
- #endif /* _WIN32||_WIN64 */
+ #endif /* USE_WIN32_API */
#endif /* TBB_USE_ASSERT */
}
@@ -175,11 +175,11 @@
s.my_mutex = NULL;
return s.internal_try_acquire(*this);
#else
- #if _WIN32||_WIN64
+ #if USE_WIN32_API
return TryEnterCriticalSection(&impl)!=0;
#else
return pthread_mutex_trylock(&impl)==0;
- #endif /* _WIN32||_WIN64 */
+ #endif /* USE_WIN32_API */
#endif /* TBB_USE_ASSERT */
}
@@ -191,16 +191,16 @@
s.my_mutex = this;
s.internal_release();
#else
- #if _WIN32||_WIN64
+ #if USE_WIN32_API
LeaveCriticalSection(&impl);
#else
pthread_mutex_unlock(&impl);
- #endif /* _WIN32||_WIN64 */
+ #endif /* USE_WIN32_API */
#endif /* TBB_USE_ASSERT */
}
//! Return native_handle
- #if _WIN32||_WIN64
+ #if USE_WIN32_API
typedef LPCRITICAL_SECTION native_handle_type;
#else
typedef pthread_mutex_t* native_handle_type;
@@ -213,12 +213,12 @@
HELD=0x56CD
};
private:
-#if _WIN32||_WIN64
+#if USE_WIN32_API
CRITICAL_SECTION impl;
enum state_t state;
#else
pthread_mutex_t impl;
-#endif /* _WIN32||_WIN64 */
+#endif /* USE_WIN32_API */
//! All checks from mutex constructor using mutex.state were moved here
void __TBB_EXPORTED_METHOD internal_construct();
@@ -226,7 +226,7 @@
//! All checks from mutex destructor using mutex.state were moved here
void __TBB_EXPORTED_METHOD internal_destroy();
-#if _WIN32||_WIN64
+#if USE_WIN32_API
public:
//! Set the internal state
void set_state( state_t to ) { state = to; }
diff -ur tbb42_20131003oss.orig/include/tbb/recursive_mutex.h tbb42_20131003oss/include/tbb/recursive_mutex.h
--- tbb42_20131003oss.orig/include/tbb/recursive_mutex.h 2013-11-10 17:41:41.238628564 +0100
+++ tbb42_20131003oss/include/tbb/recursive_mutex.h 2013-11-10 18:12:51.041832304 +0100
@@ -29,7 +29,7 @@
#ifndef __TBB_recursive_mutex_H
#define __TBB_recursive_mutex_H
-#if _WIN32||_WIN64
+#if USE_WIN32_API
#include "machine/windows_api.h"
#else
#include <pthread.h>
@@ -51,7 +51,7 @@
#if TBB_USE_ASSERT || TBB_USE_THREADING_TOOLS
internal_construct();
#else
- #if _WIN32||_WIN64
+ #if USE_WIN32_API
InitializeCriticalSectionEx(&impl, 4000, 0);
#else
pthread_mutexattr_t mtx_attr;
@@ -65,7 +65,7 @@
tbb::internal::handle_perror(error_code,"recursive_mutex: pthread_mutex_init failed");
pthread_mutexattr_destroy( &mtx_attr );
- #endif /* _WIN32||_WIN64*/
+ #endif /* USE_WIN32_API*/
#endif /* TBB_USE_ASSERT */
};
@@ -73,12 +73,12 @@
#if TBB_USE_ASSERT
internal_destroy();
#else
- #if _WIN32||_WIN64
+ #if USE_WIN32_API
DeleteCriticalSection(&impl);
#else
pthread_mutex_destroy(&impl);
- #endif /* _WIN32||_WIN64 */
+ #endif /* USE_WIN32_API */
#endif /* TBB_USE_ASSERT */
};
@@ -168,11 +168,11 @@
aligned_space<scoped_lock,1> tmp;
new(tmp.begin()) scoped_lock(*this);
#else
- #if _WIN32||_WIN64
+ #if USE_WIN32_API
EnterCriticalSection(&impl);
#else
pthread_mutex_lock(&impl);
- #endif /* _WIN32||_WIN64 */
+ #endif /* USE_WIN32_API */
#endif /* TBB_USE_ASSERT */
}
@@ -183,11 +183,11 @@
aligned_space<scoped_lock,1> tmp;
return (new(tmp.begin()) scoped_lock)->internal_try_acquire(*this);
#else
- #if _WIN32||_WIN64
+ #if USE_WIN32_API
return TryEnterCriticalSection(&impl)!=0;
#else
return pthread_mutex_trylock(&impl)==0;
- #endif /* _WIN32||_WIN64 */
+ #endif /* USE_WIN32_API */
#endif /* TBB_USE_ASSERT */
}
@@ -199,16 +199,16 @@
s.my_mutex = this;
s.internal_release();
#else
- #if _WIN32||_WIN64
+ #if USE_WIN32_API
LeaveCriticalSection(&impl);
#else
pthread_mutex_unlock(&impl);
- #endif /* _WIN32||_WIN64 */
+ #endif /* USE_WIN32_API */
#endif /* TBB_USE_ASSERT */
}
//! Return native_handle
- #if _WIN32||_WIN64
+ #if USE_WIN32_API
typedef LPCRITICAL_SECTION native_handle_type;
#else
typedef pthread_mutex_t* native_handle_type;
@@ -216,7 +216,7 @@
native_handle_type native_handle() { return (native_handle_type) &impl; }
private:
-#if _WIN32||_WIN64
+#if USE_WIN32_API
CRITICAL_SECTION impl;
enum state_t {
INITIALIZED=0x1234,
diff -ur tbb42_20131003oss.orig/include/tbb/tbb_config.h tbb42_20131003oss/include/tbb/tbb_config.h
--- tbb42_20131003oss.orig/include/tbb/tbb_config.h 2013-11-10 17:41:41.235295249 +0100
+++ tbb42_20131003oss/include/tbb/tbb_config.h 2013-11-10 17:51:45.298689423 +0100
@@ -43,6 +43,12 @@
#include <cstddef>
#endif
+#if !defined(USE_WIN32_API)
+#if _WIN32||_WIN64
+#define USE_WIN32_API 1
+#endif
+#endif
+
#define __TBB_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if __clang__
diff -ur tbb42_20131003oss.orig/include/tbb/tbb_thread.h tbb42_20131003oss/include/tbb/tbb_thread.h
--- tbb42_20131003oss.orig/include/tbb/tbb_thread.h 2013-11-10 17:41:41.238628564 +0100
+++ tbb42_20131003oss/include/tbb/tbb_thread.h 2013-11-10 17:49:42.722686808 +0100
@@ -30,7 +30,7 @@
#define __TBB_tbb_thread_H
#include "tbb_stddef.h"
-#if _WIN32||_WIN64
+#if USE_WIN32_API
#include "machine/windows_api.h"
#define __TBB_NATIVE_THREAD_ROUTINE unsigned WINAPI
#define __TBB_NATIVE_THREAD_ROUTINE_PTR(r) unsigned (WINAPI* r)( void* )
@@ -43,7 +43,7 @@
#define __TBB_NATIVE_THREAD_ROUTINE void*
#define __TBB_NATIVE_THREAD_ROUTINE_PTR(r) void* (*r)( void* )
#include <pthread.h>
-#endif // _WIN32||_WIN64
+#endif // USE_WIN32_API
#include "tick_count.h"
@@ -124,18 +124,18 @@
class tbb_thread_v3 {
tbb_thread_v3(const tbb_thread_v3&); // = delete; // Deny access
public:
-#if _WIN32||_WIN64
+#if USE_WIN32_API
typedef HANDLE native_handle_type;
#else
typedef pthread_t native_handle_type;
-#endif // _WIN32||_WIN64
+#endif // USE_WIN32_API
class id;
//! Constructs a thread object that does not represent a thread of execution.
tbb_thread_v3() : my_handle(0)
-#if _WIN32||_WIN64
+#if USE_WIN32_API
, my_thread_id(0)
-#endif // _WIN32||_WIN64
+#endif // USE_WIN32_API
{}
//! Constructs an object and executes f() in a new thread
@@ -158,10 +158,10 @@
if (joinable()) detach();
my_handle = x.my_handle;
x.my_handle = 0;
-#if _WIN32||_WIN64
+#if USE_WIN32_API
my_thread_id = x.my_thread_id;
x.my_thread_id = 0;
-#endif // _WIN32||_WIN64
+#endif // USE_WIN32_API
return *this;
}
void swap( tbb_thread_v3& t ) {tbb::swap( *this, t );}
@@ -187,9 +187,9 @@
static unsigned __TBB_EXPORTED_FUNC hardware_concurrency();
private:
native_handle_type my_handle;
-#if _WIN32||_WIN64
+#if USE_WIN32_API
thread_id_type my_thread_id;
-#endif // _WIN32||_WIN64
+#endif // USE_WIN32_API
/** Runs start_routine(closure) on another thread and sets my_handle to the handle of the created thread. */
void __TBB_EXPORTED_METHOD internal_start( __TBB_NATIVE_THREAD_ROUTINE_PTR(start_routine),
@@ -199,13 +199,13 @@
};
class tbb_thread_v3::id {
-#if _WIN32||_WIN64
+#if USE_WIN32_API
thread_id_type my_id;
id( thread_id_type id_ ) : my_id(id_) {}
#else
pthread_t my_id;
id( pthread_t id_ ) : my_id(id_) {}
-#endif // _WIN32||_WIN64
+#endif // USE_WIN32_API
friend class tbb_thread_v3;
public:
id() : my_id(0) {}
@@ -229,11 +229,11 @@
}; // tbb_thread_v3::id
tbb_thread_v3::id tbb_thread_v3::get_id() const {
-#if _WIN32||_WIN64
+#if USE_WIN32_API
return id(my_thread_id);
#else
return id(my_handle);
-#endif // _WIN32||_WIN64
+#endif // USE_WIN32_API
}
void __TBB_EXPORTED_FUNC move_v3( tbb_thread_v3& t1, tbb_thread_v3& t2 );
tbb_thread_v3::id __TBB_EXPORTED_FUNC thread_get_id_v3();
@@ -285,11 +285,11 @@
tbb::tbb_thread::native_handle_type h = t1.my_handle;
t1.my_handle = t2.my_handle;
t2.my_handle = h;
-#if _WIN32||_WIN64
+#if USE_WIN32_API
thread_id_type i = t1.my_thread_id;
t1.my_thread_id = t2.my_thread_id;
t2.my_thread_id = i;
-#endif /* _WIN32||_WIN64 */
+#endif /* USE_WIN32_API */
}
namespace this_tbb_thread {
diff -ur tbb42_20131003oss.orig/include/tbb/tick_count.h tbb42_20131003oss/include/tbb/tick_count.h
--- tbb42_20131003oss.orig/include/tbb/tick_count.h 2013-11-10 17:41:41.238628564 +0100
+++ tbb42_20131003oss/include/tbb/tick_count.h 2013-11-10 19:04:34.838350928 +0100
@@ -31,7 +31,7 @@
#include "tbb_stddef.h"
-#if _WIN32||_WIN64
+#if USE_WIN32_API
#include "machine/windows_api.h"
#elif __linux__
#include <ctime>
@@ -81,7 +81,7 @@
interval_t& operator-=( const interval_t& i ) {value -= i.value; return *this;}
private:
static long long ticks_per_second(){
-#if _WIN32||_WIN64
+#if USE_WIN32_API
LARGE_INTEGER qpfreq;
int rval = QueryPerformanceFrequency(&qpfreq);
__TBB_ASSERT_EX(rval, "QueryPerformanceFrequency returned zero");
@@ -112,7 +112,7 @@
inline tick_count tick_count::now() {
tick_count result;
-#if _WIN32||_WIN64
+#if USE_WIN32_API
LARGE_INTEGER qpcnt;
int rval = QueryPerformanceCounter(&qpcnt);
__TBB_ASSERT_EX(rval, "QueryPerformanceCounter failed");
diff -ur tbb42_20131003oss.orig/src/tbb/condition_variable.cpp tbb42_20131003oss/src/tbb/condition_variable.cpp
--- tbb42_20131003oss.orig/src/tbb/condition_variable.cpp 2013-11-10 17:41:41.211962042 +0100
+++ tbb42_20131003oss/src/tbb/condition_variable.cpp 2013-11-10 18:19:34.046315708 +0100
@@ -38,7 +38,7 @@
namespace internal {
//condition_variable
-#if _WIN32||_WIN64
+#if USE_WIN32_API
using tbb::interface5::internal::condition_variable_using_event;
static atomic<do_once_state> condvar_api_state;
@@ -152,11 +152,11 @@
if( dynamic_link( "Kernel32.dll", CondVarLinkTable, 4 ) )
__TBB_destroy_condvar = (void (WINAPI *)(PCONDITION_VARIABLE))&destroy_condvar_noop;
}
-#endif /* _WIN32||_WIN64 */
+#endif /* USE_WIN32_API */
} // namespace internal
-#if _WIN32||_WIN64
+#if USE_WIN32_API
namespace interface5 {
namespace internal {
diff -ur tbb42_20131003oss.orig/src/tbb/governor.cpp tbb42_20131003oss/src/tbb/governor.cpp
--- tbb42_20131003oss.orig/src/tbb/governor.cpp 2013-11-10 17:41:41.215295357 +0100
+++ tbb42_20131003oss/src/tbb/governor.cpp 2013-11-10 19:27:38.447521940 +0100
@@ -236,7 +236,7 @@
generic_scheduler* s = static_cast<generic_scheduler*>(data);
#if TBB_USE_ASSERT
void* current = theTLS.get();
-#if _WIN32||_WIN64
+#if USE_WIN32_API
uintptr_t thread_id = GetCurrentThreadId();
#else
uintptr_t thread_id = uintptr_t(pthread_self());
diff -ur tbb42_20131003oss.orig/src/tbb/mutex.cpp tbb42_20131003oss/src/tbb/mutex.cpp
--- tbb42_20131003oss.orig/src/tbb/mutex.cpp 2013-11-10 17:41:41.215295357 +0100
+++ tbb42_20131003oss/src/tbb/mutex.cpp 2013-11-10 18:16:28.123989602 +0100
@@ -32,7 +32,7 @@
namespace tbb {
void mutex::scoped_lock::internal_acquire( mutex& m ) {
-#if _WIN32||_WIN64
+#if USE_WIN32_API
switch( m.state ) {
case INITIALIZED:
case HELD:
@@ -54,13 +54,13 @@
#else
int error_code = pthread_mutex_lock(&m.impl);
__TBB_ASSERT_EX(!error_code,"mutex::scoped_lock: pthread_mutex_lock failed");
-#endif /* _WIN32||_WIN64 */
+#endif /* USE_WIN32_API */
my_mutex = &m;
}
void mutex::scoped_lock::internal_release() {
__TBB_ASSERT( my_mutex, "mutex::scoped_lock: not holding a mutex" );
-#if _WIN32||_WIN64
+#if USE_WIN32_API
switch( my_mutex->state ) {
case INITIALIZED:
__TBB_ASSERT(false,"mutex::scoped_lock: try to release the lock without acquisition");
@@ -79,12 +79,12 @@
#else
int error_code = pthread_mutex_unlock(&my_mutex->impl);
__TBB_ASSERT_EX(!error_code, "mutex::scoped_lock: pthread_mutex_unlock failed");
-#endif /* _WIN32||_WIN64 */
+#endif /* USE_WIN32_API */
my_mutex = NULL;
}
bool mutex::scoped_lock::internal_try_acquire( mutex& m ) {
-#if _WIN32||_WIN64
+#if USE_WIN32_API
switch( m.state ) {
case INITIALIZED:
case HELD:
@@ -96,10 +96,10 @@
__TBB_ASSERT(false,"mutex::scoped_lock: illegal mutex state");
break;
}
-#endif /* _WIN32||_WIN64 */
+#endif /* USE_WIN32_API */
bool result;
-#if _WIN32||_WIN64
+#if USE_WIN32_API
result = TryEnterCriticalSection(&m.impl)!=0;
if( result ) {
__TBB_ASSERT(m.state!=HELD, "mutex::scoped_lock: deadlock caused by attempt to reacquire held mutex");
@@ -107,26 +107,26 @@
}
#else
result = pthread_mutex_trylock(&m.impl)==0;
-#endif /* _WIN32||_WIN64 */
+#endif /* USE_WIN32_API */
if( result )
my_mutex = &m;
return result;
}
void mutex::internal_construct() {
-#if _WIN32||_WIN64
+#if USE_WIN32_API
InitializeCriticalSectionEx(&impl, 4000, 0);
state = INITIALIZED;
#else
int error_code = pthread_mutex_init(&impl,NULL);
if( error_code )
tbb::internal::handle_perror(error_code,"mutex: pthread_mutex_init failed");
-#endif /* _WIN32||_WIN64*/
+#endif /* USE_WIN32_API*/
ITT_SYNC_CREATE(&impl, _T("tbb::mutex"), _T(""));
}
void mutex::internal_destroy() {
-#if _WIN32||_WIN64
+#if USE_WIN32_API
switch( state ) {
case INITIALIZED:
DeleteCriticalSection(&impl);
@@ -142,7 +142,7 @@
#else
int error_code = pthread_mutex_destroy(&impl);
__TBB_ASSERT_EX(!error_code,"mutex: pthread_mutex_destroy failed");
-#endif /* _WIN32||_WIN64 */
+#endif /* USE_WIN32_API */
}
} // namespace tbb
diff -ur tbb42_20131003oss.orig/src/tbb/recursive_mutex.cpp tbb42_20131003oss/src/tbb/recursive_mutex.cpp
--- tbb42_20131003oss.orig/src/tbb/recursive_mutex.cpp 2013-11-10 17:41:41.215295357 +0100
+++ tbb42_20131003oss/src/tbb/recursive_mutex.cpp 2013-11-10 18:13:50.104845665 +0100
@@ -32,7 +32,7 @@
namespace tbb {
void recursive_mutex::scoped_lock::internal_acquire( recursive_mutex& m ) {
-#if _WIN32||_WIN64
+#if USE_WIN32_API
switch( m.state ) {
case INITIALIZED:
// since we cannot look into the internal of the CriticalSection object
@@ -58,7 +58,7 @@
void recursive_mutex::scoped_lock::internal_release() {
__TBB_ASSERT( my_mutex, "recursive_mutex::scoped_lock: not holding a mutex" );
-#if _WIN32||_WIN64
+#if USE_WIN32_API
switch( my_mutex->state ) {
case INITIALIZED:
LeaveCriticalSection( &my_mutex->impl );
@@ -73,12 +73,12 @@
#else
int error_code = pthread_mutex_unlock(&my_mutex->impl);
__TBB_ASSERT_EX(!error_code, "recursive_mutex::scoped_lock: pthread_mutex_unlock failed");
-#endif /* _WIN32||_WIN64 */
+#endif /* USE_WIN32_API */
my_mutex = NULL;
}
bool recursive_mutex::scoped_lock::internal_try_acquire( recursive_mutex& m ) {
-#if _WIN32||_WIN64
+#if USE_WIN32_API
switch( m.state ) {
case INITIALIZED:
break;
@@ -91,7 +91,7 @@
}
#endif /* _WIN32||_WIN64 */
bool result;
-#if _WIN32||_WIN64
+#if USE_WIN32_API
result = TryEnterCriticalSection(&m.impl)!=0;
#else
result = pthread_mutex_trylock(&m.impl)==0;
@@ -102,7 +102,7 @@
}
void recursive_mutex::internal_construct() {
-#if _WIN32||_WIN64
+#if USE_WIN32_API
InitializeCriticalSectionEx(&impl, 4000, 0);
state = INITIALIZED;
#else
@@ -116,12 +116,12 @@
if( error_code )
tbb::internal::handle_perror(error_code,"recursive_mutex: pthread_mutex_init failed");
pthread_mutexattr_destroy( &mtx_attr );
-#endif /* _WIN32||_WIN64*/
+#endif /* USE_WIN32_API */
ITT_SYNC_CREATE(&impl, _T("tbb::recursive_mutex"), _T(""));
}
void recursive_mutex::internal_destroy() {
-#if _WIN32||_WIN64
+#if USE_WIN32_API
switch( state ) {
case INITIALIZED:
DeleteCriticalSection(&impl);
@@ -137,7 +137,7 @@
#else
int error_code = pthread_mutex_destroy(&impl);
__TBB_ASSERT_EX(!error_code,"recursive_mutex: pthread_mutex_destroy failed");
-#endif /* _WIN32||_WIN64 */
+#endif /* USE_WIN32_API */
}
} // namespace tbb
diff -ur tbb42_20131003oss.orig/src/tbb/tbb_misc.cpp tbb42_20131003oss/src/tbb/tbb_misc.cpp
--- tbb42_20131003oss.orig/src/tbb/tbb_misc.cpp 2013-11-10 17:41:41.211962042 +0100
+++ tbb42_20131003oss/src/tbb/tbb_misc.cpp 2013-11-10 19:33:41.158890297 +0100
@@ -38,7 +38,7 @@
#include <cstdlib>
#include <stdexcept>
-#if _WIN32||_WIN64
+#if USE_WIN32_API
#include "tbb/machine/windows_api.h"
#endif
@@ -101,7 +101,7 @@
#endif /* !TBB_USE_EXCEPTIONS */
}
-#if _WIN32||_WIN64
+#if USE_WIN32_API
void handle_win_error( int error_code ) {
char buf[512];
#if !__TBB_WIN8UI_SUPPORT
@@ -117,7 +117,7 @@
PRINT_ERROR_AND_ABORT( "runtime_error", buf);
#endif /* !TBB_USE_EXCEPTIONS */
}
-#endif // _WIN32||_WIN64
+#endif // USE_WIN32_API
void throw_bad_last_alloc_exception_v4() {
throw_exception_v4(eid_bad_last_alloc);
diff -ur tbb42_20131003oss.orig/src/tbb/tbb_thread.cpp tbb42_20131003oss/src/tbb/tbb_thread.cpp
--- tbb42_20131003oss.orig/src/tbb/tbb_thread.cpp 2013-11-10 17:41:41.215295357 +0100
+++ tbb42_20131003oss/src/tbb/tbb_thread.cpp 2013-11-10 18:08:41.000000000 +0100
@@ -26,7 +26,7 @@
the GNU General Public License.
*/
-#if _WIN32||_WIN64
+#if USE_WIN32_API
#include <process.h> // _beginthreadex()
#endif
#include "tbb_misc.h" // handle_win_error(), ThreadStackSize
@@ -56,7 +56,7 @@
void tbb_thread_v3::join()
{
__TBB_ASSERT( joinable(), "thread should be joinable when join called" );
-#if _WIN32||_WIN64
+#if USE_WIN32_API
#if __TBB_WIN8UI_SUPPORT
std::thread* thread_tmp=(std::thread*)my_thread_id;
thread_tmp->join();
@@ -74,13 +74,13 @@
int status = pthread_join( my_handle, NULL );
if( status )
handle_perror( status, "pthread_join" );
-#endif // _WIN32||_WIN64
+#endif // USE_WIN32_API
my_handle = 0;
}
void tbb_thread_v3::detach() {
__TBB_ASSERT( joinable(), "only joinable thread can be detached" );
-#if _WIN32||_WIN64
+#if USE_WIN32_API
BOOL status = CloseHandle( my_handle );
if ( status == 0 )
handle_win_error( GetLastError() );
@@ -89,13 +89,13 @@
int status = pthread_detach( my_handle );
if( status )
handle_perror( status, "pthread_detach" );
-#endif // _WIN32||_WIN64
+#endif // USE_WIN32_API
my_handle = 0;
}
void tbb_thread_v3::internal_start( __TBB_NATIVE_THREAD_ROUTINE_PTR(start_routine),
void* closure ) {
-#if _WIN32||_WIN64
+#if USE_WIN32_API
#if __TBB_WIN8UI_SUPPORT
std::thread* thread_tmp=new std::thread(start_routine, closure);
my_handle = thread_tmp->native_handle();
@@ -132,7 +132,7 @@
handle_perror( status, "pthread_create" );
my_handle = thread_handle;
-#endif // _WIN32||_WIN64
+#endif // USE_WIN32_API
}
unsigned tbb_thread_v3::hardware_concurrency() {
@@ -140,11 +140,11 @@
}
tbb_thread_v3::id thread_get_id_v3() {
-#if _WIN32||_WIN64
+#if USE_WIN32_API
return tbb_thread_v3::id( GetCurrentThreadId() );
#else
return tbb_thread_v3::id( pthread_self() );
-#endif // _WIN32||_WIN64
+#endif // USE_WIN32_API
}
void move_v3( tbb_thread_v3& t1, tbb_thread_v3& t2 )
@@ -153,10 +153,10 @@
t1.detach();
t1.my_handle = t2.my_handle;
t2.my_handle = 0;
-#if _WIN32||_WIN64
+#if USE_WIN32_API
t1.my_thread_id = t2.my_thread_id;
t2.my_thread_id = 0;
-#endif // _WIN32||_WIN64
+#endif // USE_WIN32_API
}
void thread_yield_v3()