aboutsummaryrefslogtreecommitdiff
path: root/tcc.h
diff options
context:
space:
mode:
authorgrischka <grischka>2017-07-23 21:24:11 +0200
committergrischka <grischka>2017-07-23 21:24:11 +0200
commit4b3c6e74aba07d61e91b2e0ba7190483a0f9f000 (patch)
tree8e91e83762d9c60dd81182b9d423f8addb3532f2 /tcc.h
parentfdc18d307aafce6e8833b0eb26c1313da88cfc9a (diff)
downloadtinycc-4b3c6e74aba07d61e91b2e0ba7190483a0f9f000.tar.gz
tinycc-4b3c6e74aba07d61e91b2e0ba7190483a0f9f000.tar.bz2
tccgen: nodata_wanted fix, default ONE_SOURCE, etc...
tccgen.c: doubles need to be aligned, on ARM. The section_reserve() in init_putv does not do that. -D ONE_SOURCE: is now the default and not longer needed. Also, tcc.h now sets the default native target. These both make compiling tcc simple as "gcc tcc.c -o tcc -ldl" again. arm-asm.c: enable pseudo asm also for inline asm tests/tests2/Makefile: disable bitfield tests except on windows and x86_64 and don't generate-always tcc.c: fix a loop with -dt on errors configure: print compiler version (as recognized) tccpp.c: actually define symbols for tcc -dt clear static variables (needed for -dt or libtcc usage) 96_nodata_wanted.c: use __label__ instead of asm lib/files: use native symbols (__i386__ etc.) instead of TCC_TARGET_...
Diffstat (limited to 'tcc.h')
-rw-r--r--tcc.h59
1 files changed, 36 insertions, 23 deletions
diff --git a/tcc.h b/tcc.h
index 05371bd..bfe6ab4 100644
--- a/tcc.h
+++ b/tcc.h
@@ -81,6 +81,14 @@ extern long double strtold (const char *__nptr, char **__endptr);
# define O_BINARY 0
#endif
+#ifndef offsetof
+#define offsetof(type, field) ((size_t) &((type *)0)->field)
+#endif
+
+#ifndef countof
+#define countof(tab) (sizeof(tab) / sizeof((tab)[0]))
+#endif
+
#ifdef _MSC_VER
# define NORETURN __declspec(noreturn)
# define ALIGNED(x) __declspec(align(x))
@@ -99,12 +107,6 @@ extern long double strtold (const char *__nptr, char **__endptr);
# define PATHCMP strcmp
#endif
-#ifdef TCC_TARGET_PE
-#define PATHSEP ';'
-#else
-#define PATHSEP ':'
-#endif
-
/* -------------------------------------------- */
/* parser debug */
@@ -129,12 +131,20 @@ extern long double strtold (const char *__nptr, char **__endptr);
#if !defined(TCC_TARGET_I386) && !defined(TCC_TARGET_ARM) && \
!defined(TCC_TARGET_ARM64) && !defined(TCC_TARGET_C67) && \
!defined(TCC_TARGET_X86_64)
-#define TCC_TARGET_I386
-#endif
-
-/* object format selection */
-#if defined(TCC_TARGET_C67)
-#define TCC_TARGET_COFF
+# if defined __x86_64__ || defined _AMD64_
+# define TCC_TARGET_X86_64
+# elif defined __arm__
+# define TCC_TARGET_ARM
+# define TCC_ARM_EABI
+# define TCC_ARM_HARDFLOAT
+# elif defined __aarch64__
+# define TCC_TARGET_ARM64
+# else
+# define TCC_TARGET_I386
+# endif
+# ifdef _WIN32
+# define TCC_TARGET_PE 1
+# endif
#endif
/* only native compiler supports -run */
@@ -164,7 +174,7 @@ extern long double strtold (const char *__nptr, char **__endptr);
# define CONFIG_SYSROOT ""
#endif
#ifndef CONFIG_TCCDIR
-# define CONFIG_TCCDIR "."
+# define CONFIG_TCCDIR "/usr/local/lib/tcc"
#endif
#ifndef CONFIG_LDDIR
# define CONFIG_LDDIR "lib"
@@ -266,6 +276,12 @@ extern long double strtold (const char *__nptr, char **__endptr);
#define TCC_LIBGCC USE_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) "/libgcc_s.so.1"
#endif
+#ifdef TCC_TARGET_PE
+#define PATHSEP ';'
+#else
+#define PATHSEP ':'
+#endif
+
/* -------------------------------------------- */
#include "libtcc.h"
@@ -278,7 +294,11 @@ extern long double strtold (const char *__nptr, char **__endptr);
# define PUB_FUNC
#endif
-#ifdef ONE_SOURCE
+#ifndef ONE_SOURCE
+# define ONE_SOURCE 1
+#endif
+
+#if ONE_SOURCE
#define ST_INLN static inline
#define ST_FUNC static
#define ST_DATA static
@@ -314,6 +334,7 @@ extern long double strtold (const char *__nptr, char **__endptr);
# include "arm64-link.c"
#endif
#ifdef TCC_TARGET_C67
+# define TCC_TARGET_COFF
# include "coff.h"
# include "c67-gen.c"
# include "c67-link.c"
@@ -965,14 +986,6 @@ struct filespec {
#define TOK_A_SHL 0x81
#define TOK_A_SAR 0x82
-#ifndef offsetof
-#define offsetof(type, field) ((size_t) &((type *)0)->field)
-#endif
-
-#ifndef countof
-#define countof(tab) (sizeof(tab) / sizeof((tab)[0]))
-#endif
-
#define TOK_EOF (-1) /* end of file */
#define TOK_LINEFEED 10 /* line feed */
@@ -1641,7 +1654,7 @@ ST_FUNC void gen_makedeps(TCCState *s, const char *target, const char *filename)
/********************************************************/
#undef ST_DATA
-#ifdef ONE_SOURCE
+#if ONE_SOURCE
#define ST_DATA static
#else
#define ST_DATA