tcc-stupidos/win32/include
Avi Halachmi (:avih) cff81434a5 win32: 32 bit: allow 64 bit time via __MINGW_USE_VC2005_COMPAT
Before VC2005, the time macros (time, time_t, localtime, etc) were
32 bit on 32 bit platforms, but they became 64 in VC2005.
This works even on XP 32 (_time64 etc do exist in XP32 - and in tcc).

However, tv_sec in struct timeval (which for msvc is in winsock2.h)
remains 32 bit to this day on 32 bit platforms, and dlls which were
not recompiled remain with time 32, possibly at the API boundary.

Due to these, and maybe more, mingw w64 decided to keep the time
macros 32 bit on 32 bit platforms, with __MINGW_USE_VC2005_COMPAT
override (which does nothing in mingw w64 except time -> time64).

It's not perfect, but it allows some existing code to easily switch
to 64 bit time without redefining time etc, e.g. used by libressl:
  https://github.com/libressl/portable/blob/master/README.mingw.md

Before, it was impossible to enable the 64 bit time macros in tcc 32.

This commit adds support for __MINGW_USE_VC2005_COMPAT in tcc as well,
which, like in mingw w64, affects only the 32->64 time macros, and is
a cheap way to get 64 bit time in existing code in some 32 bit apps.

The additional #ifndef _USE_32BIT_TIME_T is unrelated to the override,
and avoids a warning (and nothing else) when the code explicitly
defines it - which is allowed in MSVC, and also guarded in mingw w64.

Relevant current quote from the libressl link above:
------- >8 ---------

Why the -D__MINGW_USE_VC2005_COMPAT flag on 32-bit systems?

An ABI change introduced with Microsoft Visual C++ 2005 (also known as
Visual C++ 8.0) switched time_t from 32-bit to 64-bit. It is important
to build LibreSSL with 64-bit time_t whenever possible, because 32-bit
time_t is unable to represent times past 2038 (this is commonly known
as the Y2K38 problem).

If LibreSSL is built with 32-bit time_t, when verifying a certificate
whose expiry date is set past 19 January 2038, it will be unable to
tell if the certificate has expired or not, and thus take the safe
stance and reject it.

In order to avoid this, you need to build LibreSSL (and everything
that links with it) with the -D__MINGW_USE_VC2005_COMPAT flag. This
tells MinGW-w64 to use the new ABI.

64-bit systems always have a 64-bit time_t and are not affected by
this problem.
2024-11-18 15:45:30 +02:00
..
sec_api win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
sys win32: include/sys/types.h: add useconds_t 2024-10-23 14:48:50 +03:00
tcc Fix wine 2021-01-03 20:12:34 +01:00
winapi win32: mingw headers: mainly add LOAD_LIBRARY* values 2024-11-18 15:44:14 +02:00
_mingw.h win32: 32 bit: allow 64 bit time via __MINGW_USE_VC2005_COMPAT 2024-11-18 15:45:30 +02:00
assert.h C11, section 7.2: The macro static_assert expands to _Static_assert. This macro was missing on Windows 2020-01-14 07:41:58 +01:00
conio.h Spelling fixes 2017-09-24 18:03:26 -07:00
ctype.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
dir.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
direct.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
dirent.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
dos.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
errno.h tccpp: cleanup target-os defines 2020-12-31 02:03:31 +01:00
excpt.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
fcntl.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
fenv.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
inttypes.h add version number to manpage 2013-02-17 00:48:51 +01:00
io.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
iso646.h Add C99 compiliant iso646.h header 2019-01-13 10:24:50 +01:00
limits.h Fix char limits 2020-11-17 09:06:48 +02:00
locale.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
malloc.h tccrun: review last changes 2024-02-19 17:45:44 +01:00
math.h tccpp: cleanup target-os defines 2020-12-31 02:03:31 +01:00
mem.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
memory.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
process.h win32/include/process.h: update prototypes to match mingw. 2014-04-12 00:09:57 -04:00
setjmp.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
share.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
signal.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
stdint.h Spelling fixes 2017-09-24 18:03:26 -07:00
stdio.h add version number to manpage 2013-02-17 00:48:51 +01:00
stdlib.h tccrun: review last changes 2024-02-19 17:45:44 +01:00
string.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
tchar.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
time.h win32/include: enable _timezone etc variables. 2011-07-11 18:44:47 +02:00
uchar.h stuff & fixes 2023-09-06 22:42:30 +02:00
unistd.h win32: make #include <unistd.h> work 2024-10-23 14:58:41 +03:00
vadefs.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00
values.h Spelling fixes 2017-09-24 18:03:26 -07:00
wchar.h win32: wchar.h: don't redifine WCHAR_MIN[/MAX] (after stdint.h) 2016-06-19 14:44:07 +03:00
wctype.h win64: use new headers from mingw 2009-07-18 22:06:37 +02:00