2013-02-14 09:53:07 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2019-06-25 15:43:24 +03:00
|
|
|
#if defined(_WIN32)
|
|
|
|
#include <fcntl.h>
|
|
|
|
#endif
|
|
|
|
|
2013-02-14 18:39:35 +04:00
|
|
|
/* Define architecture */
|
2017-02-18 11:55:34 +03:00
|
|
|
#if defined(__i386__) || defined _M_IX86
|
2013-02-14 18:39:35 +04:00
|
|
|
# define TRIPLET_ARCH "i386"
|
2017-02-18 11:55:34 +03:00
|
|
|
#elif defined(__x86_64__) || defined _M_AMD64
|
2013-02-14 18:39:35 +04:00
|
|
|
# define TRIPLET_ARCH "x86_64"
|
|
|
|
#elif defined(__arm__)
|
|
|
|
# define TRIPLET_ARCH "arm"
|
2015-02-13 21:58:31 +03:00
|
|
|
#elif defined(__aarch64__)
|
|
|
|
# define TRIPLET_ARCH "aarch64"
|
2019-06-22 07:13:10 +03:00
|
|
|
#elif defined(__riscv) && defined(__LP64__)
|
|
|
|
# define TRIPLET_ARCH "riscv64"
|
2013-02-14 18:39:35 +04:00
|
|
|
#else
|
|
|
|
# define TRIPLET_ARCH "unknown"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Define OS */
|
|
|
|
#if defined (__linux__)
|
|
|
|
# define TRIPLET_OS "linux"
|
|
|
|
#elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
|
|
|
|
# define TRIPLET_OS "kfreebsd"
|
2020-06-21 11:58:36 +03:00
|
|
|
#elif defined(_WIN32)
|
2017-02-18 11:55:34 +03:00
|
|
|
# define TRIPLET_OS "win32"
|
2020-06-21 11:58:36 +03:00
|
|
|
#elif defined(__APPLE__)
|
|
|
|
# define TRIPLET_OS "darwin"
|
2013-02-14 18:39:35 +04:00
|
|
|
#elif !defined (__GNU__)
|
|
|
|
# define TRIPLET_OS "unknown"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Define calling convention and ABI */
|
2013-02-14 19:40:16 +04:00
|
|
|
#if defined (__ARM_EABI__)
|
|
|
|
# if defined (__ARM_PCS_VFP)
|
|
|
|
# define TRIPLET_ABI "gnueabihf"
|
|
|
|
# else
|
|
|
|
# define TRIPLET_ABI "gnueabi"
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# define TRIPLET_ABI "gnu"
|
|
|
|
#endif
|
2013-02-14 18:39:35 +04:00
|
|
|
|
2017-02-18 11:55:34 +03:00
|
|
|
#if defined _WIN32
|
|
|
|
# define TRIPLET TRIPLET_ARCH "-" TRIPLET_OS
|
|
|
|
#elif defined __GNU__
|
2013-02-14 18:39:35 +04:00
|
|
|
# define TRIPLET TRIPLET_ARCH "-" TRIPLET_ABI
|
|
|
|
#else
|
|
|
|
# define TRIPLET TRIPLET_ARCH "-" TRIPLET_OS "-" TRIPLET_ABI
|
|
|
|
#endif
|
|
|
|
|
2014-02-09 02:38:41 +04:00
|
|
|
#if defined(_WIN32)
|
|
|
|
int _CRT_glob = 0;
|
|
|
|
#endif
|
|
|
|
|
2013-02-14 09:53:07 +04:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2019-06-25 15:43:24 +03:00
|
|
|
#if defined(_WIN32)
|
|
|
|
_setmode(_fileno(stdout), _O_BINARY); /* don't translate \n to \r\n */
|
|
|
|
#endif
|
2013-02-14 09:53:07 +04:00
|
|
|
switch(argc == 2 ? argv[1][0] : 0) {
|
2013-02-14 18:39:35 +04:00
|
|
|
case 'b':
|
|
|
|
{
|
|
|
|
volatile unsigned foo = 0x01234567;
|
|
|
|
puts(*(unsigned char*)&foo == 0x67 ? "no" : "yes");
|
2013-02-14 09:53:07 +04:00
|
|
|
break;
|
2013-02-14 18:39:35 +04:00
|
|
|
}
|
2020-06-21 11:58:36 +03:00
|
|
|
#if defined(__clang__)
|
2020-06-21 10:53:52 +03:00
|
|
|
case 'm':
|
|
|
|
printf("%d\n", __clang_minor__);
|
|
|
|
break;
|
|
|
|
case 'v':
|
|
|
|
printf("%d\n", __clang_major__);
|
|
|
|
break;
|
2020-06-21 11:58:36 +03:00
|
|
|
#elif defined(__TINYC__)
|
2017-02-18 11:55:34 +03:00
|
|
|
case 'v':
|
|
|
|
puts("0");
|
|
|
|
break;
|
|
|
|
case 'm':
|
|
|
|
printf("%d\n", __TINYC__);
|
|
|
|
break;
|
2020-06-21 11:58:36 +03:00
|
|
|
#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
|
|
|
|
/* GNU comes last as other compilers may add 'GNU' compatibility */
|
2020-06-21 11:52:04 +03:00
|
|
|
case 'm':
|
|
|
|
printf("%d\n", __GNUC_MINOR__);
|
|
|
|
break;
|
|
|
|
case 'v':
|
|
|
|
printf("%d\n", __GNUC__);
|
|
|
|
break;
|
2013-02-14 18:39:35 +04:00
|
|
|
#else
|
2013-02-14 09:53:07 +04:00
|
|
|
case 'm':
|
2013-02-14 18:39:35 +04:00
|
|
|
case 'v':
|
2013-02-14 09:53:07 +04:00
|
|
|
puts("0");
|
|
|
|
break;
|
|
|
|
#endif
|
2013-02-14 18:39:35 +04:00
|
|
|
case 't':
|
|
|
|
puts(TRIPLET);
|
2013-02-14 09:53:07 +04:00
|
|
|
break;
|
2020-06-22 11:12:18 +03:00
|
|
|
case 'c':
|
|
|
|
#if defined(__clang__)
|
|
|
|
puts("clang");
|
|
|
|
#elif defined(__TINYC__)
|
|
|
|
puts("tcc");
|
|
|
|
#elif defiend(__GNUC__)
|
|
|
|
puts("gcc");
|
|
|
|
#else
|
|
|
|
puts("unknown");
|
|
|
|
#endif
|
|
|
|
break;
|
2017-02-18 11:55:34 +03:00
|
|
|
default:
|
2013-02-14 09:53:07 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|