As no one protested, accepted or even commented, I pushed a patch. Hope it’s
Ok

 

See:
https://repo.or.cz/tinycc.git/commitdiff/40f01478d82a3dc225c3299062741fc36cb
e2b56

 

Now, whether it is compiled with –m32 or -m64 on Windows, this sample gives
the same expected result:

 

c:\tmp>tcc -m32 foo.c -o foo.exe && foo

100000000 8

1 8

 

c:\tmp>tcc -m64 foo.c -o foo.exe && foo

100000000 8

1 8

 

c:\tmp>more foo.c

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

 

int

main() {

        long long x = strtoll("0x100000000", NULL, 0);

        printf("%llx %d\n", x, (int)sizeof(x));

        x = (x >> 32);

        printf("%llx %d\n", x, (int)sizeof(x));

}

 

Last but not least, it lets GNUmake compile ROOTB on Windows with this
version of tcc.

 

Christian

 

 

From: Tinycc-devel [mailto:tinycc-devel-boun...@nongnu.org] On Behalf Of
Christian Jullien
Sent: Sunday, November 06, 2022 09:43
To: tinycc-devel@nongnu.org
Subject: [Tinycc-devel] strto[u]ll: Do you allow me to apply this patch?

 

As _strto[u]ll exists in msvcrt.dll and works well for either –m32|-m64
tcc.h can just test for _WIN32.

I also define those macros in the win32§include/stdlib.h

 

 

jullien@sims4:~/tinycc $ git diff

diff --git a/tcc.h b/tcc.h

index aa04404..1756831 100644

--- a/tcc.h

+++ b/tcc.h

@@ -65,7 +65,7 @@ extern long double strtold (const char *__nptr, char
**__endptr);

# ifndef __GNUC__

#  define strtold (long double)strtod

#  define strtof (float)strtod

-#  ifdef _WIN64

+#  ifdef _WIN32

#   define strtoll _strtoi64

#   define strtoull _strtoui64

#  else

diff --git a/win32/include/stdlib.h b/win32/include/stdlib.h

index 033c0fd..671772c 100644

--- a/win32/include/stdlib.h

+++ b/win32/include/stdlib.h

@@ -544,8 +544,18 @@ extern "C" {

 

   __CRT_INLINE long long __cdecl llabs(long long _j) { return (_j >= 0 ? _j
: -_j); }

 

+  /* stro[u]ll do not properly map in Windows; use macros as with VC++ does
*/

+#if !defined(strtoll)

+#define strtoll _strtoi64

+#endif

+#if !defined(strtoull)

+#define strtoull _strtoui64

+#endif

+

+/*

   long long  __cdecl strtoll(const char* __restrict__, char** __restrict,
int);

   unsigned long long  __cdecl strtoull(const char* __restrict__, char**
__restrict__, int);

+*/

 

   /* these are stubs for MS _i64 versions */

   long long  __cdecl atoll (const char *);

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to