CMakePlatformId.h.in 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. #define STRINGIFY_HELPER(X) #X
  2. #define STRINGIFY(X) STRINGIFY_HELPER(X)
  3. /* Identify known platforms by name. */
  4. #if defined(__linux) || defined(__linux__) || defined(linux)
  5. # define PLATFORM_ID "Linux"
  6. #elif defined(__CYGWIN__)
  7. # define PLATFORM_ID "Cygwin"
  8. #elif defined(__MINGW32__)
  9. # define PLATFORM_ID "MinGW"
  10. #elif defined(__APPLE__)
  11. # define PLATFORM_ID "Darwin"
  12. #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
  13. # define PLATFORM_ID "Windows"
  14. #elif defined(__FreeBSD__) || defined(__FreeBSD)
  15. # define PLATFORM_ID "FreeBSD"
  16. #elif defined(__NetBSD__) || defined(__NetBSD)
  17. # define PLATFORM_ID "NetBSD"
  18. #elif defined(__OpenBSD__) || defined(__OPENBSD)
  19. # define PLATFORM_ID "OpenBSD"
  20. #elif defined(__sun) || defined(sun)
  21. # define PLATFORM_ID "SunOS"
  22. #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
  23. # define PLATFORM_ID "AIX"
  24. #elif defined(__hpux) || defined(__hpux__)
  25. # define PLATFORM_ID "HP-UX"
  26. #elif defined(__HAIKU__)
  27. # define PLATFORM_ID "Haiku"
  28. #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
  29. # define PLATFORM_ID "BeOS"
  30. #elif defined(__QNX__) || defined(__QNXNTO__)
  31. # define PLATFORM_ID "QNX"
  32. #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
  33. # define PLATFORM_ID "Tru64"
  34. #elif defined(__riscos) || defined(__riscos__)
  35. # define PLATFORM_ID "RISCos"
  36. #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
  37. # define PLATFORM_ID "SINIX"
  38. #elif defined(__UNIX_SV__)
  39. # define PLATFORM_ID "UNIX_SV"
  40. #elif defined(__bsdos__)
  41. # define PLATFORM_ID "BSDOS"
  42. #elif defined(_MPRAS) || defined(MPRAS)
  43. # define PLATFORM_ID "MP-RAS"
  44. #elif defined(__osf) || defined(__osf__)
  45. # define PLATFORM_ID "OSF1"
  46. #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
  47. # define PLATFORM_ID "SCO_SV"
  48. #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
  49. # define PLATFORM_ID "ULTRIX"
  50. #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
  51. # define PLATFORM_ID "Xenix"
  52. #elif defined(__WATCOMC__)
  53. # if defined(__LINUX__)
  54. # define PLATFORM_ID "Linux"
  55. # elif defined(__DOS__)
  56. # define PLATFORM_ID "DOS"
  57. # elif defined(__OS2__)
  58. # define PLATFORM_ID "OS2"
  59. # elif defined(__WINDOWS__)
  60. # define PLATFORM_ID "Windows3x"
  61. # else /* unknown platform */
  62. # define PLATFORM_ID
  63. # endif
  64. #elif defined(__INTEGRITY)
  65. # if defined(INT_178B)
  66. # define PLATFORM_ID "Integrity178"
  67. # else /* regular Integrity */
  68. # define PLATFORM_ID "Integrity"
  69. # endif
  70. #else /* unknown platform */
  71. # define PLATFORM_ID
  72. #endif
  73. /* For windows compilers MSVC and Intel we can determine
  74. the architecture of the compiler being used. This is because
  75. the compilers do not have flags that can change the architecture,
  76. but rather depend on which compiler is being used
  77. */
  78. #if defined(_WIN32) && defined(_MSC_VER)
  79. # if defined(_M_IA64)
  80. # define ARCHITECTURE_ID "IA64"
  81. # elif defined(_M_X64) || defined(_M_AMD64)
  82. # define ARCHITECTURE_ID "x64"
  83. # elif defined(_M_IX86)
  84. # define ARCHITECTURE_ID "X86"
  85. # elif defined(_M_ARM64)
  86. # define ARCHITECTURE_ID "ARM64"
  87. # elif defined(_M_ARM)
  88. # if _M_ARM == 4
  89. # define ARCHITECTURE_ID "ARMV4I"
  90. # elif _M_ARM == 5
  91. # define ARCHITECTURE_ID "ARMV5I"
  92. # else
  93. # define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
  94. # endif
  95. # elif defined(_M_MIPS)
  96. # define ARCHITECTURE_ID "MIPS"
  97. # elif defined(_M_SH)
  98. # define ARCHITECTURE_ID "SHx"
  99. # else /* unknown architecture */
  100. # define ARCHITECTURE_ID ""
  101. # endif
  102. #elif defined(__WATCOMC__)
  103. # if defined(_M_I86)
  104. # define ARCHITECTURE_ID "I86"
  105. # elif defined(_M_IX86)
  106. # define ARCHITECTURE_ID "X86"
  107. # else /* unknown architecture */
  108. # define ARCHITECTURE_ID ""
  109. # endif
  110. #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
  111. # if defined(__ICCARM__)
  112. # define ARCHITECTURE_ID "ARM"
  113. # elif defined(__ICCRX__)
  114. # define ARCHITECTURE_ID "RX"
  115. # elif defined(__ICCRH850__)
  116. # define ARCHITECTURE_ID "RH850"
  117. # elif defined(__ICCRL78__)
  118. # define ARCHITECTURE_ID "RL78"
  119. # elif defined(__ICCRISCV__)
  120. # define ARCHITECTURE_ID "RISCV"
  121. # elif defined(__ICCAVR__)
  122. # define ARCHITECTURE_ID "AVR"
  123. # elif defined(__ICC430__)
  124. # define ARCHITECTURE_ID "MSP430"
  125. # elif defined(__ICCV850__)
  126. # define ARCHITECTURE_ID "V850"
  127. # elif defined(__ICC8051__)
  128. # define ARCHITECTURE_ID "8051"
  129. # else /* unknown architecture */
  130. # define ARCHITECTURE_ID ""
  131. # endif
  132. #elif defined(__ghs__)
  133. # if defined(__PPC64__)
  134. # define ARCHITECTURE_ID "PPC64"
  135. # elif defined(__ppc__)
  136. # define ARCHITECTURE_ID "PPC"
  137. # elif defined(__ARM__)
  138. # define ARCHITECTURE_ID "ARM"
  139. # elif defined(__x86_64__)
  140. # define ARCHITECTURE_ID "x64"
  141. # elif defined(__i386__)
  142. # define ARCHITECTURE_ID "X86"
  143. # else /* unknown architecture */
  144. # define ARCHITECTURE_ID ""
  145. # endif
  146. #else
  147. # define ARCHITECTURE_ID
  148. #endif
  149. /* Convert integer to decimal digit literals. */
  150. #define DEC(n) \
  151. ('0' + (((n) / 10000000)%10)), \
  152. ('0' + (((n) / 1000000)%10)), \
  153. ('0' + (((n) / 100000)%10)), \
  154. ('0' + (((n) / 10000)%10)), \
  155. ('0' + (((n) / 1000)%10)), \
  156. ('0' + (((n) / 100)%10)), \
  157. ('0' + (((n) / 10)%10)), \
  158. ('0' + ((n) % 10))
  159. /* Convert integer to hex digit literals. */
  160. #define HEX(n) \
  161. ('0' + ((n)>>28 & 0xF)), \
  162. ('0' + ((n)>>24 & 0xF)), \
  163. ('0' + ((n)>>20 & 0xF)), \
  164. ('0' + ((n)>>16 & 0xF)), \
  165. ('0' + ((n)>>12 & 0xF)), \
  166. ('0' + ((n)>>8 & 0xF)), \
  167. ('0' + ((n)>>4 & 0xF)), \
  168. ('0' + ((n) & 0xF))
  169. /* Construct a string literal encoding the version number components. */
  170. #ifdef COMPILER_VERSION_MAJOR
  171. char const info_version[] = {
  172. 'I', 'N', 'F', 'O', ':',
  173. 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
  174. COMPILER_VERSION_MAJOR,
  175. # ifdef COMPILER_VERSION_MINOR
  176. '.', COMPILER_VERSION_MINOR,
  177. # ifdef COMPILER_VERSION_PATCH
  178. '.', COMPILER_VERSION_PATCH,
  179. # ifdef COMPILER_VERSION_TWEAK
  180. '.', COMPILER_VERSION_TWEAK,
  181. # endif
  182. # endif
  183. # endif
  184. ']','\0'};
  185. #endif
  186. /* Construct a string literal encoding the internal version number. */
  187. #ifdef COMPILER_VERSION_INTERNAL
  188. char const info_version_internal[] = {
  189. 'I', 'N', 'F', 'O', ':',
  190. 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
  191. 'i','n','t','e','r','n','a','l','[',
  192. COMPILER_VERSION_INTERNAL,']','\0'};
  193. #endif
  194. /* Construct a string literal encoding the version number components. */
  195. #ifdef SIMULATE_VERSION_MAJOR
  196. char const info_simulate_version[] = {
  197. 'I', 'N', 'F', 'O', ':',
  198. 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
  199. SIMULATE_VERSION_MAJOR,
  200. # ifdef SIMULATE_VERSION_MINOR
  201. '.', SIMULATE_VERSION_MINOR,
  202. # ifdef SIMULATE_VERSION_PATCH
  203. '.', SIMULATE_VERSION_PATCH,
  204. # ifdef SIMULATE_VERSION_TWEAK
  205. '.', SIMULATE_VERSION_TWEAK,
  206. # endif
  207. # endif
  208. # endif
  209. ']','\0'};
  210. #endif
  211. /* Construct the string literal in pieces to prevent the source from
  212. getting matched. Store it in a pointer rather than an array
  213. because some compilers will just produce instructions to fill the
  214. array rather than assigning a pointer to a static array. */
  215. char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
  216. char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";