BsPlatformDefines.h 3.7 KB

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