From f3c1ea6c2d7dca7883985820e46ec536e2d7e8cc Mon Sep 17 00:00:00 2001 From: grischka Date: Sat, 15 Oct 2016 16:01:16 +0200 Subject: [PATCH] #define __GNUC__ = 2.1 __GNUC__ nowadays as macro seems to mean the "GNU C dialect" rather than the compiler itself. See also http://gcc.gnu.org/ml/gcc/2008-07/msg00026.html This patch will probably cause problems of various kinds but maybe we should try nonetheless. --- libtcc.c | 25 +++++++++++++++++++------ tccgen.c | 4 ++++ tcctok.h | 4 ++++ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/libtcc.c b/libtcc.c index 591fd79..ecb2242 100644 --- a/libtcc.c +++ b/libtcc.c @@ -885,15 +885,28 @@ LIBTCCAPI TCCState *tcc_new(void) /* wint_t is unsigned int by default, but (signed) int on BSDs and unsigned short on windows. Other OSes might have still other conventions, sigh. */ -#if defined(__FreeBSD__) || defined (__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) +# if defined(__FreeBSD__) || defined (__FreeBSD_kernel__) + || defined(__NetBSD__) || defined(__OpenBSD__) tcc_define_symbol(s, "__WINT_TYPE__", "int"); -#else +# else tcc_define_symbol(s, "__WINT_TYPE__", "unsigned int"); -#endif +# endif +# if 0 /* glibc defines */ - tcc_define_symbol(s, "__REDIRECT(name, proto, alias)", "name proto __asm__ (#alias)"); - tcc_define_symbol(s, "__REDIRECT_NTH(name, proto, alias)", "name proto __asm__ (#alias) __THROW"); -#endif + tcc_define_symbol(s, "__REDIRECT(name, proto, alias)", + "name proto __asm__ (#alias)"); + tcc_define_symbol(s, "__REDIRECT_NTH(name, proto, alias)", + "name proto __asm__ (#alias) __THROW"); +# endif +# if 1 + /* define __GNUC__ to have some useful stuff from sys/cdefs.h */ + tcc_define_symbol(s, "__GNUC__", "2"); + tcc_define_symbol(s, "__GNUC_MINOR__", "1"); + tcc_define_symbol(s, "__builtin_alloca", "alloca"); + tcc_define_symbol(s, "__builtin_memcpy", "memcpy"); + tcc_define_symbol(s, "__USER_LABEL_PREFIX__", ""); +# endif +#endif /* ndef TCC_TARGET_PE */ return s; } diff --git a/tccgen.c b/tccgen.c index fda0211..2dcfec5 100644 --- a/tccgen.c +++ b/tccgen.c @@ -3104,10 +3104,14 @@ static void parse_attribute(AttributeDef *ad) case TOK_MODE_DI: ad->a.mode = VT_LLONG + 1; break; + case TOK_MODE_QI: + ad->a.mode = VT_BYTE + 1; + break; case TOK_MODE_HI: ad->a.mode = VT_SHORT + 1; break; case TOK_MODE_SI: + case TOK_MODE_word: ad->a.mode = VT_INT + 1; break; default: diff --git a/tcctok.h b/tcctok.h index 297a47e..228b055 100644 --- a/tcctok.h +++ b/tcctok.h @@ -117,10 +117,14 @@ DEF(TOK_FASTCALL1, "fastcall") DEF(TOK_FASTCALL2, "__fastcall") DEF(TOK_FASTCALL3, "__fastcall__") + DEF(TOK_MODE, "__mode__") + DEF(TOK_MODE_QI, "__QI__") DEF(TOK_MODE_DI, "__DI__") DEF(TOK_MODE_HI, "__HI__") DEF(TOK_MODE_SI, "__SI__") + DEF(TOK_MODE_word, "__word__") + DEF(TOK_DLLEXPORT, "dllexport") DEF(TOK_DLLIMPORT, "dllimport") DEF(TOK_NORETURN1, "noreturn")