Browse Source

removing old unused files

Roberto Parolin 6 years ago
parent
commit
d41668dfae

+ 0 - 2
include/eathread/eathread_sync.h

@@ -59,8 +59,6 @@
 
 #if !EA_THREADS_AVAILABLE
 	// Do nothing.
-#elif defined(EA_PLATFORM_OSX)
-	#include <eathread/powerpc/eathread_sync_powerpc.h>
 #elif defined(EA_PROCESSOR_X86)
 	#include <eathread/x86/eathread_sync_x86.h>
 #elif defined(EA_PROCESSOR_X86_64)

+ 11 - 7
include/eathread/internal/config.h

@@ -109,12 +109,18 @@ EA_RESTORE_VC_WARNING()
 
 
 ///////////////////////////////////////////////////////////////////////////////
-// EA_OPENKODE_THREADS_AVAILABLE
+// EA_POSIX_THREADS_AVAILABLE
 //
 // Defined as 0 or 1
 //
-#ifndef EA_OPENKODE_THREADS_AVAILABLE
-	#define EA_OPENKODE_THREADS_AVAILABLE 0  // used historically on the Marmalade (Airplay) platform.
+#ifndef EA_POSIX_THREADS_AVAILABLE
+	#if defined(__unix__) || defined(__linux__) || defined(__APPLE__) 
+		#define EA_POSIX_THREADS_AVAILABLE 1
+	#elif defined(EA_PLATFORM_SONY)
+	   #define EA_POSIX_THREADS_AVAILABLE 0  // POSIX threading API is present but use is discouraged by Sony.  They want shipping code to use their scePthreads* API.
+	#else
+		#define EA_POSIX_THREADS_AVAILABLE 0
+	#endif
 #endif
 
 
@@ -135,14 +141,12 @@ EA_RESTORE_VC_WARNING()
 
 
 #if EAT_ASSERT_ENABLED
