在 2026-9-5 01:12, Zhongteng Gui 写道:
On 2026/09/04 22:52, Zhongteng Gui wrote:Hi, here're 2 patches about cleanup and optimize gettimeofday (and related stuff).This change is a bit huge, and I'm not very sure about some parts, e.g. 1. Originally, we provide `int gettimeofday(struct timeval*, void*)`, while POSIX expects `int gettimeofday(struct timeval*, struct timezone*)`. It's noteworthy that switching to POSIX will breaks GCC without special handling. because libiberty.h bundled by GCC specially checked for __MINGW32__, and declares gettimeofday with `void*` arg type, which fails with -Wstrict-prototypes. But keeping `void*` is semantically wrong, as we actually set timezone if nonnull. 2. Should we conditionally expose gettimeofday? It is marked as obsolete in POSIX.1-2008 and removed in POSIX.1-2024.
It's just not required any more, but legacy code still wants to call it.
3. Originally, gettimeofday assumed "struct timeval*" to be nonnull, and didn't check this. Should we keep this as is, or check it and return -1 if NULL?
I'd expect that a null pointer be ignored, like on Linux.
+int __cdecl mingw_gettimeofday(struct timeval* _tv, struct timezone* _tz) __MINGW_ASM_CALL(gettimeofday);
The parameter names should be `_Tv` and `_Tz`. An identifier with one underscore followed by a lowercase letter is reserved only in global namespace.
And I suspect this can result in infinite recursion if a user has
int
gettimeofday(struct timeval* tv, struct timezone* tz)
{
return mingw_gettimeofday(tv, tz); // calls `gettimeofday`
}
--
Best regards,
LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
