eathread_sync_apple.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Copyright (c) Electronic Arts Inc. All rights reserved.
  3. ///////////////////////////////////////////////////////////////////////////////
  4. #if defined(EA_PRAGMA_ONCE_SUPPORTED)
  5. #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.
  6. #endif
  7. /////////////////////////////////////////////////////////////////////////////
  8. // Functionality related to memory and code generation synchronization.
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef EATHREAD_APPLE_EATHREAD_SYNC_APPLE_H
  11. #define EATHREAD_APPLE_EATHREAD_SYNC_APPLE_H
  12. #include <EABase/eabase.h>
  13. #include <libkern/OSAtomic.h>
  14. #define EA_THREAD_SYNC_IMPLEMENTED
  15. // EAProcessorPause
  16. // Intel has defined a 'pause' instruction for x86 processors starting with the P4, though this simply
  17. // maps to the otherwise undocumented 'rep nop' instruction. This pause instruction is important for
  18. // high performance spinning, as otherwise a high performance penalty incurs.
  19. #if defined(EA_PROCESSOR_X86) || defined(EA_PROCESSOR_X86_64)
  20. #define EAProcessorPause() __asm__ __volatile__ ("rep ; nop")
  21. #else
  22. #define EAProcessorPause()
  23. #endif
  24. // EAReadBarrier / EAWriteBarrier / EAReadWriteBarrier
  25. #define EAReadBarrier OSMemoryBarrier
  26. #define EAWriteBarrier OSMemoryBarrier
  27. #define EAReadWriteBarrier OSMemoryBarrier
  28. // EACompilerMemoryBarrier
  29. #define EACompilerMemoryBarrier() __asm__ __volatile__ ("":::"memory")
  30. #endif // EATHREAD_APPLE_EATHREAD_SYNC_APPLE_H