conftest.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #include <stdio.h>
  2. /* Define architecture */
  3. #if defined(__i386__) || defined _M_IX86
  4. # define TRIPLET_ARCH "i386"
  5. #elif defined(__x86_64__) || defined _M_AMD64
  6. # define TRIPLET_ARCH "x86_64"
  7. #elif defined(__arm__)
  8. # define TRIPLET_ARCH "arm"
  9. #elif defined(__aarch64__)
  10. # define TRIPLET_ARCH "aarch64"
  11. #else
  12. # define TRIPLET_ARCH "unknown"
  13. #endif
  14. /* Define OS */
  15. #if defined (__linux__)
  16. # define TRIPLET_OS "linux"
  17. #elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
  18. # define TRIPLET_OS "kfreebsd"
  19. #elif defined _WIN32
  20. # define TRIPLET_OS "win32"
  21. #elif !defined (__GNU__)
  22. # define TRIPLET_OS "unknown"
  23. #endif
  24. /* Define calling convention and ABI */
  25. #if defined (__ARM_EABI__)
  26. # if defined (__ARM_PCS_VFP)
  27. # define TRIPLET_ABI "gnueabihf"
  28. # else
  29. # define TRIPLET_ABI "gnueabi"
  30. # endif
  31. #else
  32. # define TRIPLET_ABI "gnu"
  33. #endif
  34. #if defined _WIN32
  35. # define TRIPLET TRIPLET_ARCH "-" TRIPLET_OS
  36. #elif defined __GNU__
  37. # define TRIPLET TRIPLET_ARCH "-" TRIPLET_ABI
  38. #else
  39. # define TRIPLET TRIPLET_ARCH "-" TRIPLET_OS "-" TRIPLET_ABI
  40. #endif
  41. #if defined(_WIN32)
  42. int _CRT_glob = 0;
  43. #endif
  44. int main(int argc, char *argv[])
  45. {
  46. switch(argc == 2 ? argv[1][0] : 0) {
  47. case 'b':
  48. {
  49. volatile unsigned foo = 0x01234567;
  50. puts(*(unsigned char*)&foo == 0x67 ? "no" : "yes");
  51. break;
  52. }
  53. #ifdef __GNUC__
  54. case 'm':
  55. printf("%d\n", __GNUC_MINOR__);
  56. break;
  57. case 'v':
  58. printf("%d\n", __GNUC__);
  59. break;
  60. #elif defined __TINYC__
  61. case 'v':
  62. puts("0");
  63. break;
  64. case 'm':
  65. printf("%d\n", __TINYC__);
  66. break;
  67. #else
  68. case 'm':
  69. case 'v':
  70. puts("0");
  71. break;
  72. #endif
  73. case 't':
  74. puts(TRIPLET);
  75. break;
  76. default:
  77. break;
  78. }
  79. return 0;
  80. }