-	#define EAT_STRINGIFY_HELPER(x) #x
-	#define EAT_STRINGIFY(x) EAT_STRINGIFY_HELPER(x)
 	#define EAT_ASSERT(expression) \
 		EA_DISABLE_VC_WARNING(4127) \
 		do { \
 			EA_ANALYSIS_ASSUME(expression); \
 			if (!(expression) ) \
-				EA::Thread::AssertionFailure(__FILE__ "(" EAT_STRINGIFY(__LINE__) "): " #expression); \
+				EA::Thread::AssertionFailure(__FILE__ "(" EA_STRINGIFY(__LINE__) "): " #expression); \
 		} while(0) \
 		EA_RESTORE_VC_WARNING()
 #else
@@ -528,7 +532,7 @@ EA_RESTORE_VC_WARNING()
 // If true then the platform supports a user specified thread affinity mask.
 //
 #ifndef EATHREAD_THREAD_AFFINITY_MASK_SUPPORTED
-	#if   defined(EA_PLATFORM_CAPILANO)
+	#if   defined(EA_PLATFORM_XBOXONE)
 		#define EATHREAD_THREAD_AFFINITY_MASK_SUPPORTED 1
 	#elif defined(EA_PLATFORM_SONY)
 		#define EATHREAD_THREAD_AFFINITY_MASK_SUPPORTED 1

+ 0 - 241
include/eathread/internal/deprecated.h

@@ -1,241 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright (c) Electronic Arts Inc. All rights reserved.
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef EATHREAD_INTERNAL_DEPRECATED_H
-#define EATHREAD_INTERNAL_DEPRECATED_H
-
-#include <EABase/eabase.h>
-
-#if defined(EA_PRAGMA_ONCE_SUPPORTED)
-	#pragma once // Some compilers (e.g. VC++) benefit significantly from using this. We've measured 3-4% build speed improvements in apps as a result.
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// This header provides facilities for nudging users off of deprecated code.
-// 
-// The goal is to provide a gradual migration where users become aware of the
-// accumulated technical debt considerably before they are required to address
-// the problem. To this end, once a feature has been deprecated, we may escalate
-// from warnings, to assertions, to build warnings before actual removal.
-//
-// EATHREAD_REMOVE_DEPRECATED_API				can be defined in client code to force build time errors
-// EATHREAD_DEPRECATED_MEMBER_WARN_ON_USE		generate runtime warnings on write to deprecated members
-// EATHREAD_DEPRECATED_MEMBER_ASSERT_ON_USE		generate runtime assertions on write to deprecated members
-// EATHREAD_DEPRECATED_MEMBER_WARN_ON_BUILD		generate runtime assertions and build warnings on access
-//
-// TODO: consider migrating these facilities to a shared location once they're stable (EAStdC)
-
-///////////////////////////////////////////////////////////////////////////////
-// EATHREAD_REMOVE_DEPRECATED_API
-//
-// Defining this macro in client code will remove any deprecated API from the
-// EAThread public headers. This can be useful to temporarily define locally
-// in dependent modules to find and eliminate any contained code that depends
-// on any deprecated EAThread features.
-//
-// Another approach is to enable broader deprecate culling by defining
-// EA_REMOVE_DEPRECATED_API within the build for the module you wish to
-// eliminate deprecated code. This should remove deprecates for all libraries
-// that support it.
-//
-// Note: Deprecated API culling macros should not be defined globally for a
-// build. Doing so will flag all use of deprecated API across all modules
-// in a game which is typically more noise than desired and makes a piecewise
-// approach more difficult. Instead, define the flags only when building the
-// module where you wish to eliminate use of deprecated code.
-#if defined(EA_REMOVE_DEPRECATED_API)
-	// respect the master control if it has been provided
-	#define EATHREAD_REMOVE_DEPRECATED_API
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// EATHREAD_DEPRECATED_MEMBER_WARN_ON_USE
-//
-// Simplifies the process of disabling public members of EAThread classes when
-// building with deprecated code removed. This macro renames the member variable
-// when deprecate culling is enabled to avoid changing the size of the structure
-// which can cause binary incompatibility issues.
-#if defined(EATHREAD_REMOVE_DEPRECATED_API)
-	// rename deprecated members to trigger a build error
-	#define EATHREAD_DEPRECATED_MEMBER_WARN_ON_USE(Type, Name) EA_DEPRECATED Type EA_PREPROCESSOR_JOIN2(name, _deprecated)
-#else
-	// member enabled, but use runtime deprecation warnings only
-	#define EATHREAD_DEPRECATED_MEMBER_WARN_ON_USE(Type, Name) EA::Thread::DeprecatedMemberWarn<Type> Name
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// EATHREAD_DEPRECATED_MEMBER_ASSERT_ON_USE
-//
-// This is similar to recently deprecated member except that it will generate
-// an assertion failure on assignment.
-#if defined(EATHREAD_REMOVE_DEPRECATED_API)
-	// rename deprecated members to trigger a build error
-	#define EATHREAD_DEPRECATED_MEMBER_ASSERT_ON_USE(Type, Name) EA_DEPRECATED Type EA_PREPROCESSOR_JOIN2(name, _deprecated)
-#else
-	// member enabled, but use runtime assertions only
-	#define EATHREAD_DEPRECATED_MEMBER_ASSERT_ON_USE(Type, Name) EA::Thread::DeprecatedMemberError<Type> Name
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// EATHREAD_DEPRECATED_MEMBER_WARN_ON_BUILD
-//
-// This is similar to deprecated member except that it additionally
-// add deprecation markup which will trigger warnings during the build. Note,
-// this will often get converted into a build error with warnings as error
-// enabled. For this reason, consider using the other macros first.
-#if defined(EATHREAD_REMOVE_DEPRECATED_API)
-	// rename deprecated members to trigger a build error
-	#define EATHREAD_DEPRECATED_MEMBER_WARN_ON_BUILD(Type, Name) EATHREAD_DEPRECATED_MEMBER_ASSERT_ON_USE(Type, Member)
-#else
-	// member enabled, assert on set but also use build-time deprecation warnings
-	#define EATHREAD_DEPRECATED_MEMBER_WARN_ON_BUILD(Type, Name) EA_DEPRECATED EATHREAD_DEPRECATED_MEMBER_ASSERT_ON_USE(Type, Name)
-#endif
-
-namespace EA {
-namespace Thread {
-
-// Issues the given warning if the flag is unset (and sets it), otherwise does nothing.  This can be use to limit the
-// amount of message spam coming from a specific usage.
-EATHREADLIB_API void WarnOnce(bool* pHasTriggered, const char* message);
-EATHREADLIB_API void ErrorOnce(bool* pHasTriggered, const char* message);
-
-// This template allows the creation of classes that implicitly convert to the wrapped type but will warn on assignment.
-// This is useful in removing public member variables from our public API.  The goal here is to provide a softer nudge
-// than a build error.  Deprecation markup on the member is a similar approach but will often trigger a build failure
-// as warnings as errors is commonly enabled.
-// TODO: does not work for types that support dereferencing
-// TODO: also missing other operator forwarding
-template <typename T>
-class DeprecatedMemberWarn
-{
-public:
-#ifdef EA_COMPILER_NO_DEFAULTED_FUNCTIONS
-	DeprecatedMemberWarn(){}
-#else
-	DeprecatedMemberWarn() = default;
-#endif
-	DeprecatedMemberWarn(T rhs): mValue(rhs) {}
-
-	//DeprecatedMemberWarn& operator=(DeprecatedMemberWarn&&) = default; // TODO: Why doesn't this work
-#ifdef EA_COMPILER_NO_DEFAULTED_FUNCTIONS
-	DeprecatedMemberWarn& operator=(const DeprecatedMemberWarn& rhs)
-	{
-		mValue = rhs.mValue;
-		return *this;
-	}
-#else
-	DeprecatedMemberWarn& operator=(const DeprecatedMemberWarn& rhs) = default;
-#endif
-
-	DeprecatedMemberWarn& operator=(const T& rhs)
-	{
-#if EAT_ASSERT_ENABLED
-		static bool hasTriggered = false;
-		WarnOnce(&hasTriggered, "Client code is accessing a deprecated structure member.");
-#endif
-		this->mValue = rhs;
-		return *this;
-	}
-
-	DeprecatedMemberWarn& operator=(T&& rhs)
-	{
-#if EAT_ASSERT_ENABLED
-		static bool hasTriggered = false;
-		WarnOnce(&hasTriggered, "Client code is accessing a deprecated structure member.");
-#endif
-		this->mValue = rhs;
-		return *this;
-	}
-
-	operator T() const
-	{
-#if EAT_ASSERT_ENABLED
-		static bool hasTriggered = false;
-		WarnOnce(&hasTriggered, "Client code is accessing a deprecated structure member.");
-#endif
-		return mValue;
-	}
-
-	// accessor for fetching the value without tripping the error
-	const T& GetValue() const { return mValue; }
-
-	// TODO: use sfinae to enable/disable when the wrapped type supports dereferencing
-	//auto operator->() const
-	//{
-		//return T::operator->(mValue);
-	//}
-
-
-private:
-	T mValue;
-	int foo;
-};
-
-// This template allows the creation of classes that implicitly convert to the wrapped type but will assert on assignment.
-// This is useful in removing public member variables from our public API.  The goal here is to provide a softer nudge
-// than a build error.  Deprecation markup on the member is a similar approach but will often trigger a build failure
-// as warnings as errors is commonly enabled.
-// TODO: does not work for types that support dereferencing
-template <typename T>
-class DeprecatedMemberError
-{
-public:
-#ifdef EA_COMPILER_NO_DEFAULTED_FUNCTIONS
-	DeprecatedMemberError(){};
-#else
-	DeprecatedMemberError() = default;
-#endif
-	DeprecatedMemberError(T rhs): mValue(rhs) {}
-
-	//DeprecatedMemberError& operator=(DeprecatedMemberError&&) = default; // TODO: Why doesn't this work
-#ifdef EA_COMPILER_NO_DEFAULTED_FUNCTIONS
-	DeprecatedMemberError& operator=(const DeprecatedMemberError& rhs)
-	{
-		mValue = rhs.mValue;
-		return *this;
-	};
-#else
-	DeprecatedMemberError& operator=(const DeprecatedMemberError& rhs) = default;
-#endif
-
-	DeprecatedMemberError& operator=(const T& rhs)
-	{
-#if EAT_ASSERT_ENABLED
-		static bool hasTriggered = false;
-		ErrorOnce(&hasTriggered, "Client code is accessing a deprecated structure member.");
-#endif
-		this->mValue = rhs;
-		return *this;
-	}
-
-	DeprecatedMemberError& operator=(T&& rhs)
-	{
-#if EAT_ASSERT_ENABLED
-		static bool hasTriggered = false;
-		ErrorOnce(&hasTriggered, "Client code is accessing a deprecated structure member.");
-#endif
-		this->mValue = rhs;
-		return *this;
-	}
-
-	operator T() const
-	{
-#if EAT_ASSERT_ENABLED
-		static bool hasTriggered = false;
-		ErrorOnce(&hasTriggered, "Client code is accessing a deprecated structure member.");
-#endif
-		return mValue;
-	}
-
-	// accessor for fetching the value without tripping the error
-	const T& GetValue() const { return mValue; }
-
-private:
-	T mValue;
-};
-
-}} // end namespace EA::Thread
-
-#endif
-

+ 0 - 559
include/eathread/powerpc/eathread_atomic_powerpc.h

@@ -1,559 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright (c) Electronic Arts Inc. All rights reserved.
-///////////////////////////////////////////////////////////////////////////////
-
-#if defined(EA_PRAGMA_ONCE_SUPPORTED)
-	#pragma once // Some compilers (e.g. VC++) benefit significantly from using this. We've measured 3-4% build speed improvements in apps as a result.
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// Defines functionality for thread-safe primitive operations.
-/////////////////////////////////////////////////////////////////////////////
-
-
-#ifndef EATHREAD_POWERPC_EATHREAD_ATOMIC_POWERPC_H
-#define EATHREAD_POWERPC_EATHREAD_ATOMIC_POWERPC_H
-
-
-#ifndef INCLUDED_eabase_H
-	#include <EABase/eabase.h>
-#endif
-#ifndef EATHREAD_EATHREAD_SYNC_H
-	#include <eathread/eathread_sync.h>
-#endif
-#include <stddef.h>
-
-
-///////////////////////////////////////////////////////////////////////////////
-// EATHREAD_XTL_H_ENABLED
-//
-// Defined as 0 or 1. Default is 1, for backward compatibility.
-// If enabled then xtl.h is #included below, merely for backward compatibility.
-//
-#ifndef EATHREAD_XTL_H_ENABLED
-	#define EATHREAD_XTL_H_ENABLED 1
-#endif
-///////////////////////////////////////////////////////////////////////////////
-
-
-
-
-#ifdef _MSC_VER
-	 #pragma warning(push)
-	 #pragma warning(disable: 4146)  // unary minus operator applied to unsigned type, result still unsigned
-#endif
-
-
-#if defined(EA_PROCESSOR_POWERPC)
-	#define EA_THREAD_ATOMIC_IMPLEMENTED
-	#define EA_THREAD_ATOMIC_LLR_SUPPORTED (0)
-
-	namespace EA
-	{
-		namespace Thread
-		{
-			/* To do
-			inline int32_t AtomicGetValue(volatile int32_t*)
-				{ }
-			inline void AtomicSetValue(volatile int32_t*, int32_t value)
-				{ }
-			inline int32_t AtomicIncrement(volatile int32_t*)
-				{ }
-			inline int32_t AtomicDecrement(volatile int32_t*)
-				{ }
-			inline int32_t AtomicAdd(volatile int32_t*, int32_t value)
-				{ }
-			inline int32_t AtomicOr(volatile int32_t*, int32_t value)
-				{ }
-			inline int32_t AtomicAnd(volatile int32_t*, int32_t value)
-				{ }
-			inline int32_t AtomicXor(volatile int32_t*, int32_t value)
-				{ }
-			inline int32_t AtomicSwap(volatile int32_t*, int32_t value)
-				{ }
-			inline bool AtomicSetValueConditional(volatile int32_t*, int32_t value, int32_t condition)
-				{ }
-
-			inline uint32_t AtomicGetValue(volatile uint32_t*)
-				{ }
-			inline void AtomicSetValue(volatile uint32_t*, uint32_t value)
-				{ }
-			inline uint32_t AtomicIncrement(volatile uint32_t*)
-				{ }
-			inline uint32_t AtomicDecrement(volatile uint32_t*)
-				{ }
-			inline uint32_t AtomicAdd(volatile uint32_t*, uint32_t value)
-				{ }
-			inline uint32_t AtomicOr(volatile uint32_t*, uint32_t value)
-				{ }
-			inline uint32_t AtomicAnd(volatile uint32_t*, uint32_t value)
-				{ }
-			inline uint32_t AtomicXor(volatile uint32_t*, uint32_t value)
-				{ }
-			inline uint32_t AtomicSwap(volatile uint32_t*, uint32_t value)
-				{ }
-			inline bool AtomicSetValueConditional(volatile uint32_t*, uint32_t value, uint32_t condition)
-				{ }
-
-			inline int64_t AtomicGetValue(volatile int64_t*)
-				{ }
-			inline void AtomicSetValue(volatile int64_t*, int64_t value)
-				{ }
-			inline int64_t AtomicIncrement(volatile int64_t*)
-				{ }
-			inline int64_t AtomicDecrement(volatile int64_t*)
-				{ }
-			inline int64_t AtomicAdd(volatile int64_t*, int64_t value)
-				{ }
-			inline int64_t AtomicOr(volatile int64_t*, int64_t value)
-				{ }
-			inline int64_t AtomicAnd(volatile int64_t*, int64_t value)
-				{ }
-			inline int64_t AtomicXor(volatile int64_t*, int64_t value)
-				{ }
-			inline int64_t AtomicSwap(volatile int64_t*, int64_t value)
-				{ }
-			inline bool AtomicSetValueConditional(volatile int64_t*, int64_t value, int64_t condition)
-				{ }
-
-			inline uint64_t AtomicGetValue(volatile uint64_t*)
-				{ }
-			inline void AtomicSetValue(volatile uint64_t*, uint64_t value)
-				{ }
-			inline uint64_t AtomicIncrement(volatile uint64_t*)
-				{ }
-			inline uint64_t AtomicDecrement(volatile uint64_t*)
-				{ }
-			inline uint64_t AtomicAdd(volatile uint64_t*, uint64_t value)
-				{ }
-			inline uint64_t AtomicOr(volatile uint64_t*, uint64_t value)
-				{ }
-			inline uint64_t AtomicAnd(volatile uint64_t*, uint64_t value)
-				{ }
-			inline uint64_t AtomicXor(volatile uint64_t*, uint64_t value)
-				{ }
-			inline uint64_t AtomicSwap(volatile uint64_t*, uint64_t value)
-				{ }
-			inline bool AtomicSetValueConditional(volatile uint64_t*, uint64_t value, uint64_t condition)
-				{ }
-			*/
-
-
-			template <class T>
-			class AtomicInt
-			{
-			public:
-				typedef AtomicInt<T> ThisType;
-				typedef T            ValueType;
-
-				/// AtomicInt
-				/// Empty constructor. Intentionally leaves mValue in an unspecified state.
-				/// This is done so that an AtomicInt acts like a standard built-in integer.
-				AtomicInt()
-					{}
-
-				AtomicInt(ValueType n) 
-					{ SetValue(n); }
-
-				AtomicInt(const ThisType& x)
-					: mValue(x.GetValue()) {}
-
-				AtomicInt& operator=(const ThisType& x)
-					{ mValue = x.GetValue(); return *this; }
-
-				ValueType GetValueRaw() const
-					{ return mValue; }
-
-				ValueType GetValue() const;
-				ValueType SetValue(ValueType n);
-				bool      SetValueConditional(ValueType n, ValueType condition);
-				ValueType Increment();
-				ValueType Decrement();
-				ValueType Add(ValueType n);
-
-			#if EA_THREAD_ATOMIC_LLR_SUPPORTED
-				ValueType Reserve(void* spuScratch = NULL);
-				bool      StoreConditionalReserved(ValueType n, void* spuScratch = NULL);
-			#endif
-
-				// operators
-				inline            operator const ValueType() const { return GetValue(); }  // Should this be provided? Is it safe enough? Return value of 'const' attempts to make this safe from misuse.
-				inline ValueType  operator =(ValueType n)          {        SetValue(n); return n; }
-				inline ValueType  operator+=(ValueType n)          { return Add(n);}
-				inline ValueType  operator-=(ValueType n)          { return Add(-n);}
-				inline ValueType  operator++()                     { return Increment();}
-				inline ValueType  operator++(int)                  { return Increment() - 1;}
-				inline ValueType  operator--()                     { return Decrement(); }
-				inline ValueType  operator--(int)                  { return Decrement() + 1;}
-
-			protected:
-				volatile ValueType mValue;
-			};
-
-				// Template specializations for Generic PowerPC: Macintosh OSX, etc.
-			#if defined(CS_UNDEFINED_STRING) || defined(EA_COMPILER_GNUC) 
-
-				template <> inline
-				AtomicInt<int32_t>::ValueType AtomicInt<int32_t>::GetValue() const
-				{
-					// The version below uses lwarx directly and not a lwarx/stwcx loop. 
-					// You would want the loop if you are on an SMP system and want the 
-					// returned value to be reflective of the last store to the address
-					// (which would be our store). The downside to the loop is that it 
-					// would be slower due to the extra instruction and due to an extra
-					// memory synchronization event.
-					ValueType nValue;
-					#if (EA_MEMORY_BARRIERS_REQUIRED == 0)
-						__asm__ __volatile__("lwarx  %0,0,%1"
-											: "=&b" (nValue) : "b" (&mValue) : "cc", "memory");
-					#else
-						__asm__ __volatile__("1: lwarx  %0,0,%1\n\
-												 stwcx. %0,0,%1\n\
-												  bne 1b"
-											   : "=&b" (nValue) : "b" (&mValue) : "cc", "memory");
-					#endif
-					return nValue;
-				}
-
-				template <> inline
-				AtomicInt<uint32_t>::ValueType AtomicInt<uint32_t>::GetValue() const
-				{
-					ValueType nValue;
-					#if (EA_MEMORY_BARRIERS_REQUIRED == 0)
-						__asm__ __volatile__("lwarx  %0,0,%1"
-											: "=&b" (nValue) : "b" (&mValue) : "cc", "memory");
-					#else
-						__asm__ __volatile__("1: lwarx  %0,0,%1\n\
-												 stwcx. %0,0,%1\n\
-												 bne 1b"
-											   : "=&b" (nValue) : "b" (&mValue) : "cc", "memory");
-					#endif
-					return nValue;
-				}
-
-				template <> inline
-				AtomicInt<int32_t>::ValueType AtomicInt<int32_t>::SetValue(ValueType n)
-				{
-					ValueType nOriginalValue;
-					__asm__ __volatile__("1: lwarx  %0,0,%2\n\
-											 stwcx. %1,0,%2\n\
-											 bne-    1b"
-										  : "=&b" (nOriginalValue) : "r" (n), "b" (&mValue) : "cc", "memory");
-					return nOriginalValue;
-				}
-
-				template <> inline
-				AtomicInt<uint32_t>::ValueType AtomicInt<uint32_t>::SetValue(ValueType n)
-				{
-					ValueType nOriginalValue;
-					__asm__ __volatile__("1: lwarx  %0,0,%2\n\
-											 stwcx. %1,0,%2\n\
-											 bne-    1b" 
-										   : "=&b" (nOriginalValue) : "r" (n), "b" (&mValue) : "cc", "memory");
-					return nOriginalValue;
-				}
-
-				template <> inline
-				bool AtomicInt<int32_t>::SetValueConditional(ValueType n, ValueType condition)
-				{
-					ValueType nOriginalValue;
-					__asm__ __volatile__("\n\
-										  1: lwarx  %0,0,%1 \n\
-											 cmpw    0,%0,%2 \n\
-											 bne     2f \n\
-											 stwcx. %3,0,%1 \n\
-											 bne-    1b\n"
-										  "2:"
-											: "=&b" (nOriginalValue)
-											: "b" (&mValue), "r" (condition), "r" (n)
-											: "cc", "memory");
-					return (condition == nOriginalValue);
-				}
-
-				template <> inline
-				bool AtomicInt<uint32_t>::SetValueConditional(ValueType n, ValueType condition)
-				{
-					ValueType nOriginalValue;
-					__asm__ __volatile__("\n\
-										 1: lwarx  %0,0,%1 \n\
-											cmpw    0,%0,%2 \n\
-											bne     2f \n\
-											stwcx. %3,0,%1 \n\
-											bne-    1b\n"
-										"2:"
-											: "=&b" (nOriginalValue)
-											: "b" (&mValue), "r" (condition), "r" (n)
-											: "cc", "memory");
-					return (condition == nOriginalValue);
-				}
-
-				template <> inline
-				AtomicInt<int32_t>::ValueType AtomicInt<int32_t>::Increment()
-				{
-					ValueType nNewValue;
-					__asm__ __volatile__("1: lwarx  %0,0,%1\n\
-											 addi    %0,%0,1\n\
-											 stwcx. %0,0,%1\n\
-											 bne-    1b"
-										   : "=&b" (nNewValue) : "b" (&mValue) : "cc", "memory");
-					return nNewValue;
-				}
-
-				template <> inline
-				AtomicInt<uint32_t>::ValueType AtomicInt<uint32_t>::Increment()
-				{
-					ValueType nNewValue;
-					__asm__ __volatile__("1: lwarx  %0,0,%1\n\
-											 addi    %0,%0,1\n\
-											 stwcx. %0,0,%1\n\
-											 bne-    1b"
-										   : "=&b" (nNewValue) : "b" (&mValue) : "cc", "memory");
-					return nNewValue;
-				}
-
-				template <> inline
-				AtomicInt<int32_t>::ValueType AtomicInt<int32_t>::Decrement()
-				{
-					ValueType nNewValue;
-					__asm__ __volatile__("1: lwarx  %0,0,%1\n\
-											 addi    %0,%0,-1\n\
-											 stwcx. %0,0,%1\n\
-											 bne-    1b"
-										   : "=&b" (nNewValue) : "b" (&mValue) : "cc", "memory");
-					return nNewValue;
-				}
-
-				template <> inline
-				AtomicInt<uint32_t>::ValueType AtomicInt<uint32_t>::Decrement()
-				{
-					ValueType nNewValue;
-					__asm__ __volatile__("1: lwarx  %0,0,%1\n\
-											 addi    %0,%0,-1\n\
-											 stwcx. %0,0,%1\n\
-											 bne-    1b"
-										   : "=&b" (nNewValue) : "b" (&mValue) : "cc", "memory");
-					return nNewValue;
-				}
-
-				template <> inline
-				AtomicInt<int32_t>::ValueType AtomicInt<int32_t>::Add(ValueType n)
-				{
-					ValueType nNewValue;
-					__asm__ __volatile__("1: lwarx    %0,0,%2\n\
-											 add      %0,%1,%0\n\
-											 stwcx.  %0,0,%2\n\
-											 bne-     1b"
-										   : "=&b" (nNewValue) : "r" (n), "b" (&mValue) : "cc", "memory");
-					return nNewValue;
-				}
-
-				template <> inline
-				AtomicInt<uint32_t>::ValueType AtomicInt<uint32_t>::Add(ValueType n)
-				{
-					ValueType nNewValue;
-					__asm__ __volatile__("1: lwarx    %0,0,%2\n\
-											 add      %0,%1,%0\n\
-											 stwcx.  %0,0,%2\n\
-											 bne-     1b"
-										   : "=&b" (nNewValue) : "r" (n), "b" (&mValue) : "cc", "memory");
-					return nNewValue;
-				}
-
-			#endif // EA_COMPILER_GNUC
-
-			#if (defined(EA_PLATFORM_WORD_SIZE) && (EA_PLATFORM_WORD_SIZE >= 8)) // If we have PowerPC64...
-
-				#if defined(EA_COMPILER_GNUC)
-
-					template <> inline
-					AtomicInt<int64_t>::ValueType AtomicInt<int64_t>::GetValue() const
-					{
-						// The version below uses lwarx directly and not a ldarx/stdcx loop. 
-						// You would want the loop if you are on an SMP system and want the 
-						// returned value to be reflective of the last store to the address
-						// (which would be our store). The downside to the loop is that it 
-						// would be slower due to the extra instruction and due to an extra
-						// memory synchronization event.
-						ValueType nValue;
-						#if (EA_MEMORY_BARRIERS_REQUIRED == 0)
-							 __asm__ __volatile__("ldarx  %0,0,%1"
-												: "=&b" (nValue) : "b" (&mValue) : "cc", "memory");
-						#else
-							 __asm__ __volatile__("1: ldarx  %0,0,%1\n\
-													  stdcx. %0,0,%1\n\
-													  bne 1b"
-													: "=&b" (nValue) : "b" (&mValue) : "cc", "memory");
-						#endif
-						return nValue;
-					}
-
-					template <> inline
-					AtomicInt<uint64_t>::ValueType AtomicInt<uint64_t>::GetValue() const
-					{
-						ValueType nValue;
-						#if (EA_MEMORY_BARRIERS_REQUIRED == 0)
-							 __asm__ __volatile__("ldarx  %0,0,%1"
-												   : "=&b" (nValue) : "b" (&mValue) : "cc", "memory");
-						#else
-							 __asm__ __volatile__("1: ldarx  %0,0,%1\n\
-													  stdcx. %0,0,%1\n\
-													  bne 1b"
-													: "=&b" (nValue) : "b" (&mValue) : "cc", "memory");
-						#endif
-						return nValue;
-					}
-
-					template <> inline
-					AtomicInt<int64_t>::ValueType AtomicInt<int64_t>::SetValue(ValueType n)
-					{
-						ValueType nOriginalValue;
-						__asm__ __volatile__("1: ldarx  %0,0,%2\n\
-												 stdcx. %1,0,%2\n\
-												 bne-    1b" 
-											   : "=&b" (nOriginalValue) : "r" (n), "b" (&mValue) : "cc", "memory");
-						return nOriginalValue;
-					}
-
-					template <> inline
-					AtomicInt<uint64_t>::ValueType AtomicInt<uint64_t>::SetValue(ValueType n)
-					{
-						ValueType nOriginalValue;
-						__asm__ __volatile__("1: ldarx  %0,0,%2\n\
-												 stdcx. %1,0,%2\n\
-												 bne-    1b" 
-											   : "=&b" (nOriginalValue) : "r" (n), "b" (&mValue) : "cc", "memory");
-						return nOriginalValue;
-					}
-
-					template <> inline
-					bool AtomicInt<int64_t>::SetValueConditional(ValueType n, ValueType condition)
-					{
-						ValueType nOriginalValue;
-						__asm__ __volatile__("\n\
-											1: ldarx  %0,0,%1 \n\
-												cmpd    0,%0,%2 \n\
-												bne     2f \n\
-												stdcx. %3,0,%1 \n\
-												bne-    1b\n"
-											"2:"
-												: "=&b" (nOriginalValue)
-												: "b" (&mValue), "r" (condition), "r" (n)
-												: "cc", "memory");
-						return (condition == nOriginalValue);
-					}
-
-					template <> inline
-					bool AtomicInt<uint64_t>::SetValueConditional(ValueType n, ValueType condition)
-					{
-						ValueType nOriginalValue;
-						__asm__ __volatile__("\n\
-											1: ldarx  %0,0,%1 \n\
-												cmpd    0,%0,%2 \n\
-												bne     2f \n\
-												stdcx. %3,0,%1 \n\
-												bne-    1b\n"
-											"2:"
-												: "=&b" (nOriginalValue)
-												: "b" (&mValue), "r" (condition), "r" (n)
-												: "cc", "memory");
-						return (condition == nOriginalValue);
-					}
-
-					template <> inline
-					AtomicInt<int64_t>::ValueType AtomicInt<int64_t>::Increment()
-					{
-						ValueType nNewValue;
-						__asm__ __volatile__("1: ldarx  %0,0,%1\n\
-												 addi    %0,%0,1\n\
-												 stdcx. %0,0,%1\n\
-												 bne-    1b"
-											   : "=&b" (nNewValue) : "b" (&mValue) : "cc", "memory");
-						return nNewValue;
-					}
-
-					template <> inline
-					AtomicInt<uint64_t>::ValueType AtomicInt<uint64_t>::Increment()
-					{
-						ValueType nNewValue;
-						__asm__ __volatile__("1: ldarx  %0,0,%1\n\
-												 addi    %0,%0,1\n\
-												 stdcx. %0,0,%1\n\
-												 bne-    1b"
-											   : "=&b" (nNewValue) : "b" (&mValue) : "cc", "memory");
-						return nNewValue;
-					}
-
-					template <> inline
-					AtomicInt<int64_t>::ValueType AtomicInt<int64_t>::Decrement()
-					{
-						ValueType nNewValue;
-						__asm__ __volatile__("1: ldarx  %0,0,%1\n\
-												 addi    %0,%0,-1\n\
-												 stdcx. %0,0,%1\n\
-												 bne-    1b"
-											   : "=&b" (nNewValue) : "b" (&mValue) : "cc", "memory");
-						return nNewValue;
-					}
-
-					template <> inline
-					AtomicInt<uint64_t>::ValueType AtomicInt<uint64_t>::Decrement()
-					{
-						ValueType nNewValue;
-						__asm__ __volatile__("1: ldarx  %0,0,%1\n\
-												 addi    %0,%0,-1\n\
-												 stdcx. %0,0,%1\n\
-												 bne-    1b"
-											   : "=&b" (nNewValue) : "b" (&mValue) : "cc", "memory");
-						return nNewValue;
-					}
-
-					template <> inline
-					AtomicInt<int64_t>::ValueType AtomicInt<int64_t>::Add(ValueType n)
-					{
-						ValueType nNewValue;
-						__asm__ __volatile__("1: ldarx    %0,0,%2\n\
-												 add      %0,%1,%0\n\
-												 stdcx.  %0,0,%2\n\
-												 bne-     1b"
-											   : "=&b" (nNewValue) : "r" (n), "b" (&mValue) : "cc", "memory");
-						return nNewValue;
-					}
-
-					template <> inline
-					AtomicInt<uint64_t>::ValueType AtomicInt<uint64_t>::Add(ValueType n)
-					{
-						ValueType nNewValue;
-						__asm__ __volatile__("1: ldarx    %0,0,%2\n\
-												 add      %0,%1,%0\n\
-												 stdcx.  %0,0,%2\n\
-												 bne-     1b"
-											   : "=&b" (nNewValue) : "r" (n), "b" (&mValue) : "cc", "memory");
-						return nNewValue;
-					}
-
-				#endif
-
-			#endif
-
-		} // namespace Thread
-
-	} // namespace EA
-
-
-#endif // EA_PROCESSOR_XXXX
-
-
-#ifdef _MSC_VER
-	 #pragma warning(pop)
-#endif
-
-
-#endif // EATHREAD_POWERPC_EATHREAD_ATOMIC_POWERPC_H
-
-
-
-
-
-
-
-

+ 0 - 31
include/eathread/powerpc/eathread_sync_powerpc.h

@@ -1,31 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright (c) Electronic Arts Inc. All rights reserved.
-///////////////////////////////////////////////////////////////////////////////
-
-#if defined(EA_PRAGMA_ONCE_SUPPORTED)
-	#pragma once // Some compilers (e.g. VC++) benefit significantly from using this. We've measured 3-4% build speed improvements in apps as a result.
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// Functionality related to memory and code generation synchronization.
-/////////////////////////////////////////////////////////////////////////////
-
-
-#ifndef EATHREAD_POWERPC_EATHREAD_SYNC_POWERPC_H
-#define EATHREAD_POWERPC_EATHREAD_SYNC_POWERPC_H
-
-
-#ifndef INCLUDED_eabase_H
-	#include <EABase/eabase.h>
-#endif
-
-
-#endif // EATHREAD_POWERPC_EATHREAD_SYNC_POWERPC_H
-
-
-
-
-
-
-
-

+ 1 - 1
include/eathread/x86-64/eathread_sync_x86-64.h

@@ -69,7 +69,7 @@
 		#define EAReadBarrier()      _ReadBarrier()
 		#define EAWriteBarrier()     _WriteBarrier()
 		#define EAReadWriteBarrier() _ReadWriteBarrier()
-	#elif defined(EA_PLATFORM_KETTLE)
+	#elif defined(EA_PLATFORM_PS4)
 		#define EAReadBarrier()      __asm__ __volatile__ ("lfence" ::: "memory");
 		#define EAWriteBarrier()     __asm__ __volatile__ ("sfence" ::: "memory");
 		#define EAReadWriteBarrier() __asm__ __volatile__ ("mfence" ::: "memory");

+ 0 - 42
source/deprecated.cpp

@@ -1,42 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright (c) Electronic Arts Inc. All rights reserved.
-///////////////////////////////////////////////////////////////////////////////
-
-#include <eathread/internal/config.h>
-#include "eathread/internal/deprecated.h"
-#include <eathread/eathread.h>
-#include <stdio.h>
-
-namespace EA {
-namespace Thread {
-		
-EATHREADLIB_API void WarnOnce(bool* pHasTriggered, const char* message)
-{
-	EA_UNUSED(pHasTriggered);
-	EA_UNUSED(message);
-#if EAT_ASSERT_ENABLED
-	if (*pHasTriggered == false)
-	{
-		*pHasTriggered = true;
-		// TODO: redirect to debug printing in EAStdC once we have a dependency
-		printf("[EAThread] ***Warning*** %s\n", message);
-	}
-#endif
-}
-
-EATHREADLIB_API void ErrorOnce(bool* pHasTriggered, const char* message)
-{
-	EA_UNUSED(pHasTriggered);
-	EA_UNUSED(message);
-#if EAT_ASSERT_ENABLED
-	if (*pHasTriggered == false)
-	{
-		*pHasTriggered = true;
-		EAT_FAIL_MSG(message);
-	}
-#endif
-}
-
-}} // end namespace EA::Thread
-
-

+ 0 - 6
source/eathread_condition.cpp

@@ -21,12 +21,6 @@ EA_RESTORE_VC_WARNING()
 	#include <eathread/eathread_condition.h>
 	#include <string.h>
 
-
-	#ifdef _MSC_VER
-		#pragma warning(disable: 4996) // This function or variable may be unsafe / deprecated.
-	#endif
-
-
 	EAConditionData::EAConditionData()
 	   : mnWaitersBlocked(0), mnWaitersToUnblock(0), mnWaitersDone(0),
 		 mSemaphoreBlockQueue(NULL, false), // We will be initializing these ourselves specifically below.

+ 1 - 1
source/kettle/eathread_semaphore_kettle.cpp

@@ -166,7 +166,7 @@
 		return mSemaphoreData.mnCount.GetValue();
 	}
 
-#endif // EA_PLATFORM_KETTLE
+#endif // EA_PLATFORM_SONY
 
 
 

+ 0 - 140
source/openkode/eathread_semaphore_openkode.cpp

@@ -1,140 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright (c) Electronic Arts Inc. All rights reserved.
-///////////////////////////////////////////////////////////////////////////////
-
-#include <EABase/eabase.h>
-#include <eathread/eathread_semaphore.h>
-
-
-#if EA_OPENKODE_THREADS_AVAILABLE
-	#include <time.h>
-	#include <errno.h>
-	#include <string.h>
-	#include <limits.h>
-	#include <KD/kd.h>
-
-
-	EASemaphoreData::EASemaphoreData()
-	  : mpSemaphore(NULL),
-		mnCount(0),
-		mnMaxCount(INT_MAX)
-	{
-	}
-
-
-	EA::Thread::SemaphoreParameters::SemaphoreParameters(int initialCount, bool bIntraProcess, const char* /*pName*/)
-	  : mInitialCount(initialCount),
-		mMaxCount(INT_MAX),
-		mbIntraProcess(bIntraProcess) // OpenKODE doesn't support inter-process semaphores.
-	{
-	}
-
-
-	EA::Thread::Semaphore::Semaphore(const SemaphoreParameters* pSemaphoreParameters, bool bDefaultParameters)
-	{
-		if(!pSemaphoreParameters && bDefaultParameters)
-		{
-			SemaphoreParameters parameters;
-			Init(&parameters);
-		}
-		else
-			Init(pSemaphoreParameters);
-	}
-
-
-	EA::Thread::Semaphore::Semaphore(int initialCount)
-	{
-		SemaphoreParameters parameters(initialCount);
-		Init(&parameters);
- 
-	}
-
-
-	EA::Thread::Semaphore::~Semaphore()
-	{
-		const KDint result = kdThreadSemFree(mSemaphoreData.mpSemaphore); (void)result;
-		EAT_ASSERT(result == 0);
-	}
-
-
-	bool EA::Thread::Semaphore::Init(const SemaphoreParameters* pSemaphoreParameters)
-	{
-		if(pSemaphoreParameters)
-		{
-			mSemaphoreData.mnCount        = pSemaphoreParameters->mInitialCount;
-			mSemaphoreData.mnMaxCount     = pSemaphoreParameters->mMaxCount;
-			mSemaphoreData.mpSemaphore    = kdThreadSemCreate((KDuint)mSemaphoreData.mnCount);
-
-			return (mSemaphoreData.mpSemaphore != NULL);
-		}
-
-		return false;
-	}
-
-
-	int EA::Thread::Semaphore::Wait(const ThreadTime& timeoutAbsolute)
-	{
-		KDint result = kdThreadSemWait(mSemaphoreData.mpSemaphore);
-
-		if(result != 0)
-		{
-			EAT_ASSERT(false); // This is an error condition.
-			return kResultError;
-		}
-
-		EAT_ASSERT(mSemaphoreData.mnCount > 0);
-		return (int)mSemaphoreData.mnCount.Decrement(); // AtomicInt32 operation. Note that the value of the semaphore count could change from the returned value by the time the caller reads it. This is fine but the user should understand this.
-	}
-
-
-	int EA::Thread::Semaphore::Post(int count)
-	{
-		// Some systems have a sem_post_multiple which we could take advantage 
-		// of here to atomically post multiple times.
-		EAT_ASSERT(mSemaphoreData.mnCount >= 0);
-
-		// It's hard to correctly implement mnMaxCount here, given that it 
-		// may be modified by multiple threads during this execution. So if you want
-		// to use max-count with an IntraProcess semaphore safely then you need to 
-		// post only from a single thread, or at least a single thread at a time.
-		
-		int currentCount = mSemaphoreData.mnCount;
-
-		// If count would cause an overflow exit early
-		if ((mSemaphoreData.mnMaxCount - count) < currentCount)
-			return kResultError;
-
-				currentCount += count;
-
-		while(count-- > 0)
-		{
-			++mSemaphoreData.mnCount;     // AtomicInt32 operation.
-
-			if(kdThreadSemPost(mSemaphoreData.mpSemaphore) != 0)
-			{
-				--mSemaphoreData.mnCount; // AtomicInt32 operation.
-				EAT_ASSERT(false);
-				return kResultError;        
-			}
-		}
-
-		// If all count posts occurred...
-		return currentCount; // It's possible that another thread may have modified this value since we changed it, but that's not important.
-	}
-
-
-	int EA::Thread::Semaphore::GetCount() const
-	{
-		return (int)mSemaphoreData.mnCount;
-	}
-
-
-#endif // EA_PLATFORM_XXX
-
-
-
-
-
-
-
-

+ 1 - 1
source/pc/eathread_callstack_win64.cpp

@@ -299,7 +299,7 @@ EATHREADLIB_API size_t GetCallstack(void* pReturnAddressArray[], size_t nReturnA
 			context.ContextFlags = CONTEXT_ALL; // Actually we should need only CONTEXT_INTEGER, so let's test that next chance we get.
 			RtlCaptureContext(&context);
 
-		#elif defined(EA_PLATFORM_CAPILANO) // This probably isn't limited to just this platform, but until we can test any other platforms we'll leave it at just this.
+		#elif defined(EA_PLATFORM_XBOXONE) // This probably isn't limited to just this platform, but until we can test any other platforms we'll leave it at just this.
 			return RtlCaptureStackBackTrace(1, (ULONG)nReturnAddressArrayCapacity, pReturnAddressArray, NULL);
 
 		#else

+ 0 - 6
source/pc/eathread_mutex_pc.cpp

@@ -16,12 +16,6 @@
 #endif
 
 
-#ifdef _MSC_VER
-	#pragma warning(disable: 4996) // This function or variable may be unsafe / deprecated.
-#endif
-
-
-
 #if defined(EA_PLATFORM_MICROSOFT) && !EA_POSIX_THREADS_AVAILABLE
 	#if defined(EA_PLATFORM_WINDOWS)
 		extern "C" WINBASEAPI BOOL WINAPI TryEnterCriticalSection(_Inout_ LPCRITICAL_SECTION lpCriticalSection);

+ 8 - 8
source/pc/eathread_pc.cpp

@@ -418,7 +418,7 @@ EATHREADLIB_API bool EA::Thread::SetThreadPriority(int nPriority)
 
 	// Windows process running in NORMAL_PRIORITY_CLASS is picky about the priority passed in.
 	// So we need to set the priority to the next priority supported
-	#if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_CAPILANO)
+	#if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_XBOXONE)
 		HANDLE thread = GetCurrentThread();
 
 		while(!result)
@@ -440,7 +440,7 @@ EATHREADLIB_API bool EA::Thread::SetThreadPriority(int nPriority)
 
 EATHREADLIB_API void EA::Thread::SetThreadProcessor(int nProcessor)
 {
-	#if   defined(EA_PLATFORM_CAPILANO)
+	#if   defined(EA_PLATFORM_XBOXONE)
 
 		DWORD mask = 0xFF; //Default to all
 		if (nProcessor >= 0)
@@ -587,7 +587,7 @@ EATHREADLIB_API void EA::Thread::SetThreadAffinityMask(const EA::Thread::ThreadI
 	}
 
 #if EATHREAD_THREAD_AFFINITY_MASK_SUPPORTED
-	#if defined(EA_PLATFORM_CAPILANO)
+	#if defined(EA_PLATFORM_XBOXONE)
 		DWORD_PTR nProcessorCountMask = 0x7F;  // default to all 7 available cores.
 	#else
 		DWORD_PTR nProcessorCountMask = (DWORD_PTR)1 << GetProcessorCount(); 
@@ -629,7 +629,7 @@ namespace Internal {
 
 		bool result = true;
 
-	#if (defined(EA_PLATFORM_CAPILANO) && EA_CAPILANO_DBG_ENABLED == 1)
+	#if (defined(EA_PLATFORM_XBOXONE) && EA_CAPILANO_DBG_ENABLED == 1)
 		wchar_t wName[EATHREAD_NAME_SIZE];
 		mbstowcs(wName, pName, EATHREAD_NAME_SIZE);
 		result = (::SetThreadName(threadId, wName) == TRUE); // requires toolhelpx.lib
@@ -693,7 +693,7 @@ namespace Internal {
 		strncpy(pTDD->mName, pName, EATHREAD_NAME_SIZE);
 		pTDD->mName[EATHREAD_NAME_SIZE - 1] = 0;
 
-	#if defined(EA_PLATFORM_WINDOWS) && defined(_MSC_VER) || (defined(EA_PLATFORM_CAPILANO))
+	#if defined(EA_PLATFORM_WINDOWS) && defined(_MSC_VER) || (defined(EA_PLATFORM_XBOXONE))
 		if(pTDD->mName[0] && (pTDD->mhThread != EA::Thread::kThreadIdInvalid))
 		{
 			#if EATHREAD_NAMING == EATHREAD_NAMING_DISABLED
@@ -737,7 +737,7 @@ EATHREADLIB_API const char* EA::Thread::GetThreadName(const EA::Thread::ThreadId
 
 EATHREADLIB_API int EA::Thread::GetProcessorCount()
 {
-	#if defined(EA_PLATFORM_CAPILANO)
+	#if defined(EA_PLATFORM_XBOXONE)
 		// Capilano has 7-ish physical CPUs available to titles.  We can access 50 - 90% of the 7th Core.  
 		// Check platform documentation for details.
 	    DWORD_PTR ProcessAffinityMask;
@@ -819,12 +819,12 @@ void EA::Thread::ThreadEnd(intptr_t threadReturnValue)
 
 	EA::Thread::SetCurrentThreadHandle(kThreadIdInvalid, true); // We use 'true' here just to be safe, as we don't know who is calling this function.
 
-	#if defined(EA_PLATFORM_CAPILANO)
+	#if defined(EA_PLATFORM_XBOXONE)
 		// _endthreadex is not supported on Capilano because it's not compatible with C++/CX and /ZW.  Use of ExitThread could result in memory leaks
 		// as ExitThread does not clean up memory allocated by the C runtime library.
 		// https://forums.xboxlive.com/AnswerPage.aspx?qid=47c1607c-bb18-4bc4-a79a-a40c59444ff3&tgt=1        
 		ExitThread(static_cast<DWORD>(threadReturnValue));
-	#elif defined(EA_PLATFORM_MICROSOFT) && defined(EA_PLATFORM_CONSOLE) && !defined(EA_PLATFORM_CAPILANO)
+	#elif defined(EA_PLATFORM_MICROSOFT) && defined(EA_PLATFORM_CONSOLE) && !defined(EA_PLATFORM_XBOXONE)
 		EAT_FAIL_MSG("EA::Thread::ThreadEnd: Not supported by this platform.");
 	#else
 		_endthreadex((unsigned int)threadReturnValue);

+ 8 - 9
source/pc/eathread_thread_pc.cpp

@@ -43,7 +43,6 @@ EA_DISABLE_VC_WARNING(6312 6322)
 
 
 	#ifdef _MSC_VER
-		#pragma warning(disable: 4996) // This function or variable may be unsafe / deprecated.
 		#ifndef EATHREAD_INIT_SEG_DEFINED
 			#define EATHREAD_INIT_SEG_DEFINED 
 		#endif
@@ -341,7 +340,7 @@ EA_DISABLE_VC_WARNING(6312 6322)
 			mThreadData.mpData->Release();
 	}
 
-  #if defined(EA_PLATFORM_CAPILANO)
+  #if defined(EA_PLATFORM_XBOXONE)
 	static DWORD WINAPI RunnableFunctionInternal(void* pContext)
   #else
 	static unsigned int __stdcall RunnableFunctionInternal(void* pContext)
@@ -442,7 +441,7 @@ EA_DISABLE_VC_WARNING(6312 6322)
 
 		const unsigned nStackSize = pTP ? (unsigned)pTP->mnStackSize : 0;
 
-		#if defined(EA_PLATFORM_CAPILANO)
+		#if defined(EA_PLATFORM_XBOXONE)
 			// Capilano no longer supports _beginthreadex. Using CreateThread instead may cause issues when using the MS CRT 
 			// according to MSDN (memory leaks or possibly crashes) as it does not initialize the CRT. This a reasonable
 			// workaround while we wait for clarification from MS on what the recommended threading APIs are for Capilano.
@@ -462,7 +461,7 @@ EA_DISABLE_VC_WARNING(6312 6322)
 			if(pTP && (pTP->mnPriority != kThreadPriorityDefault))
 				SetPriority(pTP->mnPriority);
 
-			#if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_CAPILANO)
+			#if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_XBOXONE)
 			if (pTP)
 			{
 				auto result = SetThreadPriorityBoost(pData->mhThread, pTP->mbDisablePriorityBoost);
@@ -492,7 +491,7 @@ EA_DISABLE_VC_WARNING(6312 6322)
 		return (ThreadId)kThreadIdInvalid;
 	}
 
-  #if defined(EA_PLATFORM_CAPILANO)
+  #if defined(EA_PLATFORM_XBOXONE)
 	static DWORD WINAPI RunnableObjectInternal(void* pContext)
   #else
 	static unsigned int __stdcall RunnableObjectInternal(void* pContext)
@@ -553,7 +552,7 @@ EA_DISABLE_VC_WARNING(6312 6322)
 		pData->mnThreadAffinityMask = pTP ? pTP->mnAffinityMask : kThreadAffinityMaskAny;
 		const unsigned nStackSize     = pTP ? (unsigned)pTP->mnStackSize : 0;
 
-		#if defined(EA_PLATFORM_CAPILANO)
+		#if defined(EA_PLATFORM_XBOXONE)
 			// Capilano no longer supports _beginthreadex. Using CreateThread instead may cause issues when using the MS CRT 
 			// according to MSDN (memory leaks or possibly crashes) as it does not initialize the CRT. This a reasonable
 			// workaround while we wait for clarification from MS on what the recommended threading APIs are for Capilano.
@@ -574,7 +573,7 @@ EA_DISABLE_VC_WARNING(6312 6322)
 			if(pTP && (pTP->mnPriority != kThreadPriorityDefault))
 				SetPriority(pTP->mnPriority);
 
-			#if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_CAPILANO)
+			#if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_XBOXONE)
 			if (pTP)
 			{
 				auto result = SetThreadPriorityBoost(pData->mhThread, pTP->mbDisablePriorityBoost);
@@ -733,7 +732,7 @@ EA_DISABLE_VC_WARNING(6312 6322)
 
 			// Windows process running in NORMAL_PRIORITY_CLASS is picky about the priority passed in.
 			// So we need to set the priority to the next priority supported
-			#if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_CAPILANO)
+			#if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_XBOXONE)
 				while(!result)
 				{
 					if(nNewPriority >= THREAD_PRIORITY_TIME_CRITICAL) 
@@ -758,7 +757,7 @@ EA_DISABLE_VC_WARNING(6312 6322)
 	{
 		if(mThreadData.mpData)
 		{
-			#if defined(EA_PLATFORM_CAPILANO)
+			#if defined(EA_PLATFORM_XBOXONE)
 
 				static int nProcessorCount = GetProcessorCount();
 				if(nProcessor >= nProcessorCount)

+ 1 - 0
source/unix/eathread_unix.cpp

@@ -4,6 +4,7 @@
 
 
 #include <EABase/eabase.h>
+#include <EABase/eahave.h>
 #include <eathread/eathread.h>
 #include <eathread/eathread_thread.h>
 

+ 0 - 92
test/performance/source/PerfTestThread.cpp

@@ -1,92 +0,0 @@
-////////////////////////////////////////////////////////////////////////
-// PerfTestThread.cpp
-// 
-// Copyright (c) 2014, Electronic Arts Inc. All rights reserved.
-////////////////////////////////////////////////////////////////////////
-
-#include <benchmarkenvironment/test.h>
-#include <coreallocator/icoreallocator_interface.h>
-#include <EAMain/EAEntryPointMain.inl>
-#include <EAStdC/EAString.h>
-#include <EATest/EATest.h>
-#include <eathread/eathread.h>
-#include <MemoryMan/CoreAllocator.inl>
-#include <MemoryMan/MemoryMan.inl>
-
-#include "PerfTestThread.h"
-
-using namespace benchmarkenvironment;
-
-// TODO: Releases of benchmarkenvironmrnt with version numbers higher than 4.00
-//       will include a new macro that will replace most of this code. Presently, that macro
-//       cannot be used because it redefines operator new*.
-
-// The "BENCHMARKENVIRONMENT_TESTFUNCTION" macro redefines the new and new[] operators here, which causes a compiler error.
-// This code has been removed.
-EA_PREFIX_ALIGN(128) char gWorkMemory[BENCHMARKENVIRONMENT_WORKMEMORY_SIZE] EA_POSTFIX_ALIGN(128);
-EA_PREFIX_ALIGN(128) char gResultMemory[BENCHMARKENVIRONMENT_RESULTMEMORY_SIZE] EA_POSTFIX_ALIGN(128);
-
-int EAMain(int argc, char **argv)
-{
-	
-	Initialize(argc, argv, BENCHMARKENVIRONMENT_STRINGIZE(BENCHMARKENVIRONMENT_DEFAULT_TABLE_IDENTIFIER));
-	SetFlagsValid();
-	BenchmarkEnvironmentTestFunction(gWorkMemory, sizeof(gWorkMemory), gResultMemory, sizeof(gResultMemory));
-	Complete(BENCHMARKENVIRONMENT_RESULTPASSED);
-	return 0;
-}
-
-void BenchmarkEnvironmentTestFunction(Address /*workMemory*/, unsigned int /*workSize*/, Address resultMemory,	unsigned int resultSize)
-{
-
-	typedef void(*PerfTestFunction)(Results&, EA::IO::FileStream*);
-	typedef eastl::vector<PerfTestFunction> PerfTestFunctions;
-
-	PerfTestFunctions perfTestFunctions;
-	perfTestFunctions.push_back(&PerfTestThreadAtomic);
-	perfTestFunctions.push_back(&PerfTestThreadSemaphore);
-
-	// EATHREAD_PERFORMANCE_LOG_FILENAME is set in the build file. Right now it should be ${config}-performance_log.txt
-	EA::IO::FileStream performanceLog(EATHREAD_PERFORMANCE_LOG_FILENAME);
-
-	if (!gIsAutomatedDeferredRun)
-	{
-		// If this is a local run, create a performance log for the evaluation function to look at.
-		performanceLog.Open(EA::IO::kAccessFlagWrite, EA::IO::kCDCreateAlways);
-
-		// This loggin is mostly here so that we have a way to know that this code is NOT running
-		// in the build farm context. It could be removed once that has been confirmed.
-		EA::UnitTest::Report("Local Execution -> Performance Logging Enabled\n");
-	}
-
-	// Outline the structure of the results table
-	// We can do this out here because all of the tests will submit to the same table.
-	Results resultsTable(resultMemory, resultSize);
-	const int kNumColumns = 5;
-	resultsTable.DescribeTableBegin(kNumColumns);
-	resultsTable.AddStringField("Test Name");
-	resultsTable.AddDoubleField("Mean", "s");
-	resultsTable.AddDoubleField("Min", "s");
-	resultsTable.AddDoubleField("Max", "s");
-	resultsTable.AddDoubleField("Var", "s^2");
-	resultsTable.DescribeTableEnd();
-
-	for (unsigned int i = 0; i < perfTestFunctions.size(); ++i)
-	{
-		if (gIsAutomatedDeferredRun)
-			perfTestFunctions[i](resultsTable, NULL);
-		else
-			perfTestFunctions[i](resultsTable, &performanceLog);
-	}
-
-	if (!gIsAutomatedDeferredRun)
-	{
-		performanceLog.Close();
-
-		EA::UnitTest::Report("Log file written.\n");
-	}
-
-	return;
-}
-
-

+ 0 - 49
test/performance/source/PerfTestThread.h

@@ -1,49 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright (c) Electronic Arts Inc. All rights reserved.
-///////////////////////////////////////////////////////////////////////////////
-
-
-#ifndef PERFTESTTHREAD_H
-#define PERFTESTTHREAD_H
-
-#include <eathread/eathread_thread.h>
-#include <benchmarkenvironment/results.h>
-#include <benchmarkenvironment/statistics.h>
-#include <EAIO/EAFileStream.h>
-#include <EAStdC/EASprintf.h>
-
-typedef intptr_t(*ThreadEntryFunction)(void*);
-
-void PerfTestThreadAtomic(benchmarkenvironment::Results &results, EA::IO::FileStream* pLogFileStream);
-void PerfTestThreadSemaphore(benchmarkenvironment::Results &results, EA::IO::FileStream* pLogFileStream);
-
-inline void WriteToLogFile(EA::IO::FileStream* pLogFile, const char* formatString, ...)
-{
-	if(pLogFile)
-	{
-		const int kLogBufferSize = 256;
-		char8_t buffer[kLogBufferSize];
-
-		va_list arguments;
-		va_start(arguments, formatString);
-
-		int numCharsWritten = EA::StdC::Vsnprintf(buffer, kLogBufferSize, formatString, arguments);
-
-		va_end(arguments);
-
-		pLogFile->Write(buffer, numCharsWritten);
-	}
-}
-
-inline void AddRowToResults(benchmarkenvironment::Results& results, benchmarkenvironment::Sample& sample, eastl::string testName)
-{
-	results.Begin();
-	results.Add(testName.c_str());
-	results.Add(sample.GetMean());
-	results.Add(sample.GetMin());
-	results.Add(sample.GetMax());
-	results.Add(sample.GetVariance());
-	results.End();
-}
-
-#endif

+ 0 - 129
test/performance/source/PerfTestThreadAtomic.cpp

@@ -1,129 +0,0 @@
-////////////////////////////////////////////////////////////////////////
-// PerfTestThreadAtomic.cpp
-// 
-// Copyright (c) 2014, Electronic Arts Inc. All rights reserved.
-////////////////////////////////////////////////////////////////////////
-
-#include "benchmarkenvironment/results.h"
-#include "benchmarkenvironment/statistics.h"
-#include "benchmarkenvironment/timer.h"
-
-#include "eathread/eathread_atomic.h"
-#include "eathread/eathread_thread.h"
-#include "EATest/EATest.h"
-
-#include "PerfTestThread.h"
-
-using namespace EA::Thread;
-
-#if EA_THREADS_AVAILABLE
-
-// ------------------------------------------------------------------------
-// Each thread that is involved in these tests will get its own independent timer, and a 
-// shared atomic variable. With each thread doing its own timing, we should be able to 
-// remove scheduling noise to the greatest degree possible.
-//
-struct AtomicAndTimer 
-{
-	static AtomicInt32 mAtomicInteger;
-	benchmarkenvironment::Timer mLocalTimer;
-};
-
-AtomicInt32 AtomicAndTimer::mAtomicInteger = 0;
-
-// ------------------------------------------------------------------------
-//
-static intptr_t AtomicIntMath(void* pWorkStructure) 
-{
-	AtomicAndTimer& at = *static_cast<AtomicAndTimer*>(pWorkStructure);
-
-	// A series of atomic operations copied from the atomic unit test
-	at.mLocalTimer.Start();
-
-	++(at.mAtomicInteger);
-	--(at.mAtomicInteger);
-	(at.mAtomicInteger) += 5;
-	(at.mAtomicInteger) -= 5;
-	(at.mAtomicInteger)++;
-	(at.mAtomicInteger)--;
-
-	at.mLocalTimer.Stop();
-
-	return 0;
-}
-
-// --------------------------------------------------------------------------
-//
-// todo:  come up with a performance test for CAS operations.
-// static intptr_t AtomicIntCompareAndSwap(void* pArgs)
-// {
-//     AtomicAndTimer& at = static_cast<AtomicAndTimer&>(*pArgs);
-// 
-//     toCAS->mLocalTimer.Start();
-//     toCAS->mAtomicInteger.SetValueConditional(0, 1);
-//     toCAS->mLocalTimer.Stop();
-// 
-//     return 0;
-// }
-
-// ---------------------------------------------------------------------------
-//
-void AtomicIntPerfTest(ThreadEntryFunction ptestFunc, benchmarkenvironment::Sample &sample)
-{
-	static const int kNumThreads = 8;
-
-	EA::Thread::Thread::Status threadExitStatus;
-	AtomicAndTimer threadTimers[kNumThreads];
-	float totalTime = 0.0;
-
-	Thread threads[kNumThreads];
-
-	for (int i = 0; i < kNumThreads; ++i) 
-		threads[i].Begin(ptestFunc, &threadTimers[i]);
-
-	for (int i = 0; i < kNumThreads; ++i)
-	{
-		threadExitStatus = threads[i].WaitForEnd(GetThreadTime() + 30000);
-		
-		// Only take the results if the thread exited properly.
-		if (threadExitStatus != Thread::kStatusRunning)
-			totalTime += threadTimers[i].mLocalTimer.AsSeconds();
-	}
-
-	sample.AddElement(totalTime);
-}
-
-// ------------------------------------------------------------------------------
-// NOTE If you wish to add tests here. You will need to add your test function to the 
-//      testFunctions vector, as well as the name of the test to the testNames vector.
-void PerfTestThreadAtomic(benchmarkenvironment::Results &results, EA::IO::FileStream* pPerformanceLog)
-{
-	using namespace eastl;
-	using namespace benchmarkenvironment;
-
-	const int kNumSamples = 50;
-
-	vector<ThreadEntryFunction> testFunctions;
-	testFunctions.push_back(&AtomicIntMath);
-	// The compare-and-swap test has been deactivated until we can think of a better way to test that functionality.
-	//testFunctions.push_back(&AtomicIntCompareAndSwap));
-
-	vector<string> testNames;
-	testNames.push_back("Atomic Math Test");
-	//testNames.push_back("Atomic Compare and Swap Test");
-
-	vector<Sample> samples;
-	for (unsigned int i = 0; i < testFunctions.size(); ++i)
-		samples.push_back(Sample(kNumSamples));
-
-	for (unsigned int i = 0; i < testFunctions.size(); ++i)
-	{
-		for (int j = 0; j < kNumSamples; ++j)
-			AtomicIntPerfTest(testFunctions[i], samples[i]);
-
-		AddRowToResults(results, samples[i], testNames.at(i));
-		WriteToLogFile(pPerformanceLog, "%s,%g,%g\r\n", testNames[i].c_str(), samples[i].GetMean(), samples[i].GetVariance());
-	}
-}
-
-#endif // EA_THREADS_AVAILABLE

+ 0 - 392
test/performance/source/PerfTestThreadSemaphore.cpp

@@ -1,392 +0,0 @@
-////////////////////////////////////////////////////////////////////////
-// PerfTestThreadSemaphore.cpp
-//
-// Copyright (c) 2014, Electronic Arts Inc. All rights reserved.
-////////////////////////////////////////////////////////////////////////
-
-#include "benchmarkenvironment/results.h"
-#include "benchmarkenvironment/statistics.h"
-#include "benchmarkenvironment/timer.h"
-
-#include "eathread/eathread_atomic.h"
-#include "eathread/eathread_semaphore.h"
-#include "eathread/eathread_thread.h"
-
-#include "EATest/EATest.h"
-
-#include "PerfTestThread.h"
-
-using namespace EA::Thread;
-using namespace benchmarkenvironment;
-
-// Used to set how many times the contended thread functions run.
-const int kNumTestIterations = 10000;
-
-#define THREAD_WAIT_TIMEOUT 15000
-
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//                           Producer/Consumer Tests & Test Functions
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-static AtomicInt32 gThreadSyncer = 0;
-void DECREMENT_AND_SPINWAIT(AtomicInt32& atomic_var) 
-{
-	atomic_var--;
-	while (atomic_var > 0) 
-		;
-}
-
-struct ProducerConsumerTestData
-{
-	static Semaphore* mpEmptySlots;
-	static Semaphore* mpFullSlots;
-	Timer mThreadLocalTimer;
-
-	ProducerConsumerTestData()
-		: mThreadLocalTimer() {}
-
-	static void InitSemaphores(int bufferCapacity)
-	{
-		SemaphoreParameters temp(bufferCapacity, true, "Producer/Consumer Full");
-		mpEmptySlots = new Semaphore(&temp);
-		
-		SemaphoreParameters temp2(0, false, "Producer/Consumer Empty");
-		mpFullSlots = new Semaphore(&temp2);
-	}
-
-	static void ResetSemaphores()
-	{
-		if (mpEmptySlots)
-		{
-			delete mpEmptySlots;
-			mpEmptySlots = NULL;
-		}
-		if (mpFullSlots)
-		{
-			delete mpFullSlots;
-			mpFullSlots = NULL;
-		}
-	}
-};
-
-// Initialization of the static members...
-Semaphore* ProducerConsumerTestData::mpEmptySlots = NULL;
-Semaphore* ProducerConsumerTestData::mpFullSlots = NULL;
-
-static intptr_t ProducerThreadFunction(void* pTestData)
-{
-	ProducerConsumerTestData& testData = *static_cast<ProducerConsumerTestData*>(pTestData);
-
-	testData.mThreadLocalTimer.Start();
-	for (int i = 0; i < kNumTestIterations; ++i)
-	{
-		testData.mpEmptySlots->Wait();
-		testData.mpFullSlots->Post();
-	}
-	testData.mThreadLocalTimer.Stop();
-
-	EAT_ASSERT(testData.mThreadLocalTimer.AsSeconds() >= 0.0);
-
-	return 0;
-}
-
-static intptr_t ConsumerThreadFunction(void* pTestData)
-{
-	ProducerConsumerTestData& testData = *static_cast<ProducerConsumerTestData*>(pTestData);
-
-	testData.mThreadLocalTimer.Start();
-	for (int i = 0; i < kNumTestIterations; ++i)
-	{
-		testData.mpFullSlots->Wait();
-		testData.mpEmptySlots->Post();
-	}
-	testData.mThreadLocalTimer.Stop();
-
-	EAT_ASSERT(testData.mThreadLocalTimer.AsSeconds() >= 0.0);
-
-	return 0;
-}
-
-void ProducerConsumerTest(
-	Sample& sample,
-	ThreadEntryFunction pProducer,
-	ThreadEntryFunction pConsumer,
-	int bufferCapacity,
-	bool isContended) 
-{
-	const int kThreadArraySize = 12;
-	const int kMinThreads = 4;
-
-	const int kNumCores = (isContended ? eastl::min(kThreadArraySize, eastl::max(GetProcessorCount(), kMinThreads)) : 2);
-	const int kThreadGroupSize = (isContended ? kNumCores / 2 : 1);
-
-	ProducerConsumerTestData::InitSemaphores(bufferCapacity);
-
-	eastl::vector<ProducerConsumerTestData> producerThreadTimers(kThreadGroupSize);
-	eastl::vector<ProducerConsumerTestData> consumerThreadTimers(kThreadGroupSize);
-	eastl::vector<Thread> producers(kThreadGroupSize);
-	eastl::vector<Thread> consumers(kThreadGroupSize);
-
-	ThreadAffinityMask affinityMask = 1;
-	ThreadId newThread;
-	for (int i = 0; i < kThreadGroupSize; ++i)
-	{
-		newThread = producers[i].Begin(pProducer, &producerThreadTimers[i]);
-		EA::Thread::SetThreadAffinityMask(newThread, affinityMask);
-		affinityMask = affinityMask << 1;
-
-		newThread = consumers[i].Begin(pConsumer, &consumerThreadTimers[i]);
-		EA::Thread::SetThreadAffinityMask(newThread, affinityMask);
-		affinityMask = affinityMask << 1;
-	}
-
-	for (int i = 0; i < kThreadGroupSize; ++i)
-	{
-		EA::Thread::Thread::Status producerThreadExitStatus = producers[i].WaitForEnd(GetThreadTime() + (THREAD_WAIT_TIMEOUT * kNumCores));
-		EA::Thread::Thread::Status consumerThreadExitStatus = consumers[i].WaitForEnd(GetThreadTime() + (THREAD_WAIT_TIMEOUT * kNumCores));
-
-		EA_UNUSED(producerThreadExitStatus);
-		EA_UNUSED(consumerThreadExitStatus);
-
-		EAT_ASSERT(producerThreadExitStatus != Thread::kStatusRunning);
-		EAT_ASSERT(consumerThreadExitStatus != Thread::kStatusRunning);
-	}
-
-	double totalTime = 0.0;
-	for (int i = 0; i < kThreadGroupSize; ++i)
-	{
-		totalTime += producerThreadTimers[i].mThreadLocalTimer.AsSeconds();
-		totalTime += consumerThreadTimers[i].mThreadLocalTimer.AsSeconds();
-	}
-
-	sample.AddElement(totalTime);
-
-	ProducerConsumerTestData::ResetSemaphores();
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////////////
-//                           Scheduler Tests & Test Functions
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-struct SemaphoreTestData
-{
-	static Semaphore* mpTestSemaphore;
-	Timer& mThreadLocalTimer;
-	AtomicInt32 mSignal;
-
-	SemaphoreTestData(Timer &timer, int signal = 0)
-		: mThreadLocalTimer(timer)
-		, mSignal(signal)
-	{
-	}
-
-	SemaphoreTestData operator=(const SemaphoreTestData& other)
-	{
-		mThreadLocalTimer = other.mThreadLocalTimer;
-		mSignal = other.mSignal;
-
-		return *this;
-	}
-	
-	SemaphoreTestData(const SemaphoreTestData& other) 
-		: mThreadLocalTimer(other.mThreadLocalTimer)
-		, mSignal(other.mSignal) 
-	{
-	}
-	
-	static void setSemaphoreInitialCount(int count)
-	{
-		SemaphoreParameters params(count, true, "Test Semaphore");
-		mpTestSemaphore = new Semaphore(&params);
-	}
-
-	static void resetSemaphore()
-	{
-		if (mpTestSemaphore)
-		{
-			delete mpTestSemaphore;
-			mpTestSemaphore = NULL;
-		}
-	}
-};
-
-Semaphore* SemaphoreTestData::mpTestSemaphore = NULL;
-
-// ------------------------------------------------------------------------------
-//
-
-static intptr_t SemaphoreTestSchedulerContendedFunction(void* pTestData)
-{
-	// In this case, each thread will have its own timer, and share the same semaphore.
-	SemaphoreTestData& testData = *static_cast<SemaphoreTestData*>(pTestData);
-
-	DECREMENT_AND_SPINWAIT(gThreadSyncer);
-	testData.mThreadLocalTimer.Start();
-
-	for (int i = 0; i < kNumTestIterations; ++i)
-	{
-		testData.mpTestSemaphore->Wait();
-		testData.mpTestSemaphore->Post();
-	}
-
-	testData.mThreadLocalTimer.Stop();
-
-	return 0;
-}
-
-// ------------------------------------------------------------------------------
-//
-static intptr_t SemaphoreTestSchedulerUncontendedWakeFunction(void* pTestData)
-{
-	// Initiate the timer when the wakeup signal is sent.
-	SemaphoreTestData& testData = *static_cast<SemaphoreTestData*>(pTestData);
-
-	testData.mThreadLocalTimer.Start();
-	testData.mpTestSemaphore->Post();
-
-	return 0;
-}
-
-// ------------------------------------------------------------------------------
-//
-static intptr_t SemaphoreTestSchedulerUncontendedWaitFunction(void* pTestData)
-{
-	// Immediately go to sleep waiting for the semaphore, then stop the timer 
-	// once we wake up.
-	SemaphoreTestData& testData = *static_cast<SemaphoreTestData*>(pTestData);
-
-	testData.mSignal++;
-	int exitResult = testData.mpTestSemaphore->Wait(GetThreadTime() + THREAD_WAIT_TIMEOUT);
-	EAT_ASSERT(exitResult != Semaphore::kResultTimeout);
-	EA_UNUSED(exitResult); // Silences gcc and clang warnings 
-
-	testData.mThreadLocalTimer.Stop();
-
-	return 0;
-}
-
-// ------------------------------------------------------------------------------
-// 
-void SemaphoreUncontendedPerfTest(Sample &sample, ThreadEntryFunction pWaitingFunc, ThreadEntryFunction pWakingFunc, int semaphoreInitialCount)
-{
-	SemaphoreParameters params(semaphoreInitialCount, true, "Uncontended");
-	Timer timer;
-
-	SemaphoreTestData sharedData(timer);
-	SemaphoreTestData::setSemaphoreInitialCount(semaphoreInitialCount);
-
-	Thread waker;
-	Thread sleeper;
-
-	sleeper.Begin(pWaitingFunc, &sharedData);
-
-	// Spin until the sleeping thread runs and blocks on the semaphore.
-	while (sharedData.mSignal == 0) {}
-
-	waker.Begin(pWakingFunc, &sharedData);
-
-	EA::Thread::Thread::Status waiterThreadExitStatus = sleeper.WaitForEnd(GetThreadTime() + THREAD_WAIT_TIMEOUT);
-	EA::Thread::Thread::Status wakerThreadExitStatus = waker.WaitForEnd(GetThreadTime() + THREAD_WAIT_TIMEOUT);
-	
-	EA_UNUSED(waiterThreadExitStatus);
-	EA_UNUSED(wakerThreadExitStatus);
-
-	EAT_ASSERT(waiterThreadExitStatus != Thread::kStatusRunning && wakerThreadExitStatus != Thread::kStatusRunning);
-
-	sample.AddElement(timer.AsSeconds());
-
-	SemaphoreTestData::resetSemaphore();
-}
-
-// ------------------------------------------------------------------------------
-// 
-void SemaphoreContendedPerfTest(benchmarkenvironment::Sample &sample, ThreadEntryFunction pTestFunc, int semaphoreInitialCount)
-{
-	// The contended test will always use per-thread timers, since any blocks are
-	// a circumstance that would arise in normal use.
-
-	const int kThreadArraySize = 12;
-	const int kMinThreads = 4;
-
-	const int kNumCores = eastl::min(kThreadArraySize, eastl::max(GetProcessorCount(), kMinThreads));
-	gThreadSyncer = kNumCores;
-
-	SemaphoreTestData::setSemaphoreInitialCount(semaphoreInitialCount);
-
-	eastl::vector<Thread> threads(kNumCores);
-	eastl::vector<Timer> timers(kNumCores);
-	eastl::vector<SemaphoreTestData> data;
-	for (int i = 0; i < kNumCores; ++i)
-		data.push_back(SemaphoreTestData(timers[i]));
-
-	for (int i = 0; i < kNumCores; ++i)
-	{
-		ThreadId newThread = threads[i].Begin(pTestFunc, &data[i]);
-		EA::Thread::SetThreadAffinityMask(newThread, ThreadAffinityMask(1 << i));
-	}
-
-	double totalTime = 0.0;
-	for (int i = 0; i < kNumCores; ++i)
-	{
-		EA::Thread::Thread::Status threadExitStatus = threads[i].WaitForEnd(GetThreadTime() + (THREAD_WAIT_TIMEOUT * kNumCores));
-		EAT_ASSERT(threadExitStatus != Thread::kStatusRunning);
-		EA_UNUSED(threadExitStatus);
-			
-		totalTime += timers[i].AsSeconds();
-	}
-
-	sample.AddElement(totalTime);
-
-	SemaphoreTestData::resetSemaphore();
-}
-
-// ------------------------------------------------------------------------------
-//
-void PerfTestThreadSemaphore(Results &results, EA::IO::FileStream* pPerformanceLog)
-{
-	using namespace eastl;
-
-	const int kNumSamples = 10;
-	const int kNumTests = 7;
-	
-	vector<Sample> samples;
-	for (int i = 0; i < kNumTests; ++i)
-		samples.push_back(Sample(kNumSamples));
-
-	for (int j = 0; j < kNumSamples; ++j)
-		SemaphoreUncontendedPerfTest(samples[0], &SemaphoreTestSchedulerUncontendedWaitFunction, &SemaphoreTestSchedulerUncontendedWakeFunction, 0);
-	AddRowToResults(results, samples[0], "Semaphore Wakeup Time");
-	WriteToLogFile(pPerformanceLog, "Semaphore Wakeup Time,%g,%g\r\n", samples[0].GetMean(), samples[0].GetVariance());  // Execution is in a local context, so output the results to the log file.
-
-	for (int j = 0; j < kNumSamples; ++j)
-		SemaphoreContendedPerfTest(samples[1], &SemaphoreTestSchedulerContendedFunction, 1);
-	AddRowToResults(results, samples[1], "Semaphore as Mutex");
-	WriteToLogFile(pPerformanceLog, "Semaphore as Mutex,%g,%g\r\n", samples[1].GetMean(), samples[1].GetVariance());
-
-	for (int j = 0; j < kNumSamples; ++j)
-		SemaphoreContendedPerfTest(samples[2], &SemaphoreTestSchedulerContendedFunction, 5);
-	AddRowToResults(results, samples[2], "Semaphore as 5-way Mutex");
-	WriteToLogFile(pPerformanceLog, "Semaphore as 5-way Mutex,%g,%g\r\n", samples[2].GetMean(), samples[2].GetVariance());
-
-	for (int j = 0; j < kNumSamples; ++j)
-		ProducerConsumerTest(samples[3], &ProducerThreadFunction, &ConsumerThreadFunction, 1, false);
-	AddRowToResults(results, samples[3], "1 P/1 C (1 Thread at once)");
-	WriteToLogFile(pPerformanceLog, "1 P/1 C (1 Thread at once),%g,%g\r\n", samples[3].GetMean(), samples[3].GetVariance());
-
-	for (int j = 0; j < kNumSamples; ++j)
-		ProducerConsumerTest(samples[4], &ProducerThreadFunction, &ConsumerThreadFunction, 5, false);
-	AddRowToResults(results, samples[4], "1 P/1 C (5 Threads at once)");
-	WriteToLogFile(pPerformanceLog, "1 P/1 C (5 Threads at once),%g,%g\r\n", samples[4].GetMean(), samples[4].GetVariance());
-
-	for (int j = 0; j < kNumSamples; ++j)
-		ProducerConsumerTest(samples[5], &ProducerThreadFunction, &ConsumerThreadFunction, 1, true);
-	AddRowToResults(results, samples[5], "1+ P/1+ C (1 Thread at once)");
-	WriteToLogFile(pPerformanceLog, "1+ P/1+ C (1 Thread at once),%g,%g\r\n", samples[5].GetMean(), samples[5].GetVariance());
-
-	for (int j = 0; j < kNumSamples; ++j)
-		ProducerConsumerTest(samples[6], &ProducerThreadFunction, &ConsumerThreadFunction, 5, true);
-	AddRowToResults(results, samples[6], "1+ P/1+ C (5 Threads at once)");
-	WriteToLogFile(pPerformanceLog, "1+ P/1+ C (5 Threads at once),%g,%g\r\n", samples[6].GetMean(), samples[6].GetVariance());
-
-	return;
-}

+ 0 - 1313
test/thread/lib/pthreads-win32/include/pthread.h

@@ -1,1313 +0,0 @@
-/* This is an implementation of the threads API of POSIX 1003.1-2001.
- *
- * --------------------------------------------------------------------------
- *
- *      Pthreads-win32 - POSIX Threads Library for Win32
- *      Copyright(C) 1998 John E. Bossom
- *      Copyright(C) 1999,2003 Pthreads-win32 contributors
- * 
- *      Contact Email: [email protected]
- * 
- *      The current list of contributors is contained
- *      in the file CONTRIBUTORS included with the source
- *      code distribution. The list can also be seen at the
- *      following World Wide Web location:
- *      http://sources.redhat.com/pthreads-win32/contributors.html
- * 
- *      This library is free software; you can redistribute it and/or
- *      modify it under the terms of the GNU Lesser General Public
- *      License as published by the Free Software Foundation; either
- *      version 2 of the License, or (at your option) any later version.
- * 
- *      This library is distributed in the hope that it will be useful,
- *      but WITHOUT ANY WARRANTY; without even the implied warranty of
- *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *      Lesser General Public License for more details.
- * 
- *      You should have received a copy of the GNU Lesser General Public
- *      License along with this library in the file COPYING.LIB;
- *      if not, write to the Free Software Foundation, Inc.,
- *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#if !defined( PTHREAD_H )
-#define PTHREAD_H
-
-#undef PTW32_LEVEL
-
-#if defined(_POSIX_SOURCE)
-#define PTW32_LEVEL 0
-/* Early POSIX */
-#endif
-
-#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
-#undef PTW32_LEVEL
-#define PTW32_LEVEL 1
-/* Include 1b, 1c and 1d */
-#endif
-
-#if defined(INCLUDE_NP)
-#undef PTW32_LEVEL
-#define PTW32_LEVEL 2
-/* Include Non-Portable extensions */
-#endif
-
-#define PTW32_LEVEL_MAX 3
-
-#if !defined(PTW32_LEVEL)
-#define PTW32_LEVEL PTW32_LEVEL_MAX
-/* Include everything */
-#endif
-
-#ifdef _UWIN
-#   define HAVE_STRUCT_TIMESPEC 1
-#   define HAVE_SIGNAL_H	1
-#   undef HAVE_CONFIG_H
-#   pragma comment(lib, "pthread")
-#endif
-
-/*
- * -------------------------------------------------------------
- *
- *
- * Module: pthread.h
- *
- * Purpose:
- *	Provides an implementation of PThreads based upon the
- *	standard:
- *
- *		POSIX 1003.1-2001
- *  and
- *    The Single Unix Specification version 3
- *
- *    (these two are equivalent)
- *
- *	in order to enhance code portability between Windows,
- *  various commercial Unix implementations, and Linux.
- *
- *	See the ANNOUNCE file for a full list of conforming
- *	routines and defined constants, and a list of missing
- *	routines and constants not defined in this implementation.
- *
- * Authors:
- *	There have been many contributors to this library.
- *	The initial implementation was contributed by
- *	John Bossom, and several others have provided major
- *	sections or revisions of parts of the implementation.
- *	Often significant effort has been contributed to
- *	find and fix important bugs and other problems to
- *	improve the reliability of the library, which sometimes
- *	is not reflected in the amount of code which changed as
- *	result.
- *	As much as possible, the contributors are acknowledged
- *	in the ChangeLog file in the source code distribution
- *	where their changes are noted in detail.
- *
- *	Contributors are listed in the CONTRIBUTORS file.
- *
- *	As usual, all bouquets go to the contributors, and all
- *	brickbats go to the project maintainer.
- *
- * Maintainer:
- *	The code base for this project is coordinated and
- *	eventually pre-tested, packaged, and made available by
- *
- *		Ross Johnson <[email protected]>
- *
- * QA Testers:
- *	Ultimately, the library is tested in the real world by
- *	a host of competent and demanding scientists and
- *	engineers who report bugs and/or provide solutions
- *	which are then fixed or incorporated into subsequent
- *	versions of the library. Each time a bug is fixed, a
- *	test case is written to prove the fix and ensure
- *	that later changes to the code don't reintroduce the
- *	same error. The number of test cases is slowly growing
- *	and therefore so is the code reliability.
- *
- * Compliance:
- *	See the file ANNOUNCE for the list of implemented
- *	and not-implemented routines and defined options.
- *	Of course, these are all defined is this file as well.
- *
- * Web site:
- *	The source code and other information about this library
- *	are available from
- *
- *		http://sources.redhat.com/pthreads-win32/
- *
- * -------------------------------------------------------------
- */
-
-/* Try to avoid including windows.h */
-#if defined(__MINGW32__) && defined(__cplusplus)
-/*
- * FIXME: The pthreadGCE.dll build gets linker unresolved errors
- * on pthread_key_create() unless windows.h is included here.
- * It appears to have something to do with an argument type mismatch.
- * Looking at tsd.o with 'nm' shows this line:
- * 00000000 T _pthread_key_create__FPP14pthread_key_t_PFPv_v
- * instead of
- * 00000000 T _pthread_key_create
- */
-#define PTW32_INCLUDE_WINDOWS_H
-#endif
-
-#ifdef PTW32_INCLUDE_WINDOWS_H
-#ifndef WIN32_LEAN_AND_MEAN
-	#define WIN32_LEAN_AND_MEAN
-#endif
-#include <Windows.h>
-#endif
-
-/*
- * -----------------
- * autoconf switches
- * -----------------
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX
-
-/* Try to avoid including windows.h */
-#if defined(__MINGW32__) && defined(__cplusplus)
-/*
- * FIXME: The pthreadGCE.dll build gets linker unresolved errors
- * on pthread_key_create() unless windows.h is included here.
- * It appears to have something to do with an argument type mismatch.
- * Looking at tsd.o with 'nm' shows this line:
- * 00000000 T _pthread_key_create__FPP14pthread_key_t_PFPv_v
- * instead of
- * 00000000 T _pthread_key_create
- */
-#define PTW32_INCLUDE_WINDOWS_H
-#endif
-
-#ifdef PTW32_INCLUDE_WINDOWS_H
-#ifndef WIN32_LEAN_AND_MEAN
-	#define WIN32_LEAN_AND_MEAN
-#endif
-#include <Windows.h>
-#endif
-
-#ifndef NEED_FTIME
-#include <time.h>
-#else /* NEED_FTIME */
-/* use native WIN32 time API */
-#endif /* NEED_FTIME */
-
-#if HAVE_SIGNAL_H
-#include <signal.h>
-#endif /* HAVE_SIGNAL_H */
-
-#include <setjmp.h>
-#include <limits.h>
-
-/*
- * Boolean values to make us independent of system includes.
- */
-enum {
-  PTW32_FALSE = 0,
-  PTW32_TRUE = (! PTW32_FALSE)
-};
-
-/*
- * This is a duplicate of what is in the autoconf config.h,
- * which is only used when building the pthread-win32 libraries.
- */
-
-#ifndef PTW32_CONFIG_H
-#  if defined(WINCE)
-#    define NEED_ERRNO
-#    define NEED_SEM
-#  endif
-#  if defined(_UWIN) || defined(__MINGW32__)
-#    define HAVE_MODE_T
-#  endif
-#endif
-
-/*
- *
- */
-
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX
-#ifdef NEED_ERRNO
-#include "need_errno.h"
-#else
-#include <errno.h>
-#endif
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
-
-/*
- * Several systems don't define ENOTSUP. If not, we use
- * the same value as Solaris.
- */
-#ifndef ENOTSUP
-#  define ENOTSUP 48
-#endif
-
-#ifndef ETIMEDOUT
-#  define ETIMEDOUT 10060     /* This is the value in winsock.h. */
-#endif
-
-#include <sched.h>
-
-/*
- * To avoid including windows.h we define only those things that we
- * actually need from it. I don't like the potential incompatibility that
- * this creates with future versions of windows.
- */
-#ifndef PTW32_INCLUDE_WINDOWS_H
-#ifndef HANDLE
-# define PTW32__HANDLE_DEF
-# define HANDLE void *
-#endif
-#ifndef DWORD
-# define PTW32__DWORD_DEF
-# define DWORD unsigned long
-#endif
-#endif
-
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
-
-#ifndef HAVE_STRUCT_TIMESPEC
-struct timespec {
-	long tv_sec;
-	long tv_nsec;
-};
-#endif /* HAVE_STRUCT_TIMESPEC */
-
-#ifndef SIG_BLOCK
-#define SIG_BLOCK 0
-#endif /* SIG_BLOCK */
-
-#ifndef SIG_UNBLOCK 
-#define SIG_UNBLOCK 1
-#endif /* SIG_UNBLOCK */
-
-#ifndef SIG_SETMASK
-#define SIG_SETMASK 2
-#endif /* SIG_SETMASK */
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif				/* __cplusplus */
-
-/*
- * -------------------------------------------------------------
- *
- * POSIX 1003.1-2001 Options
- * =========================
- *
- * _POSIX_THREADS (set)
- *			If set, you can use threads
- *
- * _POSIX_THREAD_ATTR_STACKSIZE (set)
- *			If set, you can control the size of a thread's
- *			stack
- *				pthread_attr_getstacksize
- *				pthread_attr_setstacksize
- *
- * _POSIX_THREAD_ATTR_STACKADDR (not set)
- *			If set, you can allocate and control a thread's
- *			stack. If not supported, the following functions
- *			will return ENOSYS, indicating they are not
- *			supported:
- *				pthread_attr_getstackaddr
- *				pthread_attr_setstackaddr
- *
- * _POSIX_THREAD_PRIORITY_SCHEDULING (set)
- *			If set, you can use realtime scheduling.
- *			Indicates the availability of:
- *				pthread_attr_getinheritsched
- *				pthread_attr_getschedparam
- *				pthread_attr_getschedpolicy
- *				pthread_attr_getscope
- *				pthread_attr_setinheritsched
- *				pthread_attr_setschedparam
- *				pthread_attr_setschedpolicy
- *				pthread_attr_setscope
- *				pthread_getschedparam
- *				pthread_setschedparam
- *				sched_get_priority_max
- *				sched_get_priority_min
- *				sched_rr_set_interval
- *
- * _POSIX_THREAD_PRIO_INHERIT (not set)
- *			If set, you can create priority inheritance
- *			mutexes.
- *				pthread_mutexattr_getprotocol +
- *				pthread_mutexattr_setprotocol +
- *
- * _POSIX_THREAD_PRIO_PROTECT (not set)
- *			If set, you can create priority ceiling mutexes
- *			Indicates the availability of:
- *				pthread_mutex_getprioceiling
- *				pthread_mutex_setprioceiling
- *				pthread_mutexattr_getprioceiling
- *				pthread_mutexattr_getprotocol	  +
- *				pthread_mutexattr_setprioceiling
- *				pthread_mutexattr_setprotocol	  +
- *
- * _POSIX_THREAD_PROCESS_SHARED (not set)
- *			If set, you can create mutexes and condition
- *			variables that can be shared with another
- *			process.If set, indicates the availability
- *			of:
- *				pthread_mutexattr_getpshared
- *				pthread_mutexattr_setpshared
- *				pthread_condattr_getpshared
- *				pthread_condattr_setpshared
- *
- * _POSIX_THREAD_SAFE_FUNCTIONS (set)
- *			If set you can use the special *_r library
- *			functions that provide thread-safe behaviour
- *
- * _POSIX_READER_WRITER_LOCKS (set)
- *			If set, you can use read/write locks
- *
- * _POSIX_SPIN_LOCKS (set)
- *			If set, you can use spin locks
- *
- * _POSIX_BARRIERS (set)
- *			If set, you can use barriers
- *
- *	+ These functions provide both 'inherit' and/or
- *	  'protect' protocol, based upon these macro
- *	  settings.
- *
- * POSIX 1003.1-2001 Limits
- * ===========================
- *
- * PTHREAD_DESTRUCTOR_ITERATIONS
- *			Maximum number of attempts to destroy
- *			a thread's thread-specific data on
- *			termination (must be at least 4)
- *
- * PTHREAD_KEYS_MAX
- *			Maximum number of thread-specific data keys
- *			available per process (must be at least 128)
- *
- * PTHREAD_STACK_MIN
- *			Minimum supported stack size for a thread
- *
- * PTHREAD_THREADS_MAX
- *			Maximum number of threads supported per
- *			process (must be at least 64).
- *
- * _POSIX_SEM_NSEMS_MAX
- *	The maximum number of semaphores a process can have.
- *	(only defined if not already defined)
- *
- * _POSIX_SEM_VALUE_MAX
- *	The maximum value a semaphore can have.
- *	(only defined if not already defined)
- *
- * -------------------------------------------------------------
- */
-
-/*
- * POSIX Options
- */
-#ifndef _POSIX_THREADS
-#define _POSIX_THREADS
-#endif
-
-#ifndef _POSIX_READER_WRITER_LOCKS
-#define _POSIX_READER_WRITER_LOCKS
-#endif
-
-#ifndef _POSIX_SPIN_LOCKS
-#define _POSIX_SPIN_LOCKS
-#endif
-
-#ifndef _POSIX_BARRIERS
-#define _POSIX_BARRIERS
-#endif
-
-#define _POSIX_THREAD_SAFE_FUNCTIONS
-#define _POSIX_THREAD_ATTR_STACKSIZE
-#define _POSIX_THREAD_PRIORITY_SCHEDULING
-
-#if defined( KLUDGE )
-/*
- * The following are not supported
- */
-#define _POSIX_THREAD_ATTR_STACKADDR
-#define _POSIX_THREAD_PRIO_INHERIT
-#define _POSIX_THREAD_PRIO_PROTECT
-#define _POSIX_THREAD_PROCESS_SHARED
-
-#endif				/* KLUDGE */
-
-/*
- * POSIX Limits
- *
- *	PTHREAD_DESTRUCTOR_ITERATIONS
- *		Standard states this must be at least
- *		4.
- *
- *	PTHREAD_KEYS_MAX
- *		WIN32 permits only 64 TLS keys per process.
- *		This limitation could be worked around by
- *		simply simulating keys.
- *
- *	PTHREADS_STACK_MIN
- *		POSIX specifies 0 which is also the value WIN32
- *		interprets as allowing the system to
- *		set the size to that of the main thread. The
- *		maximum stack size in Win32 is 1Meg. WIN32
- *		allocates more stack as required up to the 1Meg
- *		limit.
- *
- *	PTHREAD_THREADS_MAX
- *		Not documented by WIN32. Wrote a test program
- *		that kept creating threads until it failed
- *		revealed this approximate number (Windows NT).
- *		This number is somewhat less for Windows 9x
- *		and is effectively less than 64. Perhaps this
- *		constant should be set at DLL load time.
- *
- */
-#define PTHREAD_DESTRUCTOR_ITERATIONS			       4
-#define PTHREAD_KEYS_MAX			64
-#define PTHREAD_STACK_MIN			 0
-#define PTHREAD_THREADS_MAX		      2019
-#ifndef _POSIX_SEM_NSEMS_MAX
-/* Not used and only an arbitrary value. */
-#  define _POSIX_SEM_NSEMS_MAX		      1024
-#endif
-#ifndef _POSIX_SEM_VALUE_MAX
-#  define _POSIX_SEM_VALUE_MAX	       (INT_MAX/2)
-#endif
-
-#if __GNUC__ && ! defined (__declspec)
-# error Please upgrade your GNU compiler to one that supports __declspec.
-#endif
-
-/*
- * When building the DLL code, you should define PTW32_BUILD so that
- * the variables/functions are exported correctly. When using the DLL,
- * do NOT define PTW32_BUILD, and then the variables/functions will
- * be imported correctly.
- */
-#ifdef _DLL
-#  ifdef PTW32_BUILD
-#    define PTW32_DLLPORT __declspec (dllexport)
-#  else
-#    define PTW32_DLLPORT __declspec (dllimport)
-#  endif
-#endif
-
-#if defined(_UWIN) && PTW32_LEVEL >= PTW32_LEVEL_MAX
-#   include	<sys/types.h>
-#else
-typedef struct pthread_t_ *pthread_t;
-typedef struct pthread_attr_t_ *pthread_attr_t;
-typedef struct pthread_once_t_ pthread_once_t;
-typedef struct pthread_key_t_ *pthread_key_t;
-typedef struct pthread_mutex_t_ *pthread_mutex_t;
-typedef struct pthread_mutexattr_t_ *pthread_mutexattr_t;
-typedef struct pthread_cond_t_ *pthread_cond_t;
-typedef struct pthread_condattr_t_ *pthread_condattr_t;
-#endif
-typedef struct pthread_rwlock_t_ *pthread_rwlock_t;
-typedef struct pthread_rwlockattr_t_ *pthread_rwlockattr_t;
-typedef struct pthread_spinlock_t_ *pthread_spinlock_t;
-typedef struct pthread_barrier_t_ *pthread_barrier_t;
-typedef struct pthread_barrierattr_t_ *pthread_barrierattr_t;
-
-/*
- * ====================
- * ====================
- * POSIX Threads
- * ====================
- * ====================
- */
-
-enum {
-/*
- * pthread_attr_{get,set}detachstate
- */
-  PTHREAD_CREATE_JOINABLE	= 0,  /* Default */
-  PTHREAD_CREATE_DETACHED	= 1,
-
-/*
- * pthread_attr_{get,set}inheritsched
- */
-  PTHREAD_INHERIT_SCHED 	= 0,
-  PTHREAD_EXPLICIT_SCHED	= 1,  /* Default */
-
-/*
- * pthread_{get,set}scope
- */
-  PTHREAD_SCOPE_PROCESS 	= 0,
-  PTHREAD_SCOPE_SYSTEM		= 1,  /* Default */
-
-/*
- * pthread_setcancelstate paramters
- */
-  PTHREAD_CANCEL_ENABLE 	= 0,  /* Default */
-  PTHREAD_CANCEL_DISABLE	= 1,
-
-/*
- * pthread_setcanceltype parameters
- */
-  PTHREAD_CANCEL_ASYNCHRONOUS	= 0,
-  PTHREAD_CANCEL_DEFERRED	= 1,  /* Default */
-
-/*
- * pthread_mutexattr_{get,set}pshared
- * pthread_condattr_{get,set}pshared
- */
-  PTHREAD_PROCESS_PRIVATE	= 0,
-  PTHREAD_PROCESS_SHARED	= 1,
-
-/*
- * pthread_barrier_wait
- */
-  PTHREAD_BARRIER_SERIAL_THREAD = -1
-};
-
-/*
- * ====================
- * ====================
- * Cancelation
- * ====================
- * ====================
- */
-#define PTHREAD_CANCELED       ((void *) -1)
-
-
-/*
- * ====================
- * ====================
- * Once Key
- * ====================
- * ====================
- */
-#define PTHREAD_ONCE_INIT	{ PTW32_FALSE, -1 }
-
-struct pthread_once_t_
-{
-  int done;		    /* indicates if user function executed  */
-  long started; 	    /* First thread to increment this value */
-				/* to zero executes the user function   */
-};
-
-
-/*
- * ====================
- * ====================
- * Object initialisers
- * ====================
- * ====================
- */
-#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) -1)
-
-#define PTHREAD_COND_INITIALIZER ((pthread_cond_t) -1)
-
-#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) -1)
-
-#define PTHREAD_SPINLOCK_INITIALIZER ((pthread_spinlock_t) -1)
-
-
-/*
- * Mutex types.
- */
-enum
-{
-  /* Compatibility with LinuxThreads */
-  PTHREAD_MUTEX_FAST_NP,
-  PTHREAD_MUTEX_RECURSIVE_NP,
-  PTHREAD_MUTEX_ERRORCHECK_NP,
-  PTHREAD_MUTEX_TIMED_NP = PTHREAD_MUTEX_FAST_NP,
-  PTHREAD_MUTEX_ADAPTIVE_NP = PTHREAD_MUTEX_FAST_NP,
-  /* For compatibility with POSIX */
-  PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_FAST_NP,
-  PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
-  PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
-  PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
-};
-
-
-/* There are three implementations of cancel cleanup.
- * Note that pthread.h is included in both application
- * compilation units and also internally for the library.
- * The code here and within the library aims to work
- * for all reasonable combinations of environments.
- *
- * The three implementations are:
- *
- *   WIN32 SEH
- *   C
- *   C++
- *
- * Please note that exiting a push/pop block via
- * "return", "exit", "break", or "continue" will
- * lead to different behaviour amongst applications
- * depending upon whether the library was built
- * using SEH, C++, or C. For example, a library built
- * with SEH will call the cleanup routine, while both
- * C++ and C built versions will not.
- */
-
-/*
- * Define defaults for cleanup code.
- * Note: Unless the build explicitly defines one of the following, then
- * we default to standard C style cleanup. This style uses setjmp/longjmp
- * in the cancelation and thread exit implementations and therefore won't
- * do stack unwinding if linked to applications that have it (e.g.
- * C++ apps). This is currently consistent with most/all commercial Unix
- * POSIX threads implementations.
- */
-#if !defined( __CLEANUP_SEH ) && !defined( __CLEANUP_CXX ) && !defined( __CLEANUP_C )
-# define __CLEANUP_C
-#endif
-
-#if defined( __CLEANUP_SEH ) && defined(__GNUC__)
-#error ERROR [__FILE__, line __LINE__]: GNUC does not support SEH.
-#endif
-
-typedef struct ptw32_cleanup_t ptw32_cleanup_t;
-typedef void (__cdecl *ptw32_cleanup_callback_t)(void *);
-
-struct ptw32_cleanup_t
-{
-  ptw32_cleanup_callback_t routine;
-  void *arg;
-  struct ptw32_cleanup_t *prev;
-};
-
-#ifdef __CLEANUP_SEH
-	/*
-	 * WIN32 SEH version of cancel cleanup.
-	 */
-
-#define pthread_cleanup_push( _rout, _arg ) \
-	{ \
-		ptw32_cleanup_t	_cleanup; \
-		\
-	_cleanup.routine	= (ptw32_cleanup_callback_t)(_rout); \
-		_cleanup.arg	= (_arg); \
-		__try \
-		  { \
-
-#define pthread_cleanup_pop( _execute ) \
-		  } \
-		__finally \
-		{ \
-			if( _execute || AbnormalTermination()) \
-			  { \
-			  (*(_cleanup.routine))( _cleanup.arg ); \
-			  } \
-		} \
-	}
-
-#else /* __CLEANUP_SEH */
-
-#ifdef __CLEANUP_C
-
-	/*
-	 * C implementation of PThreads cancel cleanup
-	 */
-
-#define pthread_cleanup_push( _rout, _arg ) \
-	{ \
-		ptw32_cleanup_t	_cleanup; \
-		\
-		ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t) (_rout), (_arg) ); \
-
-#define pthread_cleanup_pop( _execute ) \
-		(void) ptw32_pop_cleanup( _execute ); \
-	}
-
-#else /* __CLEANUP_C */
-
-#ifdef __CLEANUP_CXX
-
-	/*
-	 * C++ version of cancel cleanup.
-	 * - John E. Bossom.
-	 */
-
-	class PThreadCleanup {
-	  /*
-	   * PThreadCleanup
-	   *
-	   * Purpose
-	   *	  This class is a C++ helper class that is
-	   *	  used to implement pthread_cleanup_push/
-	   *	  pthread_cleanup_pop.
-	   *	  The destructor of this class automatically
-	   *	  pops the pushed cleanup routine regardless
-	   *	  of how the code exits the scope
-	   *	  (i.e. such as by an exception)
-	   */
-	  ptw32_cleanup_callback_t cleanUpRout;
-	  void	  *	  obj;
-	  int		  executeIt;
-
-	public:
-	  PThreadCleanup() :
-		cleanUpRout( 0 ),
-		obj( 0 ),
-		executeIt( 0 )
-		/*
-		 * No cleanup performed
-		 */
-		{
-		}
-
-	  PThreadCleanup(
-		 ptw32_cleanup_callback_t routine,
-			 void	 *	 arg ) :
-		cleanUpRout( routine ),
-		obj( arg ),
-		executeIt( 1 )
-		/*
-		 * Registers a cleanup routine for 'arg'
-		 */
-		{
-		}
-
-	  ~PThreadCleanup()
-		{
-		  if ( executeIt && ((void *) cleanUpRout != (void *) 0) )
-		{
-		  (void) (*cleanUpRout)( obj );
-		}
-		}
-
-	  void execute( int exec )
-		{
-		  executeIt = exec;
-		}
-	};
-
-	/*
-	 * C++ implementation of PThreads cancel cleanup;
-	 * This implementation takes advantage of a helper
-	 * class who's destructor automatically calls the
-	 * cleanup routine if we exit our scope weirdly
-	 */
-#define pthread_cleanup_push( _rout, _arg ) \
-	{ \
-		PThreadCleanup  cleanup((ptw32_cleanup_callback_t)(_rout), \
-					(void *) (_arg) );
-
-#define pthread_cleanup_pop( _execute ) \
-		cleanup.execute( _execute ); \
-	}
-
-#else
-
-#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined.
-
-#endif /* __CLEANUP_CXX */
-
-#endif /* __CLEANUP_C */
-
-#endif /* __CLEANUP_SEH */
-
-/*
- * ===============
- * ===============
- * Methods
- * ===============
- * ===============
- */
-
-/*
- * PThread Attribute Functions
- */
-PTW32_DLLPORT int pthread_attr_init (pthread_attr_t * attr);
-
-PTW32_DLLPORT int pthread_attr_destroy (pthread_attr_t * attr);
-
-PTW32_DLLPORT int pthread_attr_getdetachstate (const pthread_attr_t * attr,
-					 int *detachstate);
-
-PTW32_DLLPORT int pthread_attr_getstackaddr (const pthread_attr_t * attr,
-					   void **stackaddr);
-
-PTW32_DLLPORT int pthread_attr_getstacksize (const pthread_attr_t * attr,
-					   size_t * stacksize);
-
-PTW32_DLLPORT int pthread_attr_setdetachstate (pthread_attr_t * attr,
-					 int detachstate);
-
-PTW32_DLLPORT int pthread_attr_setstackaddr (pthread_attr_t * attr,
-					   void *stackaddr);
-
-PTW32_DLLPORT int pthread_attr_setstacksize (pthread_attr_t * attr,
-					   size_t stacksize);
-
-PTW32_DLLPORT int pthread_attr_getschedparam (const pthread_attr_t *attr,
-					struct sched_param *param);
-
-PTW32_DLLPORT int pthread_attr_setschedparam (pthread_attr_t *attr,
-					const struct sched_param *param);
-
-PTW32_DLLPORT int pthread_attr_setschedpolicy (pthread_attr_t *,
-					 int);
-
-PTW32_DLLPORT int pthread_attr_getschedpolicy (pthread_attr_t *,
-					 int *);
-
-PTW32_DLLPORT int pthread_attr_setinheritsched(pthread_attr_t * attr,
-					 int inheritsched);
-
-PTW32_DLLPORT int pthread_attr_getinheritsched(pthread_attr_t * attr,
-					 int * inheritsched);
-
-PTW32_DLLPORT int pthread_attr_setscope (pthread_attr_t *,
-				   int);
-
-PTW32_DLLPORT int pthread_attr_getscope (const pthread_attr_t *,
-				   int *);
-
-/*
- * PThread Functions
- */
-PTW32_DLLPORT int pthread_create (pthread_t * tid,
-				const pthread_attr_t * attr,
-				void *(*start) (void *),
-				void *arg);
-
-PTW32_DLLPORT int pthread_detach (pthread_t tid);
-
-PTW32_DLLPORT int pthread_equal (pthread_t t1,
-			   pthread_t t2);
-
-PTW32_DLLPORT void pthread_exit (void *value_ptr);
-
-PTW32_DLLPORT int pthread_join (pthread_t thread,
-			  void **value_ptr);
-
-PTW32_DLLPORT pthread_t pthread_self (void);
-
-PTW32_DLLPORT int pthread_cancel (pthread_t thread);
-
-PTW32_DLLPORT int pthread_setcancelstate (int state,
-					int *oldstate);
-
-PTW32_DLLPORT int pthread_setcanceltype (int type,
-				   int *oldtype);
-
-PTW32_DLLPORT void pthread_testcancel (void);
-
-PTW32_DLLPORT int pthread_once (pthread_once_t * once_control,
-			  void (*init_routine) (void));
-
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX
-PTW32_DLLPORT ptw32_cleanup_t *ptw32_pop_cleanup (int execute);
-
-PTW32_DLLPORT void ptw32_push_cleanup (ptw32_cleanup_t * cleanup,
-				 void (*routine) (void *),
-				 void *arg);
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
-
-/*
- * Thread Specific Data Functions
- */
-PTW32_DLLPORT int pthread_key_create (pthread_key_t * key,
-				void (*destructor) (void *));
-
-PTW32_DLLPORT int pthread_key_delete (pthread_key_t key);
-
-PTW32_DLLPORT int pthread_setspecific (pthread_key_t key,
-				 const void *value);
-
-PTW32_DLLPORT void *pthread_getspecific (pthread_key_t key);
-
-
-/*
- * Mutex Attribute Functions
- */
-PTW32_DLLPORT int pthread_mutexattr_init (pthread_mutexattr_t * attr);
-
-PTW32_DLLPORT int pthread_mutexattr_destroy (pthread_mutexattr_t * attr);
-
-PTW32_DLLPORT int pthread_mutexattr_getpshared (const pthread_mutexattr_t
-					  * attr,
-					  int *pshared);
-
-PTW32_DLLPORT int pthread_mutexattr_setpshared (pthread_mutexattr_t * attr,
-					  int pshared);
-
-PTW32_DLLPORT int pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind);
-PTW32_DLLPORT int pthread_mutexattr_gettype (pthread_mutexattr_t * attr, int *kind);
-
-/*
- * Barrier Attribute Functions
- */
-PTW32_DLLPORT int pthread_barrierattr_init (pthread_barrierattr_t * attr);
-
-PTW32_DLLPORT int pthread_barrierattr_destroy (pthread_barrierattr_t * attr);
-
-PTW32_DLLPORT int pthread_barrierattr_getpshared (const pthread_barrierattr_t
-						* attr,
-						int *pshared);
-
-PTW32_DLLPORT int pthread_barrierattr_setpshared (pthread_barrierattr_t * attr,
-						int pshared);
-
-/*
- * Mutex Functions
- */
-PTW32_DLLPORT int pthread_mutex_init (pthread_mutex_t * mutex,
-				const pthread_mutexattr_t * attr);
-
-PTW32_DLLPORT int pthread_mutex_destroy (pthread_mutex_t * mutex);
-
-PTW32_DLLPORT int pthread_mutex_lock (pthread_mutex_t * mutex);
-
-PTW32_DLLPORT int pthread_mutex_timedlock(pthread_mutex_t *mutex,
-					const struct timespec *abstime);
-
-PTW32_DLLPORT int pthread_mutex_trylock (pthread_mutex_t * mutex);
-
-PTW32_DLLPORT int pthread_mutex_unlock (pthread_mutex_t * mutex);
-
-/*
- * Spinlock Functions
- */
-PTW32_DLLPORT int pthread_spin_init (pthread_spinlock_t * lock, int pshared);
-
-PTW32_DLLPORT int pthread_spin_destroy (pthread_spinlock_t * lock);
-
-PTW32_DLLPORT int pthread_spin_lock (pthread_spinlock_t * lock);
-
-PTW32_DLLPORT int pthread_spin_trylock (pthread_spinlock_t * lock);
-
-PTW32_DLLPORT int pthread_spin_unlock (pthread_spinlock_t * lock);
-
-/*
- * Barrier Functions
- */
-PTW32_DLLPORT int pthread_barrier_init (pthread_barrier_t * barrier,
-				  const pthread_barrierattr_t * attr,
-				  unsigned int count);
-
-PTW32_DLLPORT int pthread_barrier_destroy (pthread_barrier_t * barrier);
-
-PTW32_DLLPORT int pthread_barrier_wait (pthread_barrier_t * barrier);
-
-/*
- * Condition Variable Attribute Functions
- */
-PTW32_DLLPORT int pthread_condattr_init (pthread_condattr_t * attr);
-
-PTW32_DLLPORT int pthread_condattr_destroy (pthread_condattr_t * attr);
-
-PTW32_DLLPORT int pthread_condattr_getpshared (const pthread_condattr_t * attr,
-					 int *pshared);
-
-PTW32_DLLPORT int pthread_condattr_setpshared (pthread_condattr_t * attr,
-					 int pshared);
-
-/*
- * Condition Variable Functions
- */
-PTW32_DLLPORT int pthread_cond_init (pthread_cond_t * cond,
-				   const pthread_condattr_t * attr);
-
-PTW32_DLLPORT int pthread_cond_destroy (pthread_cond_t * cond);
-
-PTW32_DLLPORT int pthread_cond_wait (pthread_cond_t * cond,
-				   pthread_mutex_t * mutex);
-
-PTW32_DLLPORT int pthread_cond_timedwait (pthread_cond_t * cond,
-					pthread_mutex_t * mutex,
-					const struct timespec *abstime);
-
-PTW32_DLLPORT int pthread_cond_signal (pthread_cond_t * cond);
-
-PTW32_DLLPORT int pthread_cond_broadcast (pthread_cond_t * cond);
-
-/*
- * Scheduling
- */
-PTW32_DLLPORT int pthread_setschedparam (pthread_t thread,
-				   int policy,
-				   const struct sched_param *param);
-
-PTW32_DLLPORT int pthread_getschedparam (pthread_t thread,
-				   int *policy,
-				   struct sched_param *param);
-
-PTW32_DLLPORT int pthread_setconcurrency (int);
- 
-PTW32_DLLPORT int pthread_getconcurrency (void);
-
-/*
- * Read-Write Lock Functions
- */
-PTW32_DLLPORT int pthread_rwlock_init(pthread_rwlock_t *lock,
-				const pthread_rwlockattr_t *attr);
-
-PTW32_DLLPORT int pthread_rwlock_destroy(pthread_rwlock_t *lock);
-
-PTW32_DLLPORT int pthread_rwlock_tryrdlock(pthread_rwlock_t *);
-
-PTW32_DLLPORT int pthread_rwlock_trywrlock(pthread_rwlock_t *);
-
-PTW32_DLLPORT int pthread_rwlock_rdlock(pthread_rwlock_t *lock);
-
-PTW32_DLLPORT int pthread_rwlock_timedrdlock(pthread_rwlock_t *lock,
-					   const struct timespec *abstime);
-
-PTW32_DLLPORT int pthread_rwlock_wrlock(pthread_rwlock_t *lock);
-
-PTW32_DLLPORT int pthread_rwlock_timedwrlock(pthread_rwlock_t *lock,
-					   const struct timespec *abstime);
-
-PTW32_DLLPORT int pthread_rwlock_unlock(pthread_rwlock_t *lock);
-
-PTW32_DLLPORT int pthread_rwlockattr_init (pthread_rwlockattr_t * attr);
-
-PTW32_DLLPORT int pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr);
-
-PTW32_DLLPORT int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr,
-					   int *pshared);
-
-PTW32_DLLPORT int pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr,
-					   int pshared);
-
-/*
- *  Errno reading function
- *  Added by Paul Pedriana, 10/2003 
- */
-PTW32_DLLPORT int pthread_win32_errno(void);
-
-
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX - 1
-
-/*
- * Signal Functions. Should be defined in <signal.h> but MSVC and MinGW32
- * already have signal.h that don't define these.
- */
-PTW32_DLLPORT int pthread_kill(pthread_t thread, int sig);
-
-/*
- * Non-portable functions
- */
-
-/*
- * Compatibility with Linux.
- */
-PTW32_DLLPORT int pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr,
-					 int kind);
-PTW32_DLLPORT int pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr,
-					 int *kind);
-
-/*
- * Possibly supported by other POSIX threads implementations
- */
-PTW32_DLLPORT int pthread_delay_np (struct timespec * interval);
-PTW32_DLLPORT int pthread_num_processors_np(void);
-
-/*
- * Useful if an application wants to statically link
- * the lib rather than load the DLL at run-time.
- */
-PTW32_DLLPORT int pthread_win32_process_attach_np(void);
-PTW32_DLLPORT int pthread_win32_process_detach_np(void);
-PTW32_DLLPORT int pthread_win32_thread_attach_np(void);
-PTW32_DLLPORT int pthread_win32_thread_detach_np(void);
-
-/*
- * Register a system time change with the library.
- * Causes the library to perform various functions
- * in response to the change. Should be called whenever
- * the application's top level window receives a
- * WM_TIMECHANGE message. It can be passed directly to
- * pthread_create() as a new thread if desired.
- */
-PTW32_DLLPORT void * pthread_timechange_handler_np(void *);
-
-#endif /*PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 */
-
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX
-
-/*
- * Returns the Win32 HANDLE for the POSIX thread.
- */
-PTW32_DLLPORT HANDLE pthread_getw32threadhandle_np(pthread_t thread);
-
-
-/*
- * Protected Methods
- *
- * This function blocks until the given WIN32 handle
- * is signaled or pthread_cancel had been called.
- * This function allows the caller to hook into the
- * PThreads cancel mechanism. It is implemented using
- *
- *		WaitForMultipleObjects
- *
- * on 'waitHandle' and a manually reset WIN32 Event
- * used to implement pthread_cancel. The 'timeout'
- * argument to TimedWait is simply passed to
- * WaitForMultipleObjects.
- */
-PTW32_DLLPORT int pthreadCancelableWait (HANDLE waitHandle);
-PTW32_DLLPORT int pthreadCancelableTimedWait (HANDLE waitHandle,
-					DWORD timeout);
-
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
-
-/*
- * Thread-Safe C Runtime Library Mappings.
- */
-#ifndef _UWIN
-#  if defined(NEED_ERRNO)
-	 PTW32_DLLPORT int * _errno( void );
-#  else
-#    ifndef errno
-#      if (defined(_MT) || defined(_DLL))
-	 __declspec(dllimport) extern int * __cdecl _errno(void);
-#	 define errno	(*_errno())
-#      endif
-#    endif
-#  endif
-#endif
-
-/*
- * WIN32 C runtime library had been made thread-safe
- * without affecting the user interface. Provide
- * mappings from the UNIX thread-safe versions to
- * the standard C runtime library calls.
- * Only provide function mappings for functions that
- * actually exist on WIN32.
- */
-
-#if !defined(__MINGW32__)
-#define strtok_r( _s, _sep, _lasts ) \
-	( *(_lasts) = strtok( (_s), (_sep) ) )
-#endif /* !__MINGW32__ */
-
-#define asctime_r( _tm, _buf ) \
-	( strcpy( (_buf), asctime( (_tm) ) ), \
-	  (_buf) )
-
-#define ctime_r( _clock, _buf ) \
-	( strcpy( (_buf), ctime( (_clock) ) ),	\
-	  (_buf) )
-
-#define gmtime_r( _clock, _result ) \
-	( *(_result) = *gmtime( (_clock) ), \
-	  (_result) )
-
-#define localtime_r( _clock, _result ) \
-	( *(_result) = *localtime( (_clock) ), \
-	  (_result) )
-
-#define rand_r( _seed ) \
-	( _seed == _seed? rand() : rand() )
-
-
-#ifdef __cplusplus
-
-/*
- * Internal exceptions
- */
-class ptw32_exception {};
-class ptw32_exception_cancel : public ptw32_exception {};
-class ptw32_exception_exit   : public ptw32_exception {};
-
-#endif
-
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX
-
-/* FIXME: This is only required if the library was built using SEH */
-/*
- * Get internal SEH tag
- */
-PTW32_DLLPORT DWORD ptw32_get_exception_services_code(void);
-
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
-
-#ifndef PTW32_BUILD
-
-#ifdef __CLEANUP_SEH
-
-/*
- * Redefine the SEH __except keyword to ensure that applications
- * propagate our internal exceptions up to the library's internal handlers.
- */
-#define __except( E ) \
-	__except( ( GetExceptionCode() == ptw32_get_exception_services_code() ) \
-		 ? EXCEPTION_CONTINUE_SEARCH : ( E ) )
-
-#endif /* __CLEANUP_SEH */
-
-#ifdef __CLEANUP_CXX
-
-/*
- * Redefine the C++ catch keyword to ensure that applications
- * propagate our internal exceptions up to the library's internal handlers.
- */
-#ifdef _MSC_VER
-	/*
-	 * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll'
-	 * if you want Pthread-Win32 cancelation and pthread_exit to work.
-	 */
-
-#ifndef PtW32NoCatchWarn
-
-#pragma message("Specify \"/DPtW32NoCatchWarn\" compiler flag to skip this message.")
-#pragma message("------------------------------------------------------------------")
-#pragma message("When compiling applications with MSVC++ and C++ exception handling:")
-#pragma message("  Replace any 'catch( ... )' in routines called from POSIX threads")
-#pragma message("  with 'PtW32CatchAll' or 'CATCHALL' if you want POSIX thread")
-#pragma message("  cancelation and pthread_exit to work. For example:")
-#pragma message("")
-#pragma message("    #ifdef PtW32CatchAll")
-#pragma message("      PtW32CatchAll")
-#pragma message("    #else")
-#pragma message("      catch(...)")
-#pragma message("    #endif")
-#pragma message("	 {")
-#pragma message("	   /* Catchall block processing */")
-#pragma message("	 }")
-#pragma message("------------------------------------------------------------------")
-
-#endif
-
-#define PtW32CatchAll \
-	catch( ptw32_exception & ) { throw; } \
-	catch( ... )
-
-#else /* _MSC_VER */
-
-#define catch( E ) \
-	catch( ptw32_exception & ) { throw; } \
-	catch( E )
-
-#endif /* _MSC_VER */
-
-#endif /* __CLEANUP_CXX */
-
-#endif /* ! PTW32_BUILD */
-
-#ifdef __cplusplus
-}				/* End of extern "C" */
-#endif				/* __cplusplus */
-
-#ifdef PTW32__HANDLE_DEF
-# undef HANDLE
-#endif
-#ifdef PTW32__DWORD_DEF
-# undef DWORD
-#endif
-
-#undef PTW32_LEVEL
-#undef PTW32_LEVEL_MAX
-
-#endif /* PTHREAD_H */

+ 0 - 174
test/thread/lib/pthreads-win32/include/sched.h

@@ -1,174 +0,0 @@
-/*
- * Module: sched.h
- *
- * Purpose:
- *      Provides an implementation of POSIX realtime extensions
- *      as defined in 
- *
- *              POSIX 1003.1b-1993      (POSIX.1b)
- *
- * --------------------------------------------------------------------------
- *
- *      Pthreads-win32 - POSIX Threads Library for Win32
- *      Copyright(C) 1998 John E. Bossom
- *      Copyright(C) 1999,2003 Pthreads-win32 contributors
- * 
- *      Contact Email: [email protected]
- * 
- *      The current list of contributors is contained
- *      in the file CONTRIBUTORS included with the source
- *      code distribution. The list can also be seen at the
- *      following World Wide Web location:
- *      http://sources.redhat.com/pthreads-win32/contributors.html
- * 
- *      This library is free software; you can redistribute it and/or
- *      modify it under the terms of the GNU Lesser General Public
- *      License as published by the Free Software Foundation; either
- *      version 2 of the License, or (at your option) any later version.
- * 
- *      This library is distributed in the hope that it will be useful,
- *      but WITHOUT ANY WARRANTY; without even the implied warranty of
- *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *      Lesser General Public License for more details.
- * 
- *      You should have received a copy of the GNU Lesser General Public
- *      License along with this library in the file COPYING.LIB;
- *      if not, write to the Free Software Foundation, Inc.,
- *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-#ifndef _SCHED_H
-#define _SCHED_H
-
-#undef PTW32_LEVEL
-
-#if defined(_POSIX_SOURCE)
-#define PTW32_LEVEL 0
-/* Early POSIX */
-#endif
-
-#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
-#undef PTW32_LEVEL
-#define PTW32_LEVEL 1
-/* Include 1b, 1c and 1d */
-#endif
-
-#if defined(INCLUDE_NP)
-#undef PTW32_LEVEL
-#define PTW32_LEVEL 2
-/* Include Non-Portable extensions */
-#endif
-
-#define PTW32_LEVEL_MAX 3
-
-#if !defined(PTW32_LEVEL)
-#define PTW32_LEVEL PTW32_LEVEL_MAX
-/* Include everything */
-#endif
-
-
-#if __GNUC__ && ! defined (__declspec)
-# error Please upgrade your GNU compiler to one that supports __declspec.
-#endif
-
-/*
- * When building the DLL code, you should define PTW32_BUILD so that
- * the variables/functions are exported correctly. When using the DLL,
- * do NOT define PTW32_BUILD, and then the variables/functions will
- * be imported correctly.
- */
-#ifdef PTW32_BUILD
-# define PTW32_DLLPORT __declspec (dllexport)
-#else
-# define PTW32_DLLPORT __declspec (dllimport)
-#endif
-
-/*
- * This is a duplicate of what is in the autoconf config.h,
- * which is only used when building the pthread-win32 libraries.
- */
-
-#ifndef PTW32_CONFIG_H
-#  if defined(WINCE)
-#    define NEED_ERRNO
-#    define NEED_SEM
-#  endif
-#  if defined(_UWIN) || defined(__MINGW32__)
-#    define HAVE_MODE_T
-#  endif
-#endif
-
-/*
- *
- */
-
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX
-#ifdef NEED_ERRNO
-#include "need_errno.h"
-#else
-#include <errno.h>
-#endif
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
-
-#if defined(__MINGW32__) || defined(_UWIN)
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX
-/* For pid_t */
-#  include <sys/types.h>
-/* Required by Unix 98 */
-#  include <time.h>
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
-#else
-typedef int pid_t;
-#endif
-
-/* Thread scheduling policies */
-
-enum {
-  SCHED_OTHER = 0,
-  SCHED_FIFO,
-  SCHED_RR,
-  SCHED_MIN   = SCHED_OTHER,
-  SCHED_MAX   = SCHED_RR
-};
-
-struct sched_param {
-  int sched_priority;
-};
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif                          /* __cplusplus */
-
-PTW32_DLLPORT int sched_yield (void);
-
-PTW32_DLLPORT int sched_get_priority_min (int policy);
-
-PTW32_DLLPORT int sched_get_priority_max (int policy);
-
-PTW32_DLLPORT int sched_setscheduler (pid_t pid, int policy);
-
-PTW32_DLLPORT int sched_getscheduler (pid_t pid);
-
-/*
- * Note that this macro returns ENOTSUP rather than
- * ENOSYS as might be expected. However, returning ENOSYS
- * should mean that sched_get_priority_{min,max} are
- * not implemented as well as sched_rr_get_interval.
- * This is not the case, since we just don't support
- * round-robin scheduling. Therefore I have chosen to
- * return the same value as sched_setscheduler when
- * SCHED_RR is passed to it.
- */
-#define sched_rr_get_interval(_pid, _interval) \
-  ( errno = ENOTSUP, (int) -1 )
-
-
-#ifdef __cplusplus
-}                               /* End of extern "C" */
-#endif                          /* __cplusplus */
-
-#undef PTW32_LEVEL
-#undef PTW32_LEVEL_MAX
-
-#endif                          /* !_SCHED_H */
-

+ 0 - 163
test/thread/lib/pthreads-win32/include/semaphore.h

@@ -1,163 +0,0 @@
-/*
- * Module: semaphore.h
- *
- * Purpose:
- *	Semaphores aren't actually part of the PThreads standard.
- *	They are defined by the POSIX Standard:
- *
- *		POSIX 1003.1b-1993	(POSIX.1b)
- *
- * --------------------------------------------------------------------------
- *
- *      Pthreads-win32 - POSIX Threads Library for Win32
- *      Copyright(C) 1998 John E. Bossom
- *      Copyright(C) 1999,2003 Pthreads-win32 contributors
- * 
- *      Contact Email: [email protected]
- * 
- *      The current list of contributors is contained
- *      in the file CONTRIBUTORS included with the source
- *      code distribution. The list can also be seen at the
- *      following World Wide Web location:
- *      http://sources.redhat.com/pthreads-win32/contributors.html
- * 
- *      This library is free software; you can redistribute it and/or
- *      modify it under the terms of the GNU Lesser General Public
- *      License as published by the Free Software Foundation; either
- *      version 2 of the License, or (at your option) any later version.
- * 
- *      This library is distributed in the hope that it will be useful,
- *      but WITHOUT ANY WARRANTY; without even the implied warranty of
- *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *      Lesser General Public License for more details.
- * 
- *      You should have received a copy of the GNU Lesser General Public
- *      License along with this library in the file COPYING.LIB;
- *      if not, write to the Free Software Foundation, Inc.,
- *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-#if !defined( SEMAPHORE_H )
-#define SEMAPHORE_H
-
-#undef PTW32_LEVEL
-
-#if defined(_POSIX_SOURCE)
-#define PTW32_LEVEL 0
-/* Early POSIX */
-#endif
-
-#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
-#undef PTW32_LEVEL
-#define PTW32_LEVEL 1
-/* Include 1b, 1c and 1d */
-#endif
-
-#if defined(INCLUDE_NP)
-#undef PTW32_LEVEL
-#define PTW32_LEVEL 2
-/* Include Non-Portable extensions */
-#endif
-
-#define PTW32_LEVEL_MAX 3
-
-#if !defined(PTW32_LEVEL)
-#define PTW32_LEVEL PTW32_LEVEL_MAX
-/* Include everything */
-#endif
-
-#if __GNUC__ && ! defined (__declspec)
-# error Please upgrade your GNU compiler to one that supports __declspec.
-#endif
-
-/*
- * When building the DLL code, you should define PTW32_BUILD so that
- * the variables/functions are exported correctly. When using the DLL,
- * do NOT define PTW32_BUILD, and then the variables/functions will
- * be imported correctly.
- */
-#ifdef PTW32_BUILD
-# define PTW32_DLLPORT __declspec (dllexport)
-#else
-# define PTW32_DLLPORT __declspec (dllimport)
-#endif
-
-
-/*
- * This is a duplicate of what is in the autoconf config.h,
- * which is only used when building the pthread-win32 libraries.
- */
-
-#ifndef PTW32_CONFIG_H
-#  if defined(WINCE)
-#    define NEED_ERRNO
-#    define NEED_SEM
-#  endif
-#  if defined(_UWIN) || defined(__MINGW32__)
-#    define HAVE_MODE_T
-#  endif
-#endif
-
-/*
- *
- */
-
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX
-#ifdef NEED_ERRNO
-#include "need_errno.h"
-#else
-#include <errno.h>
-#endif
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
-
-#define _POSIX_SEMAPHORES
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif				/* __cplusplus */
-
-#ifndef HAVE_MODE_T
-typedef unsigned int mode_t;
-#endif
-
-
-typedef struct sem_t_ * sem_t;
-
-PTW32_DLLPORT int sem_init (sem_t * sem,
-				int pshared,
-				unsigned int value);
-
-PTW32_DLLPORT int sem_destroy (sem_t * sem);
-
-PTW32_DLLPORT int sem_trywait (sem_t * sem);
-
-PTW32_DLLPORT int sem_wait (sem_t * sem);
-
-PTW32_DLLPORT int sem_timedwait (sem_t * sem,
-				 const struct timespec * abstime);
-
-PTW32_DLLPORT int sem_post (sem_t * sem);
-
-PTW32_DLLPORT int sem_post_multiple (sem_t * sem,
-					 int count);
-
-PTW32_DLLPORT int sem_open (const char * name,
-				int oflag,
-				mode_t mode,
-				unsigned int value);
-
-PTW32_DLLPORT int sem_close (sem_t * sem);
-
-PTW32_DLLPORT int sem_unlink (const char * name);
-
-PTW32_DLLPORT int sem_getvalue (sem_t * sem,
-				int * sval);
-
-#ifdef __cplusplus
-}				/* End of extern "C" */
-#endif				/* __cplusplus */
-
-#undef PTW32_LEVEL
-#undef PTW32_LEVEL_MAX
-
-#endif				/* !SEMAPHORE_H */

BIN
test/thread/lib/pthreads-win32/lib/pthreadVC.dll


BIN
test/thread/lib/pthreads-win32/lib/pthreadVC.lib


BIN
test/thread/lib/pthreads-win32/lib/pthreadVC.pdb


+ 1 - 1
test/thread/source/TestThread.cpp

@@ -110,7 +110,7 @@ bool IsSuperUser()
 int TestThreadGetThreadTimeMin()
 {
 	int nErrorCount(0);
-#if defined(EA_PLATFORM_MICROSOFT) || defined(EA_PLATFORM_KETTLE)
+#if defined(EA_PLATFORM_MICROSOFT) || defined(EA_PLATFORM_PS4)
 	EATEST_VERIFY_MSG(EA::Thread::GetThreadTime() >= EATHREAD_MIN_ABSOLUTE_TIME, "Reported GetThreadTime absolute time is less than EATHREAD_MIN_ABSOLUTE_TIME. You are going to have a bad time.");
 #endif
 	return nErrorCount;

+ 4 - 4
test/thread/source/TestThreadCallstack.cpp

@@ -256,7 +256,7 @@ EA_NO_INLINE EACALLSTACK_TEST_FUNCTION_LINKAGE  int TestRemoteThreadContextVsCal
 	auto threadId = remoteThread.mThread.GetId();
 
 	{
-#if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_CAPILANO)
+#if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_XBOXONE)
 		// suspend the target thread to make sure we get a coherent callstack
 		bool wasSuspended = (::SuspendThread(threadId) != ((DWORD)-1)); // fail is (DWORD)-1
 #endif
@@ -267,7 +267,7 @@ EA_NO_INLINE EACALLSTACK_TEST_FUNCTION_LINKAGE  int TestRemoteThreadContextVsCal
 			EA::Thread::GetCallstack(addressContextArray, EAArrayCount(addressContextArray), &callstackContext);
 		}
 
-#if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_CAPILANO)
+#if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_XBOXONE)
 		// resume the target thread as needed
 		if (wasSuspended)
 		{
@@ -305,7 +305,7 @@ int TestThreadCallstack()
 			EA::Thread::ShutdownCallstack();
 		}
 
-		#if defined(EA_PLATFORM_WIN64) || defined(EA_PLATFORM_CAPILANO) ||  defined(EA_PLATFORM_KETTLE)
+		#if defined(EA_PLATFORM_WIN64) || defined(EA_PLATFORM_XBOXONE) ||  defined(EA_PLATFORM_PS4)
 		// This test will spawn a thread which will grab its own context and provide it to the main thread 
 		// to use when generating a callstack. We use semaphores to control the created thread to ensure 
 		// the thread is alive while we call GetCallstack() inside of VerifyCallstack()
@@ -344,7 +344,7 @@ int TestThreadCallstack()
 			EA::Thread::InitCallstack();
 
 			const int numErrorInRemoteTest = TestRemoteThreadContextVsCallstack();
-			#if defined(EA_PLATFORM_KETTLE) // We know that kettle cannot do remote callstacks. This is just to check that it does not crash when attempting to do a remote callstack
+			#if defined(EA_PLATFORM_PS4) // We know that kettle cannot do remote callstacks. This is just to check that it does not crash when attempting to do a remote callstack
 				EATEST_VERIFY(numErrorInRemoteTest != 0);
 			#else
 				nErrorCount += numErrorInRemoteTest;

+ 8 - 21
test/thread/source/TestThreadThread.cpp

@@ -93,9 +93,8 @@ static intptr_t TestFunction7(void*)
 
 static intptr_t TestFunction8(void*)
 {
-	ThreadSleep(2000);
-
-	++sShouldGo;
+	while(sShouldGo == 0)
+		ThreadSleep(10);
 
 	return 0;
 }
@@ -665,7 +664,7 @@ int TestThreadDisablePriorityBoost()
 {
 	int nErrorCount = 0;
 
-#if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_CAPILANO)
+#if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_XBOXONE)
 	{
 		Thread thread;
 		ThreadParameters params;
@@ -831,7 +830,7 @@ int TestThreadThread()
 
 		EATEST_VERIFY_MSG(sysThreadId != kSysThreadIdInvalid, "GetSysThreadId failure.\n");
 
-		#if (defined(EA_PLATFORM_MICROSOFT) || defined(EA_PLATFORM_UNIX) || defined(EA_PLATFORM_KETTLE)) && !EA_USE_CPP11_CONCURRENCY
+		#if (defined(EA_PLATFORM_MICROSOFT) || defined(EA_PLATFORM_UNIX) || defined(EA_PLATFORM_PS4)) && !EA_USE_CPP11_CONCURRENCY
 			const void*    pStackBase = GetThreadStackBase();
 			const void*    pStackTop  = &pStackBase;
 			const intptr_t stackSize  = ((char*)pStackBase - (char*)pStackTop);
@@ -843,7 +842,7 @@ int TestThreadThread()
 
 		// We disable this test for now on Kettle because although we have 7 cores available 
 		// there is no guaranty the their ID are 0..6 and the system takes core ID 7
-		#if !defined(EA_PLATFORM_KETTLE)
+		#if !defined(EA_PLATFORM_PS4)
 
 			int processorCount = GetProcessorCount();
 			int processor      = GetThreadProcessor();
@@ -1187,23 +1186,11 @@ int TestThreadThread()
 			ThreadId threadId = thread.Begin(TestFunction8);
 			EATEST_VERIFY_MSG(threadId != kThreadIdInvalid, "Thread failure: thread.Begin(TestFunction8) failed.\n");
 
-			// Give the thread a nominal second to get going and ensure we get a decent overlap of a second.
-			ThreadSleep(1000);
-
 			// Now we exit our scope while our thread in theory still has a second before it completes
-		}
-		
-		// We either get here before the thread function completes in which case sShouldGo is 0 or
-		// we get here after it completes which would be incorrect and would give us a sShouldGo of 1
-		const bool threadScopeSemanticsVerified = sShouldGo == 0;
+		} // NOTE(rparolin): If your test hangs here, its most likely due to a semantic change in the thread object that is waiting for threads to complete.
 
-		// Rather than try to wait on threadid in a cross platform way we simply sleep for 2 seconds which 
-		// we know should be sufficient for the thread to complete. We can make this part of the test
-		// as shouldgo should be 1 when the thread has completed.
-		ThreadSleep(2000);
-
-		EATEST_VERIFY_MSG(threadScopeSemanticsVerified, "Thread failure: Thread should not have ended before Thread object dtor completed. Behaviour is inconsistent with intent.\n");
-		EATEST_VERIFY_MSG(sShouldGo == 1, "Thread failure: Thread set to run for 2 seconds at least 3 seconds ago. Should have ended by now.\n");
+		// Signal to the thread it is allowed to complete.
+		sShouldGo = 1;
 	}