config.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Copyright (c) Electronic Arts Inc. All rights reserved.
  3. ///////////////////////////////////////////////////////////////////////////////
  4. #ifndef EATHREAD_INTERNAL_CONFIG_H
  5. #define EATHREAD_INTERNAL_CONFIG_H
  6. #include <EABase/eabase.h>
  7. EA_DISABLE_VC_WARNING(4574)
  8. #include <stddef.h>
  9. EA_RESTORE_VC_WARNING()
  10. #if defined(EA_PRAGMA_ONCE_SUPPORTED)
  11. #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.
  12. #endif
  13. ///////////////////////////////////////////////////////////////////////////////
  14. // EATHREAD_VERSION
  15. //
  16. // We more or less follow the conventional EA packaging approach to versioning
  17. // here. A primary distinction here is that minor versions are defined as two
  18. // digit entities (e.g. .03") instead of minimal digit entities ".3"). The logic
  19. // here is that the value is a counter and not a floating point fraction.
  20. // Note that the major version doesn't have leading zeros.
  21. //
  22. // Example version strings:
  23. // "0.91.00" // Major version 0, minor version 91, patch version 0.
  24. // "1.00.00" // Major version 1, minor and patch version 0.
  25. // "3.10.02" // Major version 3, minor version 10, patch version 02.
  26. // "12.03.01" // Major version 12, minor version 03, patch version
  27. //
  28. // Example usage:
  29. // printf("EATHREAD_VERSION version: %s", EATHREAD_VERSION);
  30. // printf("EATHREAD_VERSION version: %d.%d.%d", EATHREAD_VERSION_N / 10000 % 100, EATHREAD_VERSION_N / 100 % 100, EATHREAD_VERSION_N % 100);
  31. //
  32. #ifndef EATHREAD_VERSION
  33. #define EATHREAD_VERSION "1.32.09"
  34. #define EATHREAD_VERSION_N 13209
  35. // Older style version info
  36. #define EATHREAD_VERSION_MAJOR (EATHREAD_VERSION_N / 100 / 100 % 100)
  37. #define EATHREAD_VERSION_MINOR (EATHREAD_VERSION_N / 100 % 100)
  38. #define EATHREAD_VERSION_PATCH (EATHREAD_VERSION_N % 100)
  39. #endif
  40. ///////////////////////////////////////////////////////////////////////////////
  41. // _GNU_SOURCE
  42. //
  43. // Defined or not defined.
  44. // If this is defined then GlibC extension functionality is enabled during
  45. // calls to glibc header files.
  46. //
  47. #if !defined(_GNU_SOURCE)
  48. #define _GNU_SOURCE
  49. #endif
  50. ///////////////////////////////////////////////////////////////////////////////
  51. // EATHREAD_TLS_COUNT
  52. //
  53. // Defined as compile-time constant integer > 0.
  54. //
  55. #if !defined(EATHREAD_TLS_COUNT)
  56. #define EATHREAD_TLS_COUNT 16
  57. #endif
  58. ///////////////////////////////////////////////////////////////////////////////
  59. // EA_THREADS_AVAILABLE
  60. //
  61. // Defined as 0 or 1
  62. // Defines if threading is supported on the given platform.
  63. // If 0 then the EAThread implementation is not capable of creating threads,
  64. // but other facilities (e.g. mutex) work in a non-thread-aware way.
  65. //
  66. #ifndef EA_THREADS_AVAILABLE
  67. #define EA_THREADS_AVAILABLE 1
  68. #endif
  69. ///////////////////////////////////////////////////////////////////////////////
  70. // EA_USE_CPP11_CONCURRENCY
  71. //
  72. // Defined as 0 or 1
  73. //
  74. #ifndef EA_USE_CPP11_CONCURRENCY
  75. #if defined(EA_PLATFORM_WINDOWS) && !EA_WINAPI_FAMILY_PARTITION(EA_WINAPI_PARTITION_DESKTOP)
  76. #define EA_USE_CPP11_CONCURRENCY 1
  77. #else
  78. #define EA_USE_CPP11_CONCURRENCY 0
  79. #endif
  80. #endif
  81. ///////////////////////////////////////////////////////////////////////////////
  82. // EA_USE_COMMON_ATOMICINT_IMPLEMENTATION
  83. //
  84. // Use the common EAThread AtomicInt implementation on all platforms.
  85. //
  86. // Defined as 0 or 1
  87. //
  88. #ifndef EA_USE_COMMON_ATOMICINT_IMPLEMENTATION
  89. #define EA_USE_COMMON_ATOMICINT_IMPLEMENTATION 1
  90. #endif
  91. ///////////////////////////////////////////////////////////////////////////////
  92. // EA_OPENKODE_THREADS_AVAILABLE
  93. //
  94. // Defined as 0 or 1
  95. //
  96. #ifndef EA_OPENKODE_THREADS_AVAILABLE
  97. #define EA_OPENKODE_THREADS_AVAILABLE 0 // used historically on the Marmalade (Airplay) platform.
  98. #endif
  99. ///////////////////////////////////////////////////////////////////////////////
  100. // EAT_ASSERT_ENABLED
  101. //
  102. // Defined as 0 or 1, default is 1 if EA_DEBUG or _DEBUG is defined.
  103. // If defined as 1, then assertion failures are reported via EA::Thread::AssertionFailure().
  104. //
  105. #ifndef EAT_ASSERT_ENABLED
  106. #if defined(EA_DEBUG) || defined(_DEBUG)
  107. #define EAT_ASSERT_ENABLED 1
  108. #else
  109. #define EAT_ASSERT_ENABLED 0
  110. #endif
  111. #endif
  112. #if EAT_ASSERT_ENABLED
  113. #define EAT_STRINGIFY_HELPER(x) #x
  114. #define EAT_STRINGIFY(x) EAT_STRINGIFY_HELPER(x)
  115. #define EAT_ASSERT(expression) \
  116. EA_DISABLE_VC_WARNING(4127) \
  117. do { \
  118. EA_ANALYSIS_ASSUME(expression); \
  119. if (!(expression) ) \
  120. EA::Thread::AssertionFailure(__FILE__ "(" EAT_STRINGIFY(__LINE__) "): " #expression); \
  121. } while(0) \
  122. EA_RESTORE_VC_WARNING()
  123. #else
  124. #define EAT_ASSERT(expression)
  125. #endif
  126. #if EAT_ASSERT_ENABLED
  127. #define EAT_ASSERT_MSG(expression, msg) \
  128. EA_DISABLE_VC_WARNING(4127) \
  129. do { \
  130. EA_ANALYSIS_ASSUME(expression); \
  131. if (!(expression) ) \
  132. EA::Thread::AssertionFailure(msg); \
  133. } while(0) \
  134. EA_RESTORE_VC_WARNING()
  135. #else
  136. #define EAT_ASSERT_MSG(expression, msg)
  137. #endif
  138. #if EAT_ASSERT_ENABLED
  139. #define EAT_ASSERT_FORMATTED(expression, pFormat, ...) \
  140. EA_DISABLE_VC_WARNING(4127) \
  141. do { \
  142. EA_ANALYSIS_ASSUME(expression); \
  143. if (!(expression) ) \
  144. EA::Thread::AssertionFailureV(pFormat, __VA_ARGS__); \
  145. } while(0) \
  146. EA_RESTORE_VC_WARNING()
  147. #else
  148. #define EAT_ASSERT_FORMATTED(expression, pFormat, ...)
  149. #endif
  150. #if EAT_ASSERT_ENABLED
  151. #define EAT_FAIL_MSG(msg) (EA::Thread::AssertionFailure(msg))
  152. #else
  153. #define EAT_FAIL_MSG(msg)
  154. #endif
  155. ///////////////////////////////////////////////////////////////////////////////
  156. ///////////////////////////////////////////////////////////////////////////////
  157. // EAT_COMPILETIME_ASSERT
  158. //
  159. // Compile-time assertion for this module.
  160. // C-like declaration:
  161. // void EAT_COMPILETIME_ASSERT(bool bExpression);
  162. //
  163. #if !defined(EAT_COMPILETIME_ASSERT)
  164. #define EAT_COMPILETIME_ASSERT(expression) static_assert(expression, EA_STRINGIFY(expression))
  165. #endif
  166. ///////////////////////////////////////////////////////////////////////////////
  167. // EATHREAD_TLSALLOC_DTOR_ENABLED
  168. //
  169. // Defined as 0 or 1. Default is 1.
  170. // Defines if the TLSAlloc class destructor frees the TLS thread handle.
  171. // This won't make a difference unless you were using EAThread in a DLL and
  172. // you were repeatedly loading and unloading DLLs.
  173. // See eathread_pc.cpp for usage of this and more info about the situation.
  174. //
  175. #ifndef EATHREAD_TLSALLOC_DTOR_ENABLED
  176. #define EATHREAD_TLSALLOC_DTOR_ENABLED 1
  177. #endif
  178. ///////////////////////////////////////////////////////////////////////////////
  179. ///////////////////////////////////////////////////////////////////////////////
  180. // EATHREAD_LIKELY / EATHREAD_UNLIKELY
  181. //
  182. // Defined as a macro which gives a hint to the compiler for branch
  183. // prediction. GCC gives you the ability to manually give a hint to
  184. // the compiler about the result of a comparison, though it's often
  185. // best to compile shipping code with profiling feedback under both
  186. // GCC (-fprofile-arcs) and VC++ (/LTCG:PGO, etc.). However, there
  187. // are times when you feel very sure that a boolean expression will
  188. // usually evaluate to either true or false and can help the compiler
  189. // by using an explicity directive...
  190. //
  191. // Example usage:
  192. // if(EATHREAD_LIKELY(a == 0)) // Tell the compiler that a will usually equal 0.
  193. // { ... }
  194. //
  195. // Example usage:
  196. // if(EATHREAD_UNLIKELY(a == 0)) // Tell the compiler that a will usually not equal 0.
  197. // { ... }
  198. //
  199. #ifndef EATHREAD_LIKELY
  200. #define EATHREAD_LIKELY(x) EA_LIKELY(x)
  201. #define EATHREAD_UNLIKELY(x) EA_UNLIKELY(x)
  202. #endif
  203. ///////////////////////////////////////////////////////////////////////////////
  204. ///////////////////////////////////////////////////////////////////////////////
  205. // EATHREAD_NAMING
  206. //
  207. // Defined as 0, 1 (enabled), or 2 (enabled only when debugger is present).
  208. //
  209. #define EATHREAD_NAMING_DISABLED 0
  210. #define EATHREAD_NAMING_ENABLED 1
  211. #define EATHREAD_NAMING_OPTIONAL 2
  212. #ifndef EATHREAD_NAMING
  213. #if defined(EA_SHIP) || defined(EA_FINAL) // These are two de-facto standard EA defines for identifying a shipping build.
  214. #define EATHREAD_NAMING 0
  215. #else
  216. #define EATHREAD_NAMING EATHREAD_NAMING_ENABLED // or EATHREAD_NAMING_OPTIONAL?
  217. #endif
  218. #endif
  219. ///////////////////////////////////////////////////////////////////////////////
  220. // EATHREAD_NAME_SIZE
  221. //
  222. // Specifies the max size to support for naming threads.
  223. // This value can be changed as desired.
  224. //
  225. #ifndef EATHREAD_NAME_SIZE
  226. #if defined(EA_PLATFORM_WINDOWS) || defined(EA_PLATFORM_UNIX)
  227. #define EATHREAD_NAME_SIZE 64
  228. #else
  229. #define EATHREAD_NAME_SIZE 32
  230. #endif
  231. #endif
  232. ///////////////////////////////////////////////////////////////////////////////
  233. // EA_XBDM_ENABLED
  234. //
  235. // Defined as 0 or 1, with 1 being the default for debug builds.
  236. // This controls whether xbdm library usage is enabled on XBox 360. This library
  237. // allows for runtime debug functionality. But shipping applications are not
  238. // allowed to use xbdm.
  239. //
  240. #if !defined(EA_XBDM_ENABLED)
  241. #if defined(EA_DEBUG)
  242. #define EA_XBDM_ENABLED 1
  243. #else
  244. #define EA_XBDM_ENABLED 0
  245. #endif
  246. #endif
  247. ///////////////////////////////////////////////////////////////////////////////
  248. // EATHREAD_DLL
  249. //
  250. // Defined as 0 or 1. The default is dependent on the definition of EA_DLL.
  251. // If EA_DLL is defined, then EATHREAD_DLL is 1, else EATHREAD_DLL is 0.
  252. // EA_DLL is a define that controls DLL builds within the EAConfig build system.
  253. // EATHREAD_DLL controls whether EATHREAD_VERSION is built and used as a DLL.
  254. // Normally you wouldn't do such a thing, but there are use cases for such
  255. // a thing, particularly in the case of embedding C++ into C# applications.
  256. //
  257. #ifndef EATHREAD_DLL
  258. #if defined(EA_DLL)
  259. #define EATHREAD_DLL 1
  260. #else
  261. #define EATHREAD_DLL 0
  262. #endif
  263. #endif
  264. ///////////////////////////////////////////////////////////////////////////////
  265. // EATHREADLIB_API
  266. //
  267. // This is used to label functions as DLL exports under Microsoft platforms.
  268. // If EA_DLL is defined, then the user is building EAThread as a DLL and EAThread's
  269. // non-templated functions will be exported. EAThread template functions are not
  270. // labelled as EATHREADLIB_API (and are thus not exported in a DLL build). This is
  271. // because it's not possible (or at least unsafe) to implement inline templated
  272. // functions in a DLL.
  273. //
  274. // Example usage of EATHREADLIB_API:
  275. // EATHREADLIB_API int someVariable = 10; // Export someVariable in a DLL build.
  276. //
  277. // struct EATHREADLIB_API SomeClass{ // Export SomeClass and its member functions in a DLL build.
  278. // EATHREADLIB_LOCAL void PrivateMethod(); // Not exported.
  279. // };
  280. //
  281. // EATHREADLIB_API void SomeFunction(); // Export SomeFunction in a DLL build.
  282. //
  283. // For GCC, see http://gcc.gnu.org/wiki/Visibility
  284. //
  285. #ifndef EATHREADLIB_API // If the build file hasn't already defined this to be dllexport...
  286. #if EATHREAD_DLL
  287. #if defined(_MSC_VER)
  288. #define EATHREADLIB_API __declspec(dllimport)
  289. #define EATHREADLIB_LOCAL
  290. #elif defined(__CYGWIN__)
  291. #define EATHREADLIB_API __attribute__((dllimport))
  292. #define EATHREADLIB_LOCAL
  293. #elif (defined(__GNUC__) && (__GNUC__ >= 4))
  294. #define EATHREADLIB_API __attribute__ ((visibility("default")))
  295. #define EATHREADLIB_LOCAL __attribute__ ((visibility("hidden")))
  296. #else
  297. #define EATHREADLIB_API
  298. #define EATHREADLIB_LOCAL
  299. #endif
  300. #else
  301. #define EATHREADLIB_API
  302. #define EATHREADLIB_LOCAL
  303. #endif
  304. #endif
  305. ///////////////////////////////////////////////////////////////////////////////
  306. // EATHREAD_ALLOC_PREFIX
  307. //
  308. // Defined as a string literal. Defaults to this package's name.
  309. // Can be overridden by the user by predefining it or by editing this file.
  310. // This define is used as the default name used by this package for naming
  311. // memory allocations and memory allocators.
  312. //
  313. // All allocations names follow the same naming pattern:
  314. // <package>/<module>[/<specific usage>]
  315. //
  316. // Example usage:
  317. // void* p = pCoreAllocator->Alloc(37, EATHREAD_ALLOC_PREFIX, 0);
  318. //
  319. // Example usage:
  320. // gMessageServer.GetMessageQueue().get_allocator().set_name(EATHREAD_ALLOC_PREFIX "MessageSystem/Queue");
  321. //
  322. #ifndef EATHREAD_ALLOC_PREFIX
  323. #define EATHREAD_ALLOC_PREFIX "EAThread/"
  324. #endif
  325. ///////////////////////////////////////////////////////////////////////////////
  326. // EATHREAD_USE_STANDARD_NEW
  327. //
  328. // Defines whether we use the basic standard operator new or the named
  329. // extended version of operator new, as per the EASTL package.
  330. //
  331. #ifndef EATHREAD_USE_STANDARD_NEW
  332. #if EATHREAD_DLL // A DLL must provide its own implementation of new, so we just use built-in new.
  333. #define EATHREAD_USE_STANDARD_NEW 1
  334. #else
  335. #define EATHREAD_USE_STANDARD_NEW 0
  336. #endif
  337. #endif
  338. ///////////////////////////////////////////////////////////////////////////////
  339. // EATHREAD_NEW
  340. //
  341. // This is merely a wrapper for operator new which can be overridden and
  342. // which has debug/release forms.
  343. //
  344. // Example usage:
  345. // SomeClass* pObject = EATHREAD_NEW("SomeClass") SomeClass(1, 2, 3);
  346. //
  347. #ifndef EATHREAD_NEW
  348. #if EATHREAD_USE_STANDARD_NEW
  349. #define EATHREAD_NEW(name) new
  350. #define EATHREAD_NEW_ALIGNED(alignment, offset, name) new
  351. #define EATHREAD_DELETE delete
  352. #else
  353. #if defined(EA_DEBUG)
  354. #define EATHREAD_NEW(name) new(name, 0, 0, __FILE__, __LINE__)
  355. #define EATHREAD_NEW_ALIGNED(alignment, offset, name) new(alignment, offset, name, 0, 0, __FILE__, __LINE__)
  356. #define EATHREAD_DELETE delete
  357. #else
  358. #define EATHREAD_NEW(name) new(name, 0, 0, 0, 0)
  359. #define EATHREAD_NEW_ALIGNED(alignment, offset, name) new(alignment, offset, name, 0, 0, 0, 0)
  360. #define EATHREAD_DELETE delete
  361. #endif
  362. #endif
  363. #endif
  364. ///////////////////////////////////////////////////////////////////////////////
  365. // EATHREAD_HAS_EMULATED_AND_NATIVE_ATOMICS
  366. //
  367. // This symbol is defined if a platform has both native and emulated atomics.
  368. // Currently the only platform that requires this is iOS as earlier versions
  369. // of the operating system (ie: iOS 3) do not provide OS support for 64-bit
  370. // atomics while later versions (ie: iOS 4/5) do.
  371. #ifndef EATHREAD_HAS_EMULATED_AND_NATIVE_ATOMICS
  372. #if defined(__APPLE__)
  373. #define EATHREAD_HAS_EMULATED_AND_NATIVE_ATOMICS 1
  374. #else
  375. #define EATHREAD_HAS_EMULATED_AND_NATIVE_ATOMICS 0
  376. #endif
  377. #endif
  378. ///////////////////////////////////////////////////////////////////////////////
  379. // EATHREAD_GLIBC_BACKTRACE_AVAILABLE
  380. //
  381. // You generally need to be using GCC, GLIBC, and Linux for backtrace to be available.
  382. // And even then it's available only some of the time.
  383. //
  384. #if !defined(EATHREAD_GLIBC_BACKTRACE_AVAILABLE)
  385. #if (defined(__clang__) || defined(__GNUC__)) && (defined(EA_PLATFORM_LINUX) || defined(__APPLE__)) && !defined(__CYGWIN__) && !defined(EA_PLATFORM_ANDROID)
  386. #define EATHREAD_GLIBC_BACKTRACE_AVAILABLE 1
  387. #else
  388. #define EATHREAD_GLIBC_BACKTRACE_AVAILABLE 0
  389. #endif
  390. #endif
  391. ///////////////////////////////////////////////////////////////////////////////
  392. // EATHREAD_GLIBC_VERSION
  393. //
  394. // We provide our own GLIBC numeric version to determine when system library
  395. // calls are available.
  396. //
  397. #if defined(__GLIBC__)
  398. #define EATHREAD_GLIBC_VERSION ((__GLIBC__ * 1000) + __GLIBC_MINOR__)
  399. #endif
  400. ///////////////////////////////////////////////////////////////////////////////
  401. // EATHREAD_GETCALLSTACK_SUPPORTED
  402. //
  403. // Defined as 0 or 1.
  404. // Identifies whether runtime callstack unwinding (i.e. GetCallstack()) is
  405. // supported for the given platform. In some cases it may be that unwinding
  406. // support code is present but it hasn't been tested for reliability and may
  407. // have bugs preventing it from working properly. In some cases (e.g. x86)
  408. // it may be that optimized builds make it difficult to read the callstack
  409. // reliably, despite that we flag the platform as supported.
  410. //
  411. #if !defined(EATHREAD_GETCALLSTACK_SUPPORTED)
  412. #if EATHREAD_GLIBC_BACKTRACE_AVAILABLE // Typically this means Linux on x86.
  413. #define EATHREAD_GETCALLSTACK_SUPPORTED 1
  414. #elif defined(EA_PLATFORM_IPHONE)
  415. #define EATHREAD_GETCALLSTACK_SUPPORTED 1
  416. #elif defined(EA_PLATFORM_ANDROID)
  417. #define EATHREAD_GETCALLSTACK_SUPPORTED 1
  418. #elif defined(EA_PLATFORM_IPHONE_SIMULATOR)
  419. #define EATHREAD_GETCALLSTACK_SUPPORTED 1
  420. #elif defined(EA_PLATFORM_WINDOWS_PHONE) && defined(EA_PROCESSOR_ARM)
  421. #define EATHREAD_GETCALLSTACK_SUPPORTED 0
  422. #elif defined(EA_PLATFORM_MICROSOFT)
  423. #define EATHREAD_GETCALLSTACK_SUPPORTED 1
  424. #elif defined(EA_PLATFORM_LINUX)
  425. #define EATHREAD_GETCALLSTACK_SUPPORTED 1
  426. #elif defined(EA_PLATFORM_OSX)
  427. #define EATHREAD_GETCALLSTACK_SUPPORTED 1
  428. #elif defined(EA_PLATFORM_SONY)
  429. #define EATHREAD_GETCALLSTACK_SUPPORTED 1
  430. #elif defined(EA_PLATFORM_CYGWIN) // Support hasn't been verified.
  431. #define EATHREAD_GETCALLSTACK_SUPPORTED 0
  432. #elif defined(EA_PLATFORM_MINGW) // Support hasn't been verified.
  433. #define EATHREAD_GETCALLSTACK_SUPPORTED 0
  434. #endif
  435. #endif
  436. ///////////////////////////////////////////////////////////////////////////////
  437. // EATHREAD_DEBUG_DETAIL_ENABLED
  438. //
  439. // Defined as 0 or 1.
  440. // If true then detailed debug info is displayed. Can be enabled in opt builds.
  441. //
  442. #ifndef EATHREAD_DEBUG_DETAIL_ENABLED
  443. #define EATHREAD_DEBUG_DETAIL_ENABLED 0
  444. #endif
  445. ///////////////////////////////////////////////////////////////////////////////
  446. // EATHREAD_MIN_ABSOLUTE_TIME
  447. //
  448. // Defined as a time in milliseconds.
  449. // Locks and waits allow the user to specify an absolute timeout time. In order
  450. // to detect that the user accidentally specified a relative time, we define a
  451. // minimum allowed absolute time which we assert on. This minimum time is one
  452. // that in practice is impossible to be a future absolute time.
  453. //
  454. #ifndef EATHREAD_MIN_ABSOLUTE_TIME
  455. #define EATHREAD_MIN_ABSOLUTE_TIME 10000
  456. #endif
  457. ///////////////////////////////////////////////////////////////////////////////
  458. // EATHREAD_THREAD_AFFINITY_MASK_SUPPORTED
  459. //
  460. // Defined as 0 or 1.
  461. // If true then the platform supports a user specified thread affinity mask.
  462. //
  463. #ifndef EATHREAD_THREAD_AFFINITY_MASK_SUPPORTED
  464. #if defined(EA_PLATFORM_CAPILANO)
  465. #define EATHREAD_THREAD_AFFINITY_MASK_SUPPORTED 1
  466. #elif defined(EA_PLATFORM_SONY)
  467. #define EATHREAD_THREAD_AFFINITY_MASK_SUPPORTED 1
  468. #elif defined(EA_USE_CPP11_CONCURRENCY) && EA_USE_CPP11_CONCURRENCY
  469. // CPP11 doesn't not provided a mechanism to set thread affinities.
  470. #define EATHREAD_THREAD_AFFINITY_MASK_SUPPORTED 0
  471. #elif defined(EA_PLATFORM_ANDROID) || defined(EA_PLATFORM_APPLE) || defined(EA_PLATFORM_UNIX)
  472. #define EATHREAD_THREAD_AFFINITY_MASK_SUPPORTED 0
  473. #else
  474. #define EATHREAD_THREAD_AFFINITY_MASK_SUPPORTED 1
  475. #endif
  476. #endif
  477. ///////////////////////////////////////////////////////////////////////////////
  478. // EATHREAD_GLOBAL_VARIABLE_DLL_SAFETY
  479. //
  480. // Defined as 0 or 1.
  481. //
  482. //
  483. #ifndef EATHREAD_GLOBAL_VARIABLE_DLL_SAFETY
  484. #define EATHREAD_GLOBAL_VARIABLE_DLL_SAFETY 0
  485. #endif
  486. ///////////////////////////////////////////////////////////////////////////////
  487. // EATHREAD_SCEDBG_ENABLED
  488. //
  489. // Defined as 0 or 1.
  490. // Informs EAThread if Sony Debug libraries are available for us.
  491. //
  492. #ifndef EATHREAD_SCEDBG_ENABLED
  493. #ifndef EA_SCEDBG_ENABLED
  494. #define EATHREAD_SCEDBG_ENABLED 0
  495. #else
  496. #define EATHREAD_SCEDBG_ENABLED EA_SCEDBG_ENABLED
  497. #endif
  498. #endif
  499. ///////////////////////////////////////////////////////////////////////////////
  500. // EATHREAD_DEBUG_BREAK
  501. //
  502. #ifndef EATHREAD_DEBUG_BREAK
  503. #ifdef __MSC_VER
  504. #define EATHREAD_DEBUG_BREAK() __debugbreak()
  505. #else
  506. #define EATHREAD_DEBUG_BREAK() *(volatile int*)(0) = 0
  507. #endif
  508. #endif
  509. ///////////////////////////////////////////////////////////////////////////////
  510. // EATHREAD_C11_ATOMICS_AVAILABLE
  511. //
  512. #ifndef EATHREAD_C11_ATOMICS_AVAILABLE
  513. #if (defined(EA_ANDROID_SDK_LEVEL) && (EA_ANDROID_SDK_LEVEL >= 21))
  514. #define EATHREAD_C11_ATOMICS_AVAILABLE 1
  515. #else
  516. #define EATHREAD_C11_ATOMICS_AVAILABLE 0
  517. #endif
  518. #endif
  519. ///////////////////////////////////////////////////////////////////////////////
  520. // EATHREAD_ALIGNMENT_CHECK
  521. //
  522. namespace EA {
  523. namespace Thread {
  524. namespace detail {
  525. // Used to assert that memory accesses on x86-64 are atomic when "naturally" aligned to the size of registers.
  526. template <typename T>
  527. inline bool IsNaturallyAligned(T* p)
  528. {
  529. return ((uintptr_t)p & (sizeof(EA_PLATFORM_WORD_SIZE) - 1)) == 0;
  530. }
  531. }}}
  532. #ifndef EATHREAD_ALIGNMENT_CHECK
  533. #define EATHREAD_ALIGNMENT_CHECK(address) EAT_ASSERT_MSG(EA::Thread::detail::IsNaturallyAligned(address), "address is not naturally aligned.")
  534. #endif
  535. ///////////////////////////////////////////////////////////////////////////////
  536. // EATHREAD_APPLE_GETMODULEINFO_ENABLED
  537. //
  538. // This functionality has been migrated to EACallstack. We provide a preprocessor switch for backwards compatibility
  539. // until the code path is removed completely in a future release.
  540. //
  541. // Defined as 0 or 1.
  542. //
  543. #ifndef EATHREAD_APPLE_GETMODULEINFO_ENABLED
  544. #define EATHREAD_APPLE_GETMODULEINFO_ENABLED 0
  545. #endif
  546. #endif // Header include guard