platform.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * Copyright (c) 2012-2014 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/taylor001/crown/blob/master/LICENSE
  4. */
  5. // Adapted from Branimir Karadžić's platform.h (https://github.com/bkaradzic/bx)
  6. #pragma once
  7. #define CROWN_VERSION_MAJOR "0"
  8. #define CROWN_VERSION_MINOR "1"
  9. #define CROWN_VERSION_MICRO "13"
  10. #define CROWN_COMPILER_CLANG 0
  11. #define CROWN_COMPILER_GCC 0
  12. #define CROWN_COMPILER_MSVC 0
  13. #define CROWN_PLATFORM_ANDROID 0
  14. #define CROWN_PLATFORM_IOS 0
  15. #define CROWN_PLATFORM_LINUX 0
  16. #define CROWN_PLATFORM_OSX 0
  17. #define CROWN_PLATFORM_WINDOWS 0
  18. #define CROWN_CPU_ARM 0
  19. #define CROWN_CPU_JIT 0
  20. #define CROWN_CPU_MIPS 0
  21. #define CROWN_CPU_PPC 0
  22. #define CROWN_CPU_X86 0
  23. #define CROWN_ARCH_32BIT 0
  24. #define CROWN_ARCH_64BIT 0
  25. #define CROWN_CPU_ENDIAN_BIG 0
  26. #define CROWN_CPU_ENDIAN_LITTLE 0
  27. // http://sourceforge.net/apps/mediawiki/predef/index.php?title=Compilers
  28. #if defined(_MSC_VER)
  29. #undef CROWN_COMPILER_MSVC
  30. #define CROWN_COMPILER_MSVC 1
  31. #elif defined(__clang__)
  32. // clang defines __GNUC__
  33. #undef CROWN_COMPILER_CLANG
  34. #define CROWN_COMPILER_CLANG 1
  35. #elif defined(__GNUC__)
  36. #undef CROWN_COMPILER_GCC
  37. #define CROWN_COMPILER_GCC 1
  38. #else
  39. #error "CROWN_COMPILER_* is not defined!"
  40. #endif
  41. // http://sourceforge.net/apps/mediawiki/predef/index.php?title=Operating_Systems
  42. #if defined(_WIN32) || defined(_WIN64)
  43. #undef CROWN_PLATFORM_WINDOWS
  44. // http://msdn.microsoft.com/en-us/library/6sehtctf.aspx
  45. #if !defined(WINVER) && !defined(_WIN32_WINNT)
  46. // Windows Server 2003 with SP1, Windows XP with SP2 and above
  47. #define WINVER 0x0502
  48. #define _WIN32_WINNT 0x0502
  49. #endif // !defined(WINVER) && !defined(_WIN32_WINNT)
  50. #define CROWN_PLATFORM_WINDOWS 1
  51. #elif defined(__ANDROID__)
  52. // Android compiler defines __linux__
  53. #undef CROWN_PLATFORM_ANDROID
  54. #define CROWN_PLATFORM_ANDROID 1
  55. #elif defined(__linux__)
  56. #undef CROWN_PLATFORM_LINUX
  57. #define CROWN_PLATFORM_LINUX 1
  58. #elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
  59. #undef CROWN_PLATFORM_IOS
  60. #define CROWN_PLATFORM_IOS 1
  61. #elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
  62. #undef CROWN_PLATFORM_OSX
  63. #define CROWN_PLATFORM_OSX 1
  64. #else
  65. # error "CROWN_PLATFORM_* is not defined!"
  66. #endif
  67. #define CROWN_PLATFORM_POSIX (CROWN_PLATFORM_ANDROID \
  68. || CROWN_PLATFORM_IOS \
  69. || CROWN_PLATFORM_LINUX \
  70. || CROWN_PLATFORM_OSX)
  71. // http://sourceforge.net/apps/mediawiki/predef/index.php?title=Architectures
  72. #if defined(__arm__)
  73. #undef CROWN_CPU_ARM
  74. #define CROWN_CPU_ARM 1
  75. #define CROWN_CACHE_LINE_SIZE 64
  76. #elif defined(__MIPSEL__) || defined(__mips_isa_rev) // defined(mips)
  77. #undef CROWN_CPU_MIPS
  78. #define CROWN_CPU_MIPS 1
  79. #define CROWN_CACHE_LINE_SIZE 64
  80. #elif defined(_M_PPC) || defined(__powerpc__) || defined(__powerpc64__)
  81. #undef CROWN_CPU_PPC
  82. #define CROWN_CPU_PPC 1
  83. #define CROWN_CACHE_LINE_SIZE 128
  84. #elif defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__x86_64__)
  85. #undef CROWN_CPU_X86
  86. #define CROWN_CPU_X86 1
  87. #define CROWN_CACHE_LINE_SIZE 64
  88. #else // PNaCl doesn't have CPU defined.
  89. #undef CROWN_CPU_JIT
  90. #define CROWN_CPU_JIT 1
  91. #define CROWN_CACHE_LINE_SIZE 64
  92. #endif //
  93. #if defined(__x86_64__) || defined(_M_X64) || defined(__64BIT__) || defined(__powerpc64__) || defined(__ppc64__)
  94. #undef CROWN_ARCH_64BIT
  95. #define CROWN_ARCH_64BIT 64
  96. #else
  97. #undef CROWN_ARCH_32BIT
  98. #define CROWN_ARCH_32BIT 32
  99. #endif //
  100. #if CROWN_CPU_PPC
  101. #undef CROWN_CPU_ENDIAN_BIG
  102. #define CROWN_CPU_ENDIAN_BIG 1
  103. #else
  104. #undef CROWN_CPU_ENDIAN_LITTLE
  105. #define CROWN_CPU_ENDIAN_LITTLE 1
  106. #endif
  107. #if CROWN_COMPILER_GCC
  108. #define CROWN_COMPILER_NAME "GCC"
  109. #elif CROWN_COMPILER_MSVC
  110. #define CROWN_COMPILER_NAME "MSVC"
  111. #endif
  112. #if CROWN_PLATFORM_ANDROID
  113. #define CROWN_PLATFORM_NAME "Android"
  114. #elif CROWN_PLATFORM_IOS
  115. #define CROWN_PLATFORM_NAME "iOS"
  116. #elif CROWN_PLATFORM_LINUX
  117. #define CROWN_PLATFORM_NAME "Linux"
  118. #elif CROWN_PLATFORM_OSX
  119. #define CROWN_PLATFORM_NAME "OSX"
  120. #elif CROWN_PLATFORM_WINDOWS
  121. #define CROWN_PLATFORM_NAME "Windows"
  122. #endif // CROWN_PLATFORM_
  123. #if CROWN_CPU_ARM
  124. #define CROWN_CPU_NAME "ARM"
  125. #elif CROWN_CPU_MIPS
  126. #define CROWN_CPU_NAME "MIPS"
  127. #elif CROWN_CPU_PPC
  128. #define CROWN_CPU_NAME "PowerPC"
  129. #elif CROWN_CPU_JIT
  130. #define CROWN_CPU_NAME "JIT-VM"
  131. #elif CROWN_CPU_X86
  132. #define CROWN_CPU_NAME "x86"
  133. #endif // CROWN_CPU_
  134. #if CROWN_ARCH_32BIT
  135. #define CROWN_ARCH_NAME "32-bit"
  136. #elif CROWN_ARCH_64BIT
  137. #define CROWN_ARCH_NAME "64-bit"
  138. #endif // CROWN_ARCH_