Re: [Mingw-w64-public] [PATCH] crt: Increase precision of gettimeofday() if possible.

2021-05-03 Thread Liu Hao
在 5/4/21 2:48 AM, Martin Storsjö 写道: Sure. However in practice, with e.g. code like this: typedef void (*fp)(void); _Atomic fp ptr1 = ((void(*)(void))0); _Atomic fp ptr2 = ((void*)0); Clang accepts ptr1 but errors out on ptr2: https://gcc.godbolt.org/z/3YW6EsGP4 It looks like a bug. As per

Re: [Mingw-w64-public] [PATCH] crt: Increase precision of gettimeofday() if possible.

2021-05-03 Thread Martin Storsjö
On Mon, 3 May 2021, Jacek Caban wrote: I'd say that we should skip it altogether. Atomic operations seem totally redundant in this case. What would it protect from? It won't prevent multiple GetProcAddress calls - for that we'd need a critical section. Since GetProcAddress will always return t

Re: [Mingw-w64-public] [PATCH] crt: Increase precision of gettimeofday() if possible.

2021-05-03 Thread Martin Storsjö
On Mon, 3 May 2021, Liu Hao wrote: 在 2021-05-03 20:52, Martin Storsjö 写道: On Mon, 3 May 2021, Christian Franke wrote: Would plain '... = 0' without cast also work ? IIRC it should since C89 :-) That doesn't work either - clang seems to consider the cast (either implicit or explicit) betwee

Re: [Mingw-w64-public] [PATCH] crt: Increase precision of gettimeofday() if possible.

2021-05-03 Thread Liu Hao
在 2021-05-03 20:52, Martin Storsjö 写道: On Mon, 3 May 2021, Christian Franke wrote: Would plain '... = 0' without cast also work ? IIRC it should since C89 :-) That doesn't work either - clang seems to consider the cast (either implicit or explicit) between a integer or pointer-to-integer and

Re: [Mingw-w64-public] [PATCH] crt: Increase precision of gettimeofday() if possible.

2021-05-03 Thread Jacek Caban
On 5/3/21 2:52 PM, Martin Storsjö wrote: On Mon, 3 May 2021, Christian Franke wrote: Would plain '... = 0' without cast also work ? IIRC it should since C89 :-) That doesn't work either - clang seems to consider the cast (either implicit or explicit) between a integer or pointer-to-integer a

Re: [Mingw-w64-public] [PATCH] crt: Increase precision of gettimeofday() if possible.

2021-05-03 Thread Liu Hao
在 2021-05-03 20:30, Christian Franke 写道: Would plain '... = 0' without cast also work ? IIRC it should since C89 :-) Alternative: Leave '/* = 0 */' only as a comment. There is no need to set a static variable to 0. Either using `= 0` as the initializer or omitting it should work. I don't

Re: [Mingw-w64-public] [PATCH] crt: Increase precision of gettimeofday() if possible.

2021-05-03 Thread Martin Storsjö
On Mon, 3 May 2021, Christian Franke wrote: Would plain '... = 0' without cast also work ? IIRC it should since C89 :-) That doesn't work either - clang seems to consider the cast (either implicit or explicit) between a integer or pointer-to-integer and a pointer-to-function as something whi

Re: [Mingw-w64-public] [PATCH] crt: Increase precision of gettimeofday() if possible.

2021-05-03 Thread Christian Franke
Martin Storsjö wrote: On Mon, 3 May 2021, Martin Storsjö wrote: On Mon, 3 May 2021, Christian Franke wrote: Liu Hao wrote: 在 2021-05-03 14:49, Martin Storsjö 写道: Just for the record - I wouldn't mind applying the patch or something like it. I agree with the arguments that it would be ben

Re: [Mingw-w64-public] [PATCH] crt: Increase precision of gettimeofday() if possible.

2021-05-03 Thread Martin Storsjö
On Mon, 3 May 2021, Martin Storsjö wrote: On Mon, 3 May 2021, Christian Franke wrote: Liu Hao wrote: 在 2021-05-03 14:49, Martin Storsjö 写道: Just for the record - I wouldn't mind applying the patch or something like it. I agree with the arguments that it would be beneficial to get more pre

Re: [Mingw-w64-public] [PATCH] crt: Increase precision of gettimeofday() if possible.

2021-05-03 Thread Martin Storsjö
On Mon, 3 May 2021, Christian Franke wrote: Liu Hao wrote: 在 2021-05-03 14:49, Martin Storsjö 写道: Just for the record - I wouldn't mind applying the patch or something like it. I agree with the arguments that it would be beneficial to get more precision here, even if one in general maybe ca

Re: [Mingw-w64-public] [PATCH] crt: Increase precision of gettimeofday() if possible.

2021-05-03 Thread Christian Franke
Liu Hao wrote: 在 2021-05-03 14:49, Martin Storsjö 写道: Just for the record - I wouldn't mind applying the patch or something like it. I agree with the arguments that it would be beneficial to get more precision here, even if one in general maybe can argue that we don't strictly need to provid

Re: [Mingw-w64-public] [PATCH] crt: Increase precision of gettimeofday() if possible.

2021-05-03 Thread Christian Franke
Liu Hao wrote: 在 2021-04-29 03:34, Christian Franke 写道: BTW.2: The *ftime*() functions from newer versions of MSVC CRT also use GetSystemTimePreciseAsFileTime() if available. UCRTBASE.DLL still uses `GetSystemTimeAsFileTime()`. A test program build with VS2019 and estimation of the UCR

Re: [Mingw-w64-public] [PATCH] crt: Fix the parameter type for UCRT _crt_atexit

2021-05-03 Thread Liu Hao
在 2021-05-03 15:44, Martin Storsjö 写道: On Sun, 25 Apr 2021, Martin Storsjö wrote: Also move the declaration to corecrt_startup.h, and add a declaration of the corresponding _crt_quick_at_exit. Signed-off-by: Martin Storsjö --- mingw-w64-crt/crt/ucrtbase_compat.c | 5 ++--- mingw-w64-header

Re: [Mingw-w64-public] [PATCH] crt: Implement `at_quick_exit()`

2021-05-03 Thread Martin Storsjö
On Mon, 26 Apr 2021, Liu Hao wrote: 在 2021-04-26 04:20, Martin Storsjö 写道: The exact behaviour for cases 3-5 differ between whether the two are linked dynamically or statically against the CRT. I'm not sure if all the nuances are worth mimicing though. (A function registered with at_quick_ex

Re: [Mingw-w64-public] [PATCH] crt: Increase precision of gettimeofday() if possible.

2021-05-03 Thread Liu Hao
在 2021-05-03 14:49, Martin Storsjö 写道: Just for the record - I wouldn't mind applying the patch or something like it. I agree with the arguments that it would be beneficial to get more precision here, even if one in general maybe can argue that we don't strictly need to provide such precision.

Re: [Mingw-w64-public] [PATCH] crt: Fix the parameter type for UCRT _crt_atexit

2021-05-03 Thread Martin Storsjö
On Sun, 25 Apr 2021, Martin Storsjö wrote: Also move the declaration to corecrt_startup.h, and add a declaration of the corresponding _crt_quick_at_exit. Signed-off-by: Martin Storsjö --- mingw-w64-crt/crt/ucrtbase_compat.c | 5 ++--- mingw-w64-headers/crt/corecrt_startup.h | 2 ++ 2 files c