|
From: | Christian Jullien |
Subject: | Re: [Tinycc-devel] Why is __LP64__ defined for targets for 32bits targets? |
Date: | Sun, 25 Sep 2016 12:17:37 +0200 |
Having no remarks, I pushed this change and added 86-memory-model.c that test __*LP*__ features on different systems. I’m unsure what the values should be for C67. Christian From: Tinycc-devel [mailto:address@hidden On Behalf Of Christian Jullien I finally had time to investigate further. Based on my understanding (with google help), here is the fix I propose: /* TinyCC & gcc defines */ mob looks good on Windows 32 and 64, Linux x86_64, Linux arm and arm64. Can you please review for other architectures/OS? From: Christian Jullien [mailto:address@hidden] From a commit:
a patch from tcc bugzilla. diff --git a/libtcc.c b/libtcc.c index d63b86f..b0fcdf9 100644 (file) --- a/libtcc.c +++ b/libtcc.c @@ -1146,9 +1146,11 @@ LIBTCCAPI TCCState *tcc_new(void) #if defined TCC_TARGET_PE && defined TCC_TARGET_X86_64 tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned long long"); tcc_define_symbol(s, "__PTRDIFF_TYPE__", "long long"); + tcc_define_symbol(s, "__LLP64__", NULL); #else tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned long"); tcc_define_symbol(s, "__PTRDIFF_TYPE__", "long"); + tcc_define_symbol(s, "__LP64__", NULL); #endif From: Tinycc-devel [mailto:address@hidden] On Behalf Of Christian Jullien /* TinyCC & gcc defines */ #if defined TCC_TARGET_PE && defined TCC_TARGET_X86_64 tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned long long"); tcc_define_symbol(s, "__PTRDIFF_TYPE__", "long long"); tcc_define_symbol(s, "__LLP64__", NULL); #else tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned long"); tcc_define_symbol(s, "__PTRDIFF_TYPE__", "long"); tcc_define_symbol(s, "__LP64__", NULL); // <= here? #endif Compiling tcc on native 32BITS Windows for example, it defines __LP64__ This variable is specified as (see https://gcc.gnu.org/onlinedocs/gcc-4.9.2/cpp/Common-Predefined-Macros.html) __LP64__ _LP64 These macros are defined, with value 1, if (and only if) the compilation is for a target where long int and pointer both use 64-bits and int uses 32-bit. Testing this macro in programs compiled with tcc 32bits returns wrong behavior #if defined(__LP64__) #define MYPTR_SIZE_IN_BYTES 8 // Assume void* is a 64bits pointer which is false on Windows 32bit #endif |
[Prev in Thread] | Current Thread | [Next in Thread] |