BsPlatformDefines.h 3.7 KB

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