9eae11a56a7b4c1b88cb615402fcdd4583c9803d
[tinycc.git] / conftest.c
blob9eae11a56a7b4c1b88cb615402fcdd4583c9803d
1 #include <stdio.h>
3 /* Define architecture */
4 #if defined(__i386__)
5 # define TRIPLET_ARCH "i386"
6 #elif defined(__x86_64__)
7 # define TRIPLET_ARCH "x86_64"
8 #elif defined(__arm__)
9 # define TRIPLET_ARCH "arm"
10 #else
11 # define TRIPLET_ARCH "unknown"
12 #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 (__GNU__)
20 # define TRIPLET_OS "unknown"
21 #endif
23 /* Define calling convention and ABI */
24 #define TRIPLET_ABI "gnu"
26 #ifdef __GNU__
27 # define TRIPLET TRIPLET_ARCH "-" TRIPLET_ABI
28 #else
29 # define TRIPLET TRIPLET_ARCH "-" TRIPLET_OS "-" TRIPLET_ABI
30 #endif
32 int main(int argc, char *argv[])
34 switch(argc == 2 ? argv[1][0] : 0) {
35 case 'b':
37 volatile unsigned foo = 0x01234567;
38 puts(*(unsigned char*)&foo == 0x67 ? "no" : "yes");
39 break;
41 #ifdef __GNUC__
42 case 'm':
43 printf("%d\n", __GNUC_MINOR__);
44 break;
45 case 'v':
46 printf("%d\n", __GNUC__);
47 break;
48 #else
49 case 'm':
50 case 'v':
51 puts("0");
52 break;
53 #endif
54 case 't':
55 puts(TRIPLET);
56 break;
57 case -1:
58 /* to test -Wno-unused-result */
59 fread(NULL, 1, 1, NULL);
60 break;
62 return 0;