diff options
| author | gus knight <waddlesplash@gmail.com> | 2015-07-27 16:03:25 -0400 |
|---|---|---|
| committer | Augustin Cavalier <waddlesplash@gmail.com> | 2015-07-27 16:03:25 -0400 |
| commit | 47e06c6d4e542e47fcbad69a78c2436a854a0779 (patch) | |
| tree | d979fb8f3372966c0ef3031c4edeaa8f017241d9 /src/conftest.c | |
| parent | 694d0fdade8bff3bc03466675350f596b2f4f8ed (diff) | |
| download | tinycc-47e06c6d4e542e47fcbad69a78c2436a854a0779.tar.gz tinycc-47e06c6d4e542e47fcbad69a78c2436a854a0779.tar.bz2 | |
Reorganize the source tree.
* Documentation is now in "docs".
* Source code is now in "src".
* Misc. fixes here and there so that everything still works.
I think I got everything in this commit, but I only tested this
on Linux (Make) and Windows (CMake), so I might've messed
something up on other platforms...
Diffstat (limited to 'src/conftest.c')
| -rw-r--r-- | src/conftest.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/conftest.c b/src/conftest.c new file mode 100644 index 0000000..fa07a1b --- /dev/null +++ b/src/conftest.c @@ -0,0 +1,77 @@ +#include <stdio.h> + +/* 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" +#elif defined(__aarch64__) +# define TRIPLET_ARCH "aarch64" +#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 */ +#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 + +#ifdef __GNU__ +# define TRIPLET TRIPLET_ARCH "-" TRIPLET_ABI +#else +# define TRIPLET TRIPLET_ARCH "-" TRIPLET_OS "-" TRIPLET_ABI +#endif + +#if defined(_WIN32) +int _CRT_glob = 0; +#endif + +int main(int argc, char *argv[]) +{ + switch(argc == 2 ? argv[1][0] : 0) { + case 'b': + { + volatile unsigned foo = 0x01234567; + puts(*(unsigned char*)&foo == 0x67 ? "no" : "yes"); + break; + } +#ifdef __GNUC__ + case 'm': + printf("%d\n", __GNUC_MINOR__); + break; + case 'v': + printf("%d\n", __GNUC__); + break; +#else + case 'm': + case 'v': + puts("0"); + break; +#endif + case 't': + puts(TRIPLET); + break; + case -1: + /* to test -Wno-unused-result */ + fread(NULL, 1, 1, NULL); + break; + } + return 0; +} |
