2
0

BsPlatformDefines.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #pragma once
  2. // Initial platform/compiler-related stuff to set.
  3. #define BS_PLATFORM_WIN32 1
  4. #define BS_PLATFORM_LINUX 2
  5. #define BS_PLATFORM_APPLE 3
  6. #define BS_COMPILER_MSVC 1
  7. #define BS_COMPILER_GNUC 2
  8. #define BS_COMPILER_INTEL 3
  9. #define BS_COMPILER_CLANG 4
  10. #define BS_ARCHITECTURE_x86_32 1
  11. #define BS_ARCHITECTURE_x86_64 2
  12. #define BS_ENDIAN_LITTLE 1
  13. #define BS_ENDIAN_BIG 2
  14. #define BS_ENDIAN BS_ENDIAN_LITTLE
  15. #define BS_EDITOR_BUILD 1
  16. // Finds the compiler type and version.
  17. #if defined( _MSC_VER )
  18. # define BS_COMPILER BS_COMPILER_MSVC
  19. # define BS_COMP_VER _MSC_VER
  20. # define BS_THREADLOCAL __declspec(thread)
  21. #elif defined( __GNUC__ )
  22. # define BS_COMPILER BS_COMPILER_GNUC
  23. # define BS_COMP_VER (((__GNUC__)*100) + \
  24. (__GNUC_MINOR__*10) + \
  25. __GNUC_PATCHLEVEL__)
  26. # define BS_THREADLOCAL __thread
  27. #elif defined ( __INTEL_COMPILER )
  28. # define BS_COMPILER BS_COMPILER_INTEL
  29. # define BS_COMP_VER __INTEL_COMPILER
  30. // BS_THREADLOCAL define is down below because Intel compiler defines it differently based on platform
  31. #elif defined ( __clang__ )
  32. # define BS_COMPILER BS_COMPILER_CLANG
  33. # define BS_COMP_VER __clang_major__
  34. # define BS_THREADLOCAL __thread
  35. #else
  36. # pragma error "No known compiler. "
  37. #endif
  38. // See if we can use __forceinline or if we need to use __inline instead
  39. #if BS_COMPILER == BS_COMPILER_MSVC
  40. # if BS_COMP_VER >= 1200
  41. # define FORCEINLINE __forceinline
  42. # endif
  43. #elif defined(__MINGW32__)
  44. # if !defined(FORCEINLINE)
  45. # define FORCEINLINE __inline
  46. # endif
  47. #else
  48. # define FORCEINLINE __inline
  49. #endif
  50. // Finds the current platform
  51. #if defined( __WIN32__ ) || defined( _WIN32 )
  52. # define BS_PLATFORM BS_PLATFORM_WIN32
  53. #elif defined( __APPLE_CC__)
  54. # define BS_PLATFORM BS_PLATFORM_APPLE
  55. #else
  56. # define BS_PLATFORM BS_PLATFORM_LINUX
  57. #endif
  58. // Find the architecture type
  59. #if defined(__x86_64__) || defined(_M_X64)
  60. # define BS_ARCH_TYPE BS_ARCHITECTURE_x86_64
  61. #else
  62. # define BS_ARCH_TYPE BS_ARCHITECTURE_x86_32
  63. #endif
  64. // Windows Settings
  65. #if BS_PLATFORM == BS_PLATFORM_WIN32
  66. // If we're not including this from a client build, specify that the stuff
  67. // should get exported. Otherwise, import it.
  68. # if defined( BS_STATIC_LIB )
  69. // Linux compilers don't have symbol import/export directives.
  70. # define BS_UTILITY_EXPORT
  71. # else
  72. # if defined(BS_UTILITY_EXPORTS)
  73. # define BS_UTILITY_EXPORT __declspec( dllexport )
  74. # else
  75. # if defined( __MINGW32__ )
  76. # define BS_UTILITY_EXPORT
  77. # else
  78. # define BS_UTILITY_EXPORT __declspec( dllimport )
  79. # endif
  80. # endif
  81. # endif
  82. // Win32 compilers use _DEBUG for specifying debug builds.
  83. // for MinGW, we set DEBUG
  84. # if defined(_DEBUG) || defined(DEBUG)
  85. # define BS_DEBUG_MODE 1
  86. # else
  87. # define BS_DEBUG_MODE 0
  88. # endif
  89. # if BS_COMPILER == BS_COMPILER_INTEL
  90. # define BS_THREADLOCAL __declspec(thread)
  91. # endif
  92. #endif // BS_PLATFORM == BS_PLATFORM_WIN32
  93. // Linux/Apple Settings
  94. #if BS_PLATFORM == BS_PLATFORM_LINUX || BS_PLATFORM == BS_PLATFORM_APPLE
  95. // Enable GCC symbol visibility
  96. # if defined( BS_GCC_VISIBILITY )
  97. # define BS_UTILITY_EXPORT __attribute__ ((visibility("default")))
  98. # else
  99. # define BS_UTILITY_EXPORT
  100. # endif
  101. # ifdef DEBUG
  102. # define BS_DEBUG_MODE 1
  103. # else
  104. # define BS_DEBUG_MODE 0
  105. # endif
  106. # if BS_COMPILER == BS_COMPILER_INTEL
  107. # define BS_THREADLOCAL __thread
  108. # endif
  109. #endif