tinycc/conftest.c

72 lines
1.5 KiB
C
Raw Normal View History

#include <stdio.h>
2013-02-14 18:39:35 +04:00
/* Define architecture */
#if defined(__i386__)
# define TRIPLET_ARCH "i386"
#elif defined(__x86_64__)
# define TRIPLET_ARCH "x86_64"
#elif defined(__arm__)
# define TRIPLET_ARCH "arm"
#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"
#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
#ifdef __GNU__
# define TRIPLET TRIPLET_ARCH "-" TRIPLET_ABI
#else
# define TRIPLET TRIPLET_ARCH "-" TRIPLET_OS "-" TRIPLET_ABI
#endif
int main(int argc, char *argv[])
{
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");
break;
2013-02-14 18:39:35 +04:00
}
#ifdef __GNUC__
case 'm':
printf("%d\n", __GNUC_MINOR__);
break;
case 'v':
2013-02-14 18:39:35 +04:00
printf("%d\n", __GNUC__);
break;
#else
case 'm':
2013-02-14 18:39:35 +04:00
case 'v':
puts("0");
break;
#endif
2013-02-14 18:39:35 +04:00
case 't':
puts(TRIPLET);
break;
case -1:
/* to test -Wno-unused-result */
fread(NULL, 1, 1, NULL);
break;
}
return 0;
}