CMakeCCompilerId.c 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880
  1. #ifdef __cplusplus
  2. # error "A C++ compiler has been selected for C."
  3. #endif
  4. #if defined(__18CXX)
  5. # define ID_VOID_MAIN
  6. #endif
  7. #if defined(__CLASSIC_C__)
  8. /* cv-qualifiers did not exist in K&R C */
  9. # define const
  10. # define volatile
  11. #endif
  12. #if !defined(__has_include)
  13. /* If the compiler does not have __has_include, pretend the answer is
  14. always no. */
  15. # define __has_include(x) 0
  16. #endif
  17. /* Version number components: V=Version, R=Revision, P=Patch
  18. Version date components: YYYY=Year, MM=Month, DD=Day */
  19. #if defined(__INTEL_COMPILER) || defined(__ICC)
  20. # define COMPILER_ID "Intel"
  21. # if defined(_MSC_VER)
  22. # define SIMULATE_ID "MSVC"
  23. # endif
  24. # if defined(__GNUC__)
  25. # define SIMULATE_ID "GNU"
  26. # endif
  27. /* __INTEL_COMPILER = VRP prior to 2021, and then VVVV for 2021 and later,
  28. except that a few beta releases use the old format with V=2021. */
  29. # if __INTEL_COMPILER < 2021 || __INTEL_COMPILER == 202110 || __INTEL_COMPILER == 202111
  30. # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
  31. # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
  32. # if defined(__INTEL_COMPILER_UPDATE)
  33. # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
  34. # else
  35. # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
  36. # endif
  37. # else
  38. # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER)
  39. # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER_UPDATE)
  40. /* The third version component from --version is an update index,
  41. but no macro is provided for it. */
  42. # define COMPILER_VERSION_PATCH DEC(0)
  43. # endif
  44. # if defined(__INTEL_COMPILER_BUILD_DATE)
  45. /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
  46. # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
  47. # endif
  48. # if defined(_MSC_VER)
  49. /* _MSC_VER = VVRR */
  50. # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
  51. # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
  52. # endif
  53. # if defined(__GNUC__)
  54. # define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
  55. # elif defined(__GNUG__)
  56. # define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
  57. # endif
  58. # if defined(__GNUC_MINOR__)
  59. # define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
  60. # endif
  61. # if defined(__GNUC_PATCHLEVEL__)
  62. # define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
  63. # endif
  64. #elif (defined(__clang__) && defined(__INTEL_CLANG_COMPILER)) || defined(__INTEL_LLVM_COMPILER)
  65. # define COMPILER_ID "IntelLLVM"
  66. #if defined(_MSC_VER)
  67. # define SIMULATE_ID "MSVC"
  68. #endif
  69. #if defined(__GNUC__)
  70. # define SIMULATE_ID "GNU"
  71. #endif
  72. /* __INTEL_LLVM_COMPILER = VVVVRP prior to 2021.2.0, VVVVRRPP for 2021.2.0 and
  73. * later. Look for 6 digit vs. 8 digit version number to decide encoding.
  74. * VVVV is no smaller than the current year when a version is released.
  75. */
  76. #if __INTEL_LLVM_COMPILER < 1000000L
  77. # define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/100)
  78. # define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/10 % 10)
  79. # define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 10)
  80. #else
  81. # define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/10000)
  82. # define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/100 % 100)
  83. # define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 100)
  84. #endif
  85. #if defined(_MSC_VER)
  86. /* _MSC_VER = VVRR */
  87. # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
  88. # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
  89. #endif
  90. #if defined(__GNUC__)
  91. # define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
  92. #elif defined(__GNUG__)
  93. # define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
  94. #endif
  95. #if defined(__GNUC_MINOR__)
  96. # define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
  97. #endif
  98. #if defined(__GNUC_PATCHLEVEL__)
  99. # define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
  100. #endif
  101. #elif defined(__PATHCC__)
  102. # define COMPILER_ID "PathScale"
  103. # define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
  104. # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
  105. # if defined(__PATHCC_PATCHLEVEL__)
  106. # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
  107. # endif
  108. #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
  109. # define COMPILER_ID "Embarcadero"
  110. # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
  111. # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
  112. # define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF)
  113. #elif defined(__BORLANDC__)
  114. # define COMPILER_ID "Borland"
  115. /* __BORLANDC__ = 0xVRR */
  116. # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
  117. # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
  118. #elif defined(__WATCOMC__) && __WATCOMC__ < 1200
  119. # define COMPILER_ID "Watcom"
  120. /* __WATCOMC__ = VVRR */
  121. # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
  122. # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
  123. # if (__WATCOMC__ % 10) > 0
  124. # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
  125. # endif
  126. #elif defined(__WATCOMC__)
  127. # define COMPILER_ID "OpenWatcom"
  128. /* __WATCOMC__ = VVRP + 1100 */
  129. # define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
  130. # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
  131. # if (__WATCOMC__ % 10) > 0
  132. # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
  133. # endif
  134. #elif defined(__SUNPRO_C)
  135. # define COMPILER_ID "SunPro"
  136. # if __SUNPRO_C >= 0x5100
  137. /* __SUNPRO_C = 0xVRRP */
  138. # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12)
  139. # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF)
  140. # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
  141. # else
  142. /* __SUNPRO_CC = 0xVRP */
  143. # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8)
  144. # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF)
  145. # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
  146. # endif
  147. #elif defined(__HP_cc)
  148. # define COMPILER_ID "HP"
  149. /* __HP_cc = VVRRPP */
  150. # define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000)
  151. # define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100)
  152. # define COMPILER_VERSION_PATCH DEC(__HP_cc % 100)
  153. #elif defined(__DECC)
  154. # define COMPILER_ID "Compaq"
  155. /* __DECC_VER = VVRRTPPPP */
  156. # define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000)
  157. # define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100)
  158. # define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000)
  159. #elif defined(__IBMC__) && defined(__COMPILER_VER__)
  160. # define COMPILER_ID "zOS"
  161. /* __IBMC__ = VRP */
  162. # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
  163. # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
  164. # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
  165. #elif defined(__open_xl__) && defined(__clang__)
  166. # define COMPILER_ID "IBMClang"
  167. # define COMPILER_VERSION_MAJOR DEC(__open_xl_version__)
  168. # define COMPILER_VERSION_MINOR DEC(__open_xl_release__)
  169. # define COMPILER_VERSION_PATCH DEC(__open_xl_modification__)
  170. # define COMPILER_VERSION_TWEAK DEC(__open_xl_ptf_fix_level__)
  171. #elif defined(__ibmxl__) && defined(__clang__)
  172. # define COMPILER_ID "XLClang"
  173. # define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
  174. # define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
  175. # define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
  176. # define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
  177. #elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800
  178. # define COMPILER_ID "XL"
  179. /* __IBMC__ = VRP */
  180. # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
  181. # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
  182. # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
  183. #elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800
  184. # define COMPILER_ID "VisualAge"
  185. /* __IBMC__ = VRP */
  186. # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
  187. # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
  188. # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
  189. #elif defined(__NVCOMPILER)
  190. # define COMPILER_ID "NVHPC"
  191. # define COMPILER_VERSION_MAJOR DEC(__NVCOMPILER_MAJOR__)
  192. # define COMPILER_VERSION_MINOR DEC(__NVCOMPILER_MINOR__)
  193. # if defined(__NVCOMPILER_PATCHLEVEL__)
  194. # define COMPILER_VERSION_PATCH DEC(__NVCOMPILER_PATCHLEVEL__)
  195. # endif
  196. #elif defined(__PGI)
  197. # define COMPILER_ID "PGI"
  198. # define COMPILER_VERSION_MAJOR DEC(__PGIC__)
  199. # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
  200. # if defined(__PGIC_PATCHLEVEL__)
  201. # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
  202. # endif
  203. #elif defined(__clang__) && defined(__cray__)
  204. # define COMPILER_ID "CrayClang"
  205. # define COMPILER_VERSION_MAJOR DEC(__cray_major__)
  206. # define COMPILER_VERSION_MINOR DEC(__cray_minor__)
  207. # define COMPILER_VERSION_PATCH DEC(__cray_patchlevel__)
  208. # define COMPILER_VERSION_INTERNAL_STR __clang_version__
  209. #elif defined(_CRAYC)
  210. # define COMPILER_ID "Cray"
  211. # define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR)
  212. # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
  213. #elif defined(__TI_COMPILER_VERSION__)
  214. # define COMPILER_ID "TI"
  215. /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
  216. # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
  217. # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
  218. # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
  219. #elif defined(__CLANG_FUJITSU)
  220. # define COMPILER_ID "FujitsuClang"
  221. # define COMPILER_VERSION_MAJOR DEC(__FCC_major__)
  222. # define COMPILER_VERSION_MINOR DEC(__FCC_minor__)
  223. # define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__)
  224. # define COMPILER_VERSION_INTERNAL_STR __clang_version__
  225. #elif defined(__FUJITSU)
  226. # define COMPILER_ID "Fujitsu"
  227. # if defined(__FCC_version__)
  228. # define COMPILER_VERSION __FCC_version__
  229. # elif defined(__FCC_major__)
  230. # define COMPILER_VERSION_MAJOR DEC(__FCC_major__)
  231. # define COMPILER_VERSION_MINOR DEC(__FCC_minor__)
  232. # define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__)
  233. # endif
  234. # if defined(__fcc_version)
  235. # define COMPILER_VERSION_INTERNAL DEC(__fcc_version)
  236. # elif defined(__FCC_VERSION)
  237. # define COMPILER_VERSION_INTERNAL DEC(__FCC_VERSION)
  238. # endif
  239. #elif defined(__ghs__)
  240. # define COMPILER_ID "GHS"
  241. /* __GHS_VERSION_NUMBER = VVVVRP */
  242. # ifdef __GHS_VERSION_NUMBER
  243. # define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100)
  244. # define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10)
  245. # define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10)
  246. # endif
  247. #elif defined(__TASKING__)
  248. # define COMPILER_ID "Tasking"
  249. # define COMPILER_VERSION_MAJOR DEC(__VERSION__/1000)
  250. # define COMPILER_VERSION_MINOR DEC(__VERSION__ % 100)
  251. # define COMPILER_VERSION_INTERNAL DEC(__VERSION__)
  252. #elif defined(__ORANGEC__)
  253. # define COMPILER_ID "OrangeC"
  254. # define COMPILER_VERSION_MAJOR DEC(__ORANGEC_MAJOR__)
  255. # define COMPILER_VERSION_MINOR DEC(__ORANGEC_MINOR__)
  256. # define COMPILER_VERSION_PATCH DEC(__ORANGEC_PATCHLEVEL__)
  257. #elif defined(__TINYC__)
  258. # define COMPILER_ID "TinyCC"
  259. #elif defined(__BCC__)
  260. # define COMPILER_ID "Bruce"
  261. #elif defined(__SCO_VERSION__)
  262. # define COMPILER_ID "SCO"
  263. #elif defined(__ARMCC_VERSION) && !defined(__clang__)
  264. # define COMPILER_ID "ARMCC"
  265. #if __ARMCC_VERSION >= 1000000
  266. /* __ARMCC_VERSION = VRRPPPP */
  267. # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000)
  268. # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100)
  269. # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
  270. #else
  271. /* __ARMCC_VERSION = VRPPPP */
  272. # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000)
  273. # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10)
  274. # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
  275. #endif
  276. #elif defined(__clang__) && defined(__apple_build_version__)
  277. # define COMPILER_ID "AppleClang"
  278. # if defined(_MSC_VER)
  279. # define SIMULATE_ID "MSVC"
  280. # endif
  281. # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
  282. # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
  283. # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
  284. # if defined(_MSC_VER)
  285. /* _MSC_VER = VVRR */
  286. # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
  287. # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
  288. # endif
  289. # define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
  290. #elif defined(__clang__) && defined(__ARMCOMPILER_VERSION)
  291. # define COMPILER_ID "ARMClang"
  292. # define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000)
  293. # define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100)
  294. # define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION/100 % 100)
  295. # define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION)
  296. #elif defined(__clang__)
  297. # define COMPILER_ID "Clang"
  298. # if defined(_MSC_VER)
  299. # define SIMULATE_ID "MSVC"
  300. # endif
  301. # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
  302. # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
  303. # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
  304. # if defined(_MSC_VER)
  305. /* _MSC_VER = VVRR */
  306. # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
  307. # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
  308. # endif
  309. #elif defined(__LCC__) && (defined(__GNUC__) || defined(__GNUG__) || defined(__MCST__))
  310. # define COMPILER_ID "LCC"
  311. # define COMPILER_VERSION_MAJOR DEC(__LCC__ / 100)
  312. # define COMPILER_VERSION_MINOR DEC(__LCC__ % 100)
  313. # if defined(__LCC_MINOR__)
  314. # define COMPILER_VERSION_PATCH DEC(__LCC_MINOR__)
  315. # endif
  316. # if defined(__GNUC__) && defined(__GNUC_MINOR__)
  317. # define SIMULATE_ID "GNU"
  318. # define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
  319. # define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
  320. # if defined(__GNUC_PATCHLEVEL__)
  321. # define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
  322. # endif
  323. # endif
  324. #elif defined(__GNUC__)
  325. # define COMPILER_ID "GNU"
  326. # define COMPILER_VERSION_MAJOR DEC(__GNUC__)
  327. # if defined(__GNUC_MINOR__)
  328. # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
  329. # endif
  330. # if defined(__GNUC_PATCHLEVEL__)
  331. # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
  332. # endif
  333. #elif defined(_MSC_VER)
  334. # define COMPILER_ID "MSVC"
  335. /* _MSC_VER = VVRR */
  336. # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
  337. # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
  338. # if defined(_MSC_FULL_VER)
  339. # if _MSC_VER >= 1400
  340. /* _MSC_FULL_VER = VVRRPPPPP */
  341. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
  342. # else
  343. /* _MSC_FULL_VER = VVRRPPPP */
  344. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
  345. # endif
  346. # endif
  347. # if defined(_MSC_BUILD)
  348. # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
  349. # endif
  350. #elif defined(_ADI_COMPILER)
  351. # define COMPILER_ID "ADSP"
  352. #if defined(__VERSIONNUM__)
  353. /* __VERSIONNUM__ = 0xVVRRPPTT */
  354. # define COMPILER_VERSION_MAJOR DEC(__VERSIONNUM__ >> 24 & 0xFF)
  355. # define COMPILER_VERSION_MINOR DEC(__VERSIONNUM__ >> 16 & 0xFF)
  356. # define COMPILER_VERSION_PATCH DEC(__VERSIONNUM__ >> 8 & 0xFF)
  357. # define COMPILER_VERSION_TWEAK DEC(__VERSIONNUM__ & 0xFF)
  358. #endif
  359. #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
  360. # define COMPILER_ID "IAR"
  361. # if defined(__VER__) && defined(__ICCARM__)
  362. # define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000)
  363. # define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000)
  364. # define COMPILER_VERSION_PATCH DEC((__VER__) % 1000)
  365. # define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
  366. # elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__) || defined(__ICCSTM8__))
  367. # define COMPILER_VERSION_MAJOR DEC((__VER__) / 100)
  368. # define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100))
  369. # define COMPILER_VERSION_PATCH DEC(__SUBVERSION__)
  370. # define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
  371. # endif
  372. #elif defined(__SDCC_VERSION_MAJOR) || defined(SDCC)
  373. # define COMPILER_ID "SDCC"
  374. # if defined(__SDCC_VERSION_MAJOR)
  375. # define COMPILER_VERSION_MAJOR DEC(__SDCC_VERSION_MAJOR)
  376. # define COMPILER_VERSION_MINOR DEC(__SDCC_VERSION_MINOR)
  377. # define COMPILER_VERSION_PATCH DEC(__SDCC_VERSION_PATCH)
  378. # else
  379. /* SDCC = VRP */
  380. # define COMPILER_VERSION_MAJOR DEC(SDCC/100)
  381. # define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10)
  382. # define COMPILER_VERSION_PATCH DEC(SDCC % 10)
  383. # endif
  384. /* These compilers are either not known or too old to define an
  385. identification macro. Try to identify the platform and guess that
  386. it is the native compiler. */
  387. #elif defined(__hpux) || defined(__hpua)
  388. # define COMPILER_ID "HP"
  389. #else /* unknown compiler */
  390. # define COMPILER_ID ""
  391. #endif
  392. /* Construct the string literal in pieces to prevent the source from
  393. getting matched. Store it in a pointer rather than an array
  394. because some compilers will just produce instructions to fill the
  395. array rather than assigning a pointer to a static array. */
  396. char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
  397. #ifdef SIMULATE_ID
  398. char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
  399. #endif
  400. #ifdef __QNXNTO__
  401. char const* qnxnto = "INFO" ":" "qnxnto[]";
  402. #endif
  403. #if defined(__CRAYXT_COMPUTE_LINUX_TARGET)
  404. char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
  405. #endif
  406. #define STRINGIFY_HELPER(X) #X
  407. #define STRINGIFY(X) STRINGIFY_HELPER(X)
  408. /* Identify known platforms by name. */
  409. #if defined(__linux) || defined(__linux__) || defined(linux)
  410. # define PLATFORM_ID "Linux"
  411. #elif defined(__MSYS__)
  412. # define PLATFORM_ID "MSYS"
  413. #elif defined(__CYGWIN__)
  414. # define PLATFORM_ID "Cygwin"
  415. #elif defined(__MINGW32__)
  416. # define PLATFORM_ID "MinGW"
  417. #elif defined(__APPLE__)
  418. # define PLATFORM_ID "Darwin"
  419. #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
  420. # define PLATFORM_ID "Windows"
  421. #elif defined(__FreeBSD__) || defined(__FreeBSD)
  422. # define PLATFORM_ID "FreeBSD"
  423. #elif defined(__NetBSD__) || defined(__NetBSD)
  424. # define PLATFORM_ID "NetBSD"
  425. #elif defined(__OpenBSD__) || defined(__OPENBSD)
  426. # define PLATFORM_ID "OpenBSD"
  427. #elif defined(__sun) || defined(sun)
  428. # define PLATFORM_ID "SunOS"
  429. #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
  430. # define PLATFORM_ID "AIX"
  431. #elif defined(__hpux) || defined(__hpux__)
  432. # define PLATFORM_ID "HP-UX"
  433. #elif defined(__HAIKU__)
  434. # define PLATFORM_ID "Haiku"
  435. #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
  436. # define PLATFORM_ID "BeOS"
  437. #elif defined(__QNX__) || defined(__QNXNTO__)
  438. # define PLATFORM_ID "QNX"
  439. #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
  440. # define PLATFORM_ID "Tru64"
  441. #elif defined(__riscos) || defined(__riscos__)
  442. # define PLATFORM_ID "RISCos"
  443. #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
  444. # define PLATFORM_ID "SINIX"
  445. #elif defined(__UNIX_SV__)
  446. # define PLATFORM_ID "UNIX_SV"
  447. #elif defined(__bsdos__)
  448. # define PLATFORM_ID "BSDOS"
  449. #elif defined(_MPRAS) || defined(MPRAS)
  450. # define PLATFORM_ID "MP-RAS"
  451. #elif defined(__osf) || defined(__osf__)
  452. # define PLATFORM_ID "OSF1"
  453. #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
  454. # define PLATFORM_ID "SCO_SV"
  455. #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
  456. # define PLATFORM_ID "ULTRIX"
  457. #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
  458. # define PLATFORM_ID "Xenix"
  459. #elif defined(__WATCOMC__)
  460. # if defined(__LINUX__)
  461. # define PLATFORM_ID "Linux"
  462. # elif defined(__DOS__)
  463. # define PLATFORM_ID "DOS"
  464. # elif defined(__OS2__)
  465. # define PLATFORM_ID "OS2"
  466. # elif defined(__WINDOWS__)
  467. # define PLATFORM_ID "Windows3x"
  468. # elif defined(__VXWORKS__)
  469. # define PLATFORM_ID "VxWorks"
  470. # else /* unknown platform */
  471. # define PLATFORM_ID
  472. # endif
  473. #elif defined(__INTEGRITY)
  474. # if defined(INT_178B)
  475. # define PLATFORM_ID "Integrity178"
  476. # else /* regular Integrity */
  477. # define PLATFORM_ID "Integrity"
  478. # endif
  479. # elif defined(_ADI_COMPILER)
  480. # define PLATFORM_ID "ADSP"
  481. #else /* unknown platform */
  482. # define PLATFORM_ID
  483. #endif
  484. /* For windows compilers MSVC and Intel we can determine
  485. the architecture of the compiler being used. This is because
  486. the compilers do not have flags that can change the architecture,
  487. but rather depend on which compiler is being used
  488. */
  489. #if defined(_WIN32) && defined(_MSC_VER)
  490. # if defined(_M_IA64)
  491. # define ARCHITECTURE_ID "IA64"
  492. # elif defined(_M_ARM64EC)
  493. # define ARCHITECTURE_ID "ARM64EC"
  494. # elif defined(_M_X64) || defined(_M_AMD64)
  495. # define ARCHITECTURE_ID "x64"
  496. # elif defined(_M_IX86)
  497. # define ARCHITECTURE_ID "X86"
  498. # elif defined(_M_ARM64)
  499. # define ARCHITECTURE_ID "ARM64"
  500. # elif defined(_M_ARM)
  501. # if _M_ARM == 4
  502. # define ARCHITECTURE_ID "ARMV4I"
  503. # elif _M_ARM == 5
  504. # define ARCHITECTURE_ID "ARMV5I"
  505. # else
  506. # define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
  507. # endif
  508. # elif defined(_M_MIPS)
  509. # define ARCHITECTURE_ID "MIPS"
  510. # elif defined(_M_SH)
  511. # define ARCHITECTURE_ID "SHx"
  512. # else /* unknown architecture */
  513. # define ARCHITECTURE_ID ""
  514. # endif
  515. #elif defined(__WATCOMC__)
  516. # if defined(_M_I86)
  517. # define ARCHITECTURE_ID "I86"
  518. # elif defined(_M_IX86)
  519. # define ARCHITECTURE_ID "X86"
  520. # else /* unknown architecture */
  521. # define ARCHITECTURE_ID ""
  522. # endif
  523. #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
  524. # if defined(__ICCARM__)
  525. # define ARCHITECTURE_ID "ARM"
  526. # elif defined(__ICCRX__)
  527. # define ARCHITECTURE_ID "RX"
  528. # elif defined(__ICCRH850__)
  529. # define ARCHITECTURE_ID "RH850"
  530. # elif defined(__ICCRL78__)
  531. # define ARCHITECTURE_ID "RL78"
  532. # elif defined(__ICCRISCV__)
  533. # define ARCHITECTURE_ID "RISCV"
  534. # elif defined(__ICCAVR__)
  535. # define ARCHITECTURE_ID "AVR"
  536. # elif defined(__ICC430__)
  537. # define ARCHITECTURE_ID "MSP430"
  538. # elif defined(__ICCV850__)
  539. # define ARCHITECTURE_ID "V850"
  540. # elif defined(__ICC8051__)
  541. # define ARCHITECTURE_ID "8051"
  542. # elif defined(__ICCSTM8__)
  543. # define ARCHITECTURE_ID "STM8"
  544. # else /* unknown architecture */
  545. # define ARCHITECTURE_ID ""
  546. # endif
  547. #elif defined(__ghs__)
  548. # if defined(__PPC64__)
  549. # define ARCHITECTURE_ID "PPC64"
  550. # elif defined(__ppc__)
  551. # define ARCHITECTURE_ID "PPC"
  552. # elif defined(__ARM__)
  553. # define ARCHITECTURE_ID "ARM"
  554. # elif defined(__x86_64__)
  555. # define ARCHITECTURE_ID "x64"
  556. # elif defined(__i386__)
  557. # define ARCHITECTURE_ID "X86"
  558. # else /* unknown architecture */
  559. # define ARCHITECTURE_ID ""
  560. # endif
  561. #elif defined(__TI_COMPILER_VERSION__)
  562. # if defined(__TI_ARM__)
  563. # define ARCHITECTURE_ID "ARM"
  564. # elif defined(__MSP430__)
  565. # define ARCHITECTURE_ID "MSP430"
  566. # elif defined(__TMS320C28XX__)
  567. # define ARCHITECTURE_ID "TMS320C28x"
  568. # elif defined(__TMS320C6X__) || defined(_TMS320C6X)
  569. # define ARCHITECTURE_ID "TMS320C6x"
  570. # else /* unknown architecture */
  571. # define ARCHITECTURE_ID ""
  572. # endif
  573. # elif defined(__ADSPSHARC__)
  574. # define ARCHITECTURE_ID "SHARC"
  575. # elif defined(__ADSPBLACKFIN__)
  576. # define ARCHITECTURE_ID "Blackfin"
  577. #elif defined(__TASKING__)
  578. # if defined(__CTC__) || defined(__CPTC__)
  579. # define ARCHITECTURE_ID "TriCore"
  580. # elif defined(__CMCS__)
  581. # define ARCHITECTURE_ID "MCS"
  582. # elif defined(__CARM__)
  583. # define ARCHITECTURE_ID "ARM"
  584. # elif defined(__CARC__)
  585. # define ARCHITECTURE_ID "ARC"
  586. # elif defined(__C51__)
  587. # define ARCHITECTURE_ID "8051"
  588. # elif defined(__CPCP__)
  589. # define ARCHITECTURE_ID "PCP"
  590. # else
  591. # define ARCHITECTURE_ID ""
  592. # endif
  593. #else
  594. # define ARCHITECTURE_ID
  595. #endif
  596. /* Convert integer to decimal digit literals. */
  597. #define DEC(n) \
  598. ('0' + (((n) / 10000000)%10)), \
  599. ('0' + (((n) / 1000000)%10)), \
  600. ('0' + (((n) / 100000)%10)), \
  601. ('0' + (((n) / 10000)%10)), \
  602. ('0' + (((n) / 1000)%10)), \
  603. ('0' + (((n) / 100)%10)), \
  604. ('0' + (((n) / 10)%10)), \
  605. ('0' + ((n) % 10))
  606. /* Convert integer to hex digit literals. */
  607. #define HEX(n) \
  608. ('0' + ((n)>>28 & 0xF)), \
  609. ('0' + ((n)>>24 & 0xF)), \
  610. ('0' + ((n)>>20 & 0xF)), \
  611. ('0' + ((n)>>16 & 0xF)), \
  612. ('0' + ((n)>>12 & 0xF)), \
  613. ('0' + ((n)>>8 & 0xF)), \
  614. ('0' + ((n)>>4 & 0xF)), \
  615. ('0' + ((n) & 0xF))
  616. /* Construct a string literal encoding the version number. */
  617. #ifdef COMPILER_VERSION
  618. char const* info_version = "INFO" ":" "compiler_version[" COMPILER_VERSION "]";
  619. /* Construct a string literal encoding the version number components. */
  620. #elif defined(COMPILER_VERSION_MAJOR)
  621. char const info_version[] = {
  622. 'I', 'N', 'F', 'O', ':',
  623. 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
  624. COMPILER_VERSION_MAJOR,
  625. # ifdef COMPILER_VERSION_MINOR
  626. '.', COMPILER_VERSION_MINOR,
  627. # ifdef COMPILER_VERSION_PATCH
  628. '.', COMPILER_VERSION_PATCH,
  629. # ifdef COMPILER_VERSION_TWEAK
  630. '.', COMPILER_VERSION_TWEAK,
  631. # endif
  632. # endif
  633. # endif
  634. ']','\0'};
  635. #endif
  636. /* Construct a string literal encoding the internal version number. */
  637. #ifdef COMPILER_VERSION_INTERNAL
  638. char const info_version_internal[] = {
  639. 'I', 'N', 'F', 'O', ':',
  640. 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
  641. 'i','n','t','e','r','n','a','l','[',
  642. COMPILER_VERSION_INTERNAL,']','\0'};
  643. #elif defined(COMPILER_VERSION_INTERNAL_STR)
  644. char const* info_version_internal = "INFO" ":" "compiler_version_internal[" COMPILER_VERSION_INTERNAL_STR "]";
  645. #endif
  646. /* Construct a string literal encoding the version number components. */
  647. #ifdef SIMULATE_VERSION_MAJOR
  648. char const info_simulate_version[] = {
  649. 'I', 'N', 'F', 'O', ':',
  650. 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
  651. SIMULATE_VERSION_MAJOR,
  652. # ifdef SIMULATE_VERSION_MINOR
  653. '.', SIMULATE_VERSION_MINOR,
  654. # ifdef SIMULATE_VERSION_PATCH
  655. '.', SIMULATE_VERSION_PATCH,
  656. # ifdef SIMULATE_VERSION_TWEAK
  657. '.', SIMULATE_VERSION_TWEAK,
  658. # endif
  659. # endif
  660. # endif
  661. ']','\0'};
  662. #endif
  663. /* Construct the string literal in pieces to prevent the source from
  664. getting matched. Store it in a pointer rather than an array
  665. because some compilers will just produce instructions to fill the
  666. array rather than assigning a pointer to a static array. */
  667. char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
  668. char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
  669. #if !defined(__STDC__) && !defined(__clang__)
  670. # if defined(_MSC_VER) || defined(__ibmxl__) || defined(__IBMC__)
  671. # define C_VERSION "90"
  672. # else
  673. # define C_VERSION
  674. # endif
  675. #elif __STDC_VERSION__ > 201710L
  676. # define C_VERSION "23"
  677. #elif __STDC_VERSION__ >= 201710L
  678. # define C_VERSION "17"
  679. #elif __STDC_VERSION__ >= 201000L
  680. # define C_VERSION "11"
  681. #elif __STDC_VERSION__ >= 199901L
  682. # define C_VERSION "99"
  683. #else
  684. # define C_VERSION "90"
  685. #endif
  686. const char* info_language_standard_default =
  687. "INFO" ":" "standard_default[" C_VERSION "]";
  688. const char* info_language_extensions_default = "INFO" ":" "extensions_default["
  689. #if (defined(__clang__) || defined(__GNUC__) || defined(__xlC__) || \
  690. defined(__TI_COMPILER_VERSION__)) && \
  691. !defined(__STRICT_ANSI__)
  692. "ON"
  693. #else
  694. "OFF"
  695. #endif
  696. "]";
  697. /*--------------------------------------------------------------------------*/
  698. #ifdef ID_VOID_MAIN
  699. void main() {}
  700. #else
  701. # if defined(__CLASSIC_C__)
  702. int main(argc, argv) int argc; char *argv[];
  703. # else
  704. int main(int argc, char* argv[])
  705. # endif
  706. {
  707. int require = 0;
  708. require += info_compiler[argc];
  709. require += info_platform[argc];
  710. require += info_arch[argc];
  711. #ifdef COMPILER_VERSION_MAJOR
  712. require += info_version[argc];
  713. #endif
  714. #ifdef COMPILER_VERSION_INTERNAL
  715. require += info_version_internal[argc];
  716. #endif
  717. #ifdef SIMULATE_ID
  718. require += info_simulate[argc];
  719. #endif
  720. #ifdef SIMULATE_VERSION_MAJOR
  721. require += info_simulate_version[argc];
  722. #endif
  723. #if defined(__CRAYXT_COMPUTE_LINUX_TARGET)
  724. require += info_cray[argc];
  725. #endif
  726. require += info_language_standard_default[argc];
  727. require += info_language_extensions_default[argc];
  728. (void)argv;
  729. return require;
  730. }
  731. #endif