Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information