LIU Hao wrote:
> 在 2026-10-17 19:19, Kirill Makurin 写道:
>> Subject: [PATCH 03/21] winpthreads: rename misc.c -> winpthreads.c
>>
>> Likewise, rename misc.h -> winpthreads.h.
>>
>> With this change, winpthreads.h becomes library's "main" include file;
>> ensure that each source file includes it directly or indirectly.
>
> I don't quite agree with this change. The 'main' include file should be
> pthread.h; and besides, this
> isn't a public header that should be included indirectly, since it defines
> macros `likely`, `unlikely`
> and `UNREACHABLE` which are more likely to clash with user code (I've seem
> them several times).
Yes, it is internal header file and is _not_ included from any public header
file. So it is "main" include file during the build, and so is included from
any source file as it contains global definitions and declarations used during
the build.
So, I could clarify that it is "main" include file which contains global
definitions used during the build.
>> Subject: [PATCH 07/21] winpthreads: winpthreads.c: new functions
>> `winpthreads_set_thread_description_{ansi,unicode}`
>
> This changes `pthread_setname_np()` to use explicit ANSI encoding; the old
> implementation uses the CRT's
> locale.
Yes, it is true. However, Win32 APIs interpret `const char *` string using ANSI
code page and not CRT code page, and we are already passing this string to
Win32 APIs in one way or another. I think using ANSI code page is appropriate
here. I can mention this change in commit message.
Note that winpthreads and `pthread_*` functions in general rarely accept any
string arguments; in most cases, this is the `sem_*` functions.
>> Subject: [PATCH 12/21] winpthreads: time.c: improve support for
>> `CLOCK_MONOTONIC`
>>
>> ...
>>
>> + /**
>> + * Check for overflow.
>> + */
>> + if (unlikely (msFromNsec > (_UI64_MAX - msFromNsec))) {
>
> ^^^^^^^^^^
>
> This should be `if (unlikely (msFromNsec > (_UI64_MAX - msFromSec))) {`
Good catch.
>> Subject: [PATCH 21/21] winphthreads: time.c: improve conversion logic in
>> `clock_settime`
>>
>> ...
>>
>> + /**
>> + * Obtain resolution of `clock_id` as a `FILETIME` value.
>> + */
>> + struct _timespec64 resAsTimeSpec;
>> + unsigned __int64 resAsFileTime;
>> +
>> + timeImpl (NULL, &resAsTimeSpec);
>> + resAsFileTime = resAsTimeSpec.tv_sec * POW10_7 + resAsTimeSpec.tv_nsec /
>> 100;
>
> On a system which uses HPET as the high-resolution timer,
> `QueryPerformanceFrequency()` may return a
> value > 10 MHz, such as 14,318,180. `resAsTimeSpec` is the reciprocal of the
> frequency, and in this case
> it's < 100 ns, so `resAsFileTime` is zero. Later there's
>
>> if ((fileTimeMax % resAsFileTime) != 0) {
>
> so this is division by zero, and is undefined behavior.
Another good catch. I had some idea to improve this change, and I also noticed
a typo in the commit message title.
> I still haven't had time to read all of these patches; these are findings
> from AI.
Sure, no pressure. I'll address all the issues after your full review.
- Kirill Makurin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public