config.h 21 KB

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