Re: [Mingw-w64-public] winpthreads: update mutex implementation [v4]

2026-09-12 Thread Kirill Makurin
LIU Hao wrote:

> 在 2026-9-12 07:07, Kirill Makurin 写道:
>> However, I'm not sure if in the current state winphtreads is even loadable 
>> on Win9x systems and static
>> winpthreads would be broken on Win9x due to lack of support for TLS 
>> callbacks in EXEs (thanks to Pali for
>> investigating TLS behavior across Windows versions). I want to add support 
>> for old NT versions as well as
>> Win9x systems. I would prioritize adding support for older NT versions 
>> before Win9x.
>
> Ah I see it now; `__dyn_tls_pthread` is not called from the DLL entry-point 
> routine, but as a TLS callback.

It probably would be better to call it from `DllMain` for the DLL build, and 
call it as a TLS callback for static build.

> So I'm leaving `CreateEventW` alone. There's also one reference to 
> `CreateEventA` in spinlock.c which you
> may fix later.

Yes, I had this one in mind. I'll address this one along with adding fast paths 
for spinlocks later.

>> To give you an example, you can take look at this[1] source file in my 
>> posix32 library, the way it
>> handles `OutputDebugString` functions. The idea is basically to have a 
>> function (e.g.
>> `winpthreads_create_event`) which calls either ANSI or Unicode version of 
>> `CreateEvent`, depending on
>> whether code is running on NT or Win9x. This would also apply to functions 
>> such as `CreateMutex` or
>> `CreateSemaphore`.
>
> `OutputDebugString` is an exception to the common guidance that W functions 
> should be preferred to A
> ones. In reality, `OutputDebugStringW` converts its argument to an ANSI 
> string and calls
> `OutputDebugStringA`, so it's always recommended to call `OutputDebugStringA` 
> directly.

Is this so? Documentation for `WaitForDebugEventEx`[1] gives me impression that 
an application should use it instead of `WaitForDebugEvent` in order to 
retrieve Unicode string passed to `OutputDebugStringW`.

> I have pushed this series patches with these changes:

Thanks!

- Kirill Makurin

[1] 
https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-waitfordebugeventex

___
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] winpthreads: update mutex implementation [v4]

2026-09-12 Thread LIU Hao

在 2026-9-12 07:07, Kirill Makurin 写道:

LIU Hao wrote:

 > First, `LockCount` doesn't have to be 64-bit which would introduce some 
complexity for 32-bit targets;
 > and when using a 64-bit value, it's unnecessary to check for overflows which 
could take hundreds of years.

I don't have strong opinion on this; if you think that using 64-bit lock count is unnecessary, then let's 
use 32-bit lock count. Can you apply the changes locally?


OK.


However, I'm not sure if in the current state winphtreads is even loadable on Win9x systems and static 
winpthreads would be broken on Win9x due to lack of support for TLS callbacks in EXEs (thanks to Pali for 
investigating TLS behavior across Windows versions). I want to add support for old NT versions as well as 
Win9x systems. I would prioritize adding support for older NT versions before Win9x.


Ah I see it now; `__dyn_tls_pthread` is not called from the DLL entry-point 
routine, but as a TLS callback.

So I'm leaving `CreateEventW` alone. There's also one reference to `CreateEventA` in spinlock.c which you 
may fix later.



To give you an example, you can take look at this[1] source file in my posix32 library, the way it 
handles `OutputDebugString` functions. The idea is basically to have a function (e.g. 
`winpthreads_create_event`) which calls either ANSI or Unicode version of `CreateEvent`, depending on 
whether code is running on NT or Win9x. This would also apply to functions such as `CreateMutex` or 
`CreateSemaphore`.


`OutputDebugString` is an exception to the common guidance that W functions should be preferred to A 
ones. In reality, `OutputDebugStringW` converts its argument to an ANSI string and calls 
`OutputDebugStringA`, so it's always recommended to call `OutputDebugStringA` directly.



I have pushed this series patches with these changes:

diff --git a/mingw-w64-libraries/winpthreads/src/mutex.c 
b/mingw-w64-libraries/winpthreads/src/mutex.c
index a2169efa0..3b3edf261 100644
--- a/mingw-w64-libraries/winpthreads/src/mutex.c
+++ b/mingw-w64-libraries/winpthreads/src/mutex.c
@@ -239,7 +239,7 @@ typedef struct {
* once lock count reaches zero, the owning thread releases the ownership of
* the mutex.
*/
-  unsigned __int64 LockCount;
+  unsigned int LockCount;
 } WinpthreadsRecursiveMutex;

 WINPTHREADS_STATIC_ASSERT (offsetof (WinpthreadsMutexBase, Vtable) == offsetof 
(WinpthreadsRecursiveMutex, Base.Vtable), "");

@@ -646,7 +646,7 @@ static int WinpthreadsRecursiveMutexLock (WinpthreadsMutex 
*wMutex, const struct
* If calling thread already owns the mutex, simply increment the lock count.
*/
   if (mutex->Owner == threadId) {
-if (unlikely (mutex->LockCount == _UI64_MAX)) {
+if (unlikely (mutex->LockCount == UINT_MAX)) {
   return EAGAIN;
 }

@@ -668,8 +668,8 @@ static int WinpthreadsRecursiveMutexLock (WinpthreadsMutex 
*wMutex, const struct
   }

 done:
-  mutex->Owner  = threadId;
-  mutex->LockCount += 1;
+  mutex->Owner = threadId;
+  mutex->LockCount = 1;

   return 0;
 }
@@ -687,7 +687,7 @@ static int WinpthreadsRecursiveMutexTryLock 
(WinpthreadsMutex *wMutex, BOOL excl
   return EBUSY;
 }

-if (unlikely (mutex->LockCount == _UI64_MAX)) {
+if (unlikely (mutex->LockCount == UINT_MAX)) {
   return EAGAIN;
 }

@@ -699,8 +699,8 @@ static int WinpthreadsRecursiveMutexTryLock 
(WinpthreadsMutex *wMutex, BOOL excl
 return EBUSY;
   }

-  mutex->Owner  = threadId;
-  mutex->LockCount += 1;
+  mutex->Owner = threadId;
+  mutex->LockCount = 1;

   return 0;
 }
diff --git a/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-lock-recursive.c 
b/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-lock-recursive.c

index 3ead86aea..4d97a50f6 100644
--- 
a/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-lock-recursive.c
+++ 
b/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-lock-recursive.c
@@ -38,7 +38,7 @@
  * Thread A locks L.
  *
  * Thread A attempts to lock L again; the call to `pthread_mutex_lock` must
- * fail with EBUSY.
+ * fail with EDEADLK.
  *
  * Thread A unlocks L.
  *
diff --git a/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-static-lock-recursive.c 
b/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-static-lock-recursive.c

index ebfbb8be5..b0c70aff5 100644
--- 
a/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-static-lock-recursive.c
+++ 
b/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-static-lock-recursive.c
@@ -39,7 +39,7 @@
  * Thread A locks L.
  *
  * Thread A attempts to lock L again; the call to `pthread_mutex_lock` must
- * fail with EBUSY.
+ * fail with EDEADLK.
  *
  * Thread A unlocks L.
  *




--
Best regards,
LIU Hao


OpenPGP_signature.asc
Description: OpenPGP digital signature
___
Mingw-w64-public mailing list
[email protected]

Re: [Mingw-w64-public] winpthreads: update mutex implementation [v4]

2026-09-11 Thread Kirill Makurin
LIU Hao wrote:

> First, `LockCount` doesn't have to be 64-bit which would introduce some 
> complexity for 32-bit targets;
> and when using a 64-bit value, it's unnecessary to check for overflows which 
> could take hundreds of years.

I don't have strong opinion on this; if you think that using 64-bit lock count 
is unnecessary, then let's use 32-bit lock count. Can you apply the changes 
locally?

Another idea may be using 32-bit lock count for 32-bit targets and 64-bit lock 
count for 64-bit targets. I'm not sure if there's any value in doing so though.

> And, `CreateEventW()` fails on Windows 9x. Since you are not passing a name, 
> it can be equivalently
> replaced with `CreateEventA()`.

I've got a wrong impression that `CreateEventA` was not available on NT 3.1, 
similar to how locale function such as `GetLocaleInfoA` were only introduced in 
NT 3.5 and Win95. But looking at lib32/kernel32.def, it does not seem to be the 
case.

Perfectly, I think we should use `CreateEventW` on NT and `CreateEventA` on 
Win9x; "Unicode" APIs are present in kernel32.dll on Win9x systems, but they 
always fail.

However, I'm not sure if in the current state winphtreads is even loadable on 
Win9x systems and static winpthreads would be broken on Win9x due to lack of 
support for TLS callbacks in EXEs (thanks to Pali for investigating TLS 
behavior across Windows versions). I want to add support for old NT versions as 
well as Win9x systems. I would prioritize adding support for older NT versions 
before Win9x.

To give you an example, you can take look at this[1] source file in my posix32 
library, the way it handles `OutputDebugString` functions. The idea is 
basically to have a function (e.g. `winpthreads_create_event`) which calls 
either ANSI or Unicode version of `CreateEvent`, depending on whether code is 
running on NT or Win9x. This would also apply to functions such as 
`CreateMutex` or `CreateSemaphore`.

- Kirill Makurin

[1] 
https://github.com/maiddaisuki/posix32/blob/master/lib/posix32-core/src/debug.c

___
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] winpthreads: update mutex implementation [v4]

2026-09-11 Thread LIU Hao

在 2026-9-11 18:41, Kirill Makurin 写道:

Hello,

This another version of mutex changes.
GitHub CI run: https://github.com/maiddaisuki/mingw-w64/actions/runs/34578970906 


Hopefully, this is the final revision. As I have already mentioned, after these changes I want to 
implement POSIX robust mutexes. The rest of the message is a few details on how I plan to implement them.


I'd like to suggest these changes:

diff --git a/mingw-w64-libraries/winpthreads/src/mutex.c 
b/mingw-w64-libraries/winpthreads/src/mutex.c
index a2169efa0..f8cf652f5 100644
--- a/mingw-w64-libraries/winpthreads/src/mutex.c
+++ b/mingw-w64-libraries/winpthreads/src/mutex.c
@@ -239,7 +239,7 @@ typedef struct {
* once lock count reaches zero, the owning thread releases the ownership of
* the mutex.
*/
-  unsigned __int64 LockCount;
+  unsigned int LockCount;
 } WinpthreadsRecursiveMutex;

 WINPTHREADS_STATIC_ASSERT (offsetof (WinpthreadsMutexBase, Vtable) == offsetof 
(WinpthreadsRecursiveMutex, Base.Vtable), "");

@@ -367,7 +367,7 @@ static int WinpthreadsNormalMutexInit (WinpthreadsMutex 
**wMutex, const pthread_
 return ENOMEM;
   }

-  mutex->Event = CreateEventW (NULL, FALSE, FALSE, NULL);
+  mutex->Event = CreateEventA (NULL, FALSE, FALSE, NULL);

   /**
* The pthread_mutex_init() function shall fail if:
@@ -472,7 +472,7 @@ static int WinpthreadsErrorCheckMutexInit (WinpthreadsMutex 
**wMutex, const pthr
 return ENOMEM;
   }

-  mutex->Event = CreateEventW (NULL, FALSE, FALSE, NULL);
+  mutex->Event = CreateEventA (NULL, FALSE, FALSE, NULL);

   /**
* The pthread_mutex_init() function shall fail if:
@@ -602,7 +602,7 @@ static int WinpthreadsRecursiveMutexInit (WinpthreadsMutex 
**wMutex, const pthre
 return ENOMEM;
   }

-  mutex->Event = CreateEventW (NULL, FALSE, FALSE, NULL);
+  mutex->Event = CreateEventA (NULL, FALSE, FALSE, NULL);

   /**
* The pthread_mutex_init() function shall fail if:
@@ -646,7 +646,7 @@ static int WinpthreadsRecursiveMutexLock (WinpthreadsMutex 
*wMutex, const struct
* If calling thread already owns the mutex, simply increment the lock count.
*/
   if (mutex->Owner == threadId) {
-if (unlikely (mutex->LockCount == _UI64_MAX)) {
+if (unlikely (mutex->LockCount == UINT_MAX)) {
   return EAGAIN;
 }

@@ -668,8 +668,8 @@ static int WinpthreadsRecursiveMutexLock (WinpthreadsMutex 
*wMutex, const struct
   }

 done:
-  mutex->Owner  = threadId;
-  mutex->LockCount += 1;
+  mutex->Owner = threadId;
+  mutex->LockCount = 1;

   return 0;
 }
@@ -687,7 +687,7 @@ static int WinpthreadsRecursiveMutexTryLock 
(WinpthreadsMutex *wMutex, BOOL excl
   return EBUSY;
 }

-if (unlikely (mutex->LockCount == _UI64_MAX)) {
+if (unlikely (mutex->LockCount == UINT_MAX)) {
   return EAGAIN;
 }

@@ -699,8 +699,8 @@ static int WinpthreadsRecursiveMutexTryLock 
(WinpthreadsMutex *wMutex, BOOL excl
 return EBUSY;
   }

-  mutex->Owner  = threadId;
-  mutex->LockCount += 1;
+  mutex->Owner = threadId;
+  mutex->LockCount = 1;

   return 0;
 }
diff --git a/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-lock-recursive.c 
b/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-lock-recursive.c

index 3ead86aea..4d97a50f6 100644
--- 
a/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-lock-recursive.c
+++ 
b/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-lock-recursive.c
@@ -38,7 +38,7 @@
  * Thread A locks L.
  *
  * Thread A attempts to lock L again; the call to `pthread_mutex_lock` must
- * fail with EBUSY.
+ * fail with EDEADLK.
  *
  * Thread A unlocks L.
  *
diff --git a/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-static-lock-recursive.c 
b/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-static-lock-recursive.c

index ebfbb8be5..b0c70aff5 100644
--- 
a/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-static-lock-recursive.c
+++ 
b/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-static-lock-recursive.c
@@ -39,7 +39,7 @@
  * Thread A locks L.
  *
  * Thread A attempts to lock L again; the call to `pthread_mutex_lock` must
- * fail with EBUSY.
+ * fail with EDEADLK.
  *
  * Thread A unlocks L.
  *

First, `LockCount` doesn't have to be 64-bit which would introduce some complexity for 32-bit targets; 
and when using a 64-bit value, it's unnecessary to check for overflows which could take hundreds of years.


And, `CreateEventW()` fails on Windows 9x. Since you are not passing a name, it can be equivalently 
replaced with `CreateEventA()`.




--
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


Re: [Mingw-w64-public] winpthreads: update mutex implementation

2026-09-10 Thread LIU Hao

在 2026-9-10 23:22, Kirill Makurin 写道:
Should we add similar fast paths for spinlocks? After spinlock changes in May, they always call 
`WaitForSingleObject` which means they suffer from the same syscall overhead. I mentioned in the past 
that some source files (barrier.c, rwlock.c) use file-global spinlock when accessing _any_ object, so 
having fast paths could give noticeable performance improvement in some cases.




Yes; a spinlock is just a mutex.


--
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


Re: [Mingw-w64-public] winpthreads: update mutex implementation [V2]

2026-09-10 Thread LIU Hao

在 2026-9-10 21:10, Kirill Makurin 写道:

+static int WinpthreadsNormalMutexInit (WinpthreadsMutex **wMutex, const 
pthread_mutexattr_t *attr) {
+  /**
+   * Using `RTL_SIZEOF_THROUGH_FIELD` for allocation size may result in
+   * `-Walloc-size` diagnositcs.
+   */
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Walloc-size"
+#endif
+
+  *wMutex = malloc (RTL_SIZEOF_THROUGH_FIELD (WinpthreadsMutex, Mutex.Normal));
+
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
+
+  /**
+   * The pthread_mutex_init() function shall fail if:
+   *
+   * [ENOMEM]
+   *   Insufficient memory exists to initialize the mutex.
+   */
+  if (*wMutex == NULL) {
+return ENOMEM;
+  }
+
+  /**
+   * Direct access through `(*wMutex)->Mutex` may result in `-Warray-bounds`
+   * diagnostics.
+   */
+  WinpthreadsNormalMutex *mutex = &(*wMutex)->Mutex.Normal;


While there are certainly no issues in this code, the pragmas don't look quite neat. Using the COM-flavor 
approach which I suggested earlier, it could be


   struct WinpthreadsMutex
   {
 const WinpthreadsMutexVtable *vtable;
   };

   struct WinpthreadsNormalMutex
   {
 const WinpthreadsMutexVtable *vtable;
 HANDLE Event;
 LONG LockState;
   };

   static int WinpthreadsNormalMutexInit (WinpthreadsMutex **wMutex, const 
pthread_mutexattr_t *attr) {
 WinpthreadsNormalMutex *mutex = malloc (sizeof (WinpthreadsNormalMutex));
 *wMutex = (WinpthreadsMutex *) mutex;
 if (!mutex) {
   return ENOMEM;
 }

 // ...
   }



+
+  mutex->Event = CreateEventW (NULL, FALSE, FALSE, NULL);
+
+  /**
+   * The pthread_mutex_init() function shall fail if:
+   *
+   * [EAGAIN]
+   *   The system lacked the necessary resources (other than memory) to
+   *   initialize another mutex.
+   */
+  if (mutex->Event == NULL) {
+free (wMutex);
+return EAGAIN;
+  }



This should be `free (*wMutex)`, and likewise somewhere else:


diff --git a/mingw-w64-libraries/winpthreads/src/mutex.c 
b/mingw-w64-libraries/winpthreads/src/mutex.c
index be950ee2b..0a58a753d 100644
--- a/mingw-w64-libraries/winpthreads/src/mutex.c
+++ b/mingw-w64-libraries/winpthreads/src/mutex.c
@@ -380,7 +380,7 @@ static int WinpthreadsNormalMutexInit (WinpthreadsMutex 
**wMutex, const pthread_
*   initialize another mutex.
*/
   if (mutex->Event == NULL) {
-free (wMutex);
+free (*wMutex);
 return EAGAIN;
   }

@@ -503,7 +503,7 @@ static int WinpthreadsErrorCheckMutexInit (WinpthreadsMutex 
**wMutex, const pthr
*   initialize another mutex.
*/
   if (mutex->Event == NULL) {
-free (wMutex);
+free (*wMutex);
 return EAGAIN;
   }

@@ -650,7 +650,7 @@ static int WinpthreadsRecursiveMutexInit (WinpthreadsMutex 
**wMutex, const pthre
*   initialize another mutex.
*/
   if (mutex->Event == NULL) {
-free (wMutex);
+free (*wMutex);
 return EAGAIN;
   }


--
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


Re: [Mingw-w64-public] winpthreads: update mutex implementation

2026-09-10 Thread Kirill Makurin
LIU Hao wrote:

> In '[PATCH 09/24] winpthreads: mutex.c: simplify `pthread_mutex_*lock` 
> functions' and '[PATCH 11/24]
> winpthreads: mutex.c: refactor implementation', I see that for normal mutexes 
> there's no longer a fast
> path and now `_pthread_wait_for_single_object()` is always called which leads 
> to a syscall. That is a
> severe performance regression and is unacceptable; see attached figure.

Should we add similar fast paths for spinlocks? After spinlock changes in May, 
they always call `WaitForSingleObject` which means they suffer from the same 
syscall overhead. I mentioned in the past that some source files (barrier.c, 
rwlock.c) use file-global spinlock when accessing _any_ object, so having fast 
paths could give noticeable performance improvement in some cases.

- Kirill Makurin

___
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] winpthreads: update mutex implementation [V2]

2026-09-10 Thread Kirill Makurin
LIU Hao wrote:

> While there are certainly no issues in this code, the pragmas don't look 
> quite neat.

I agree that having a pragma around single function call indeed feels a bit off.

> Using the COM-flavor approach which I suggested earlier, it could be
>
> struct WinpthreadsMutex
> {
>   const WinpthreadsMutexVtable *vtable;
> };
>
> struct WinpthreadsNormalMutex
> {
>   const WinpthreadsMutexVtable *vtable;
>   HANDLE Event;
>   LONG LockState;
> };
>
> static int WinpthreadsNormalMutexInit (WinpthreadsMutex **wMutex, const 
> pthread_mutexattr_t *attr) {
>   WinpthreadsNormalMutex *mutex = malloc (sizeof 
> (WinpthreadsNormalMutex));
>   *wMutex = (WinpthreadsMutex *) mutex;
>   if (!mutex) {
> return ENOMEM;
>   }
>
>   // ...
> }

Yes, this approach does seem reasonable now. In the original version of changes 
I sent, `WinpthreadsMutex` simply contained two pointers: one to static 
"vtable" and second to allocated mutex-type specific structure. Now that we no 
longer have the latter, it does make sense to store "vtable" directly in 
mutex-type specific structure.

I'll take care of this tomorrow. Hopefully, it will be the last revision.

>> +
>> +  mutex->Event = CreateEventW (NULL, FALSE, FALSE, NULL);
>> +
>> +  /**
>> +   * The pthread_mutex_init() function shall fail if:
>> +   *
>> +   * [EAGAIN]
>> +   *   The system lacked the necessary resources (other than memory) to
>> +   *   initialize another mutex.
>> +   */
>> +  if (mutex->Event == NULL) {
>> +free (wMutex);
>> +return EAGAIN;
>> +  }
>
> This should be `free (*wMutex)`, and likewise somewhere else:

Nice catch! I simply replaced `mutex` with `wMutex` and overlooked different 
indirection levels.

- Kirill Makurin

___
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] winpthreads: update mutex implementation [V2]

2026-09-10 Thread Kirill Makurin
I wrote:

> I'll push new version for CI run later today, and if it passes, I'll send it 
> to the list.

Most of CI passes except one issue when compiling winpthreads with clang; see 
https://github.com/maiddaisuki/mingw-w64/actions/runs/34466771691/job/102837072791.

Using `RTL_SIZEOF_THROUGH_FIELD` for allocation size results in a -Walloc-size 
diagnostic from clang; we should be able to silence it with a pragma.

- Kirill Makurin


___
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] winpthreads: update mutex implementation [V2]

2026-09-10 Thread LIU Hao

在 2026-9-10 20:27, Kirill Makurin 写道:

I wrote:


I'll push new version for CI run later today, and if it passes, I'll send it to 
the list.


Most of CI passes except one issue when compiling winpthreads with clang; see https://github.com/ 
maiddaisuki/mingw-w64/actions/runs/34466771691/job/102837072791 .


Using `RTL_SIZEOF_THROUGH_FIELD` for allocation size results in a -Walloc-size diagnostic from clang; we 
should be able to silence it with a pragma.


Try this without a union, which is rather COM-ish:

   struct WinpthreadsMutexBase
   {
 const WinpthreadsMutexVtable *vtable;
   };

   struct WinpthreadsNormalMutex
   {
 const WinpthreadsMutexVtable *vtable;
 HANDLE Event;
 LONG LockState;
   };

   struct WinpthreadsErrorCheckMutex
   {
 const WinpthreadsMutexVtable *vtable;
 HANDLE Event;
 LONG LockState;
 DWORD Owner;
   };


And, does the recursive mutex really require a 64-bit recursion count? A 32-bit 
count is usually sufficient.


--
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


Re: [Mingw-w64-public] winpthreads: update mutex implementation [V2]

2026-09-10 Thread Kirill Makurin
LIU Hao wrote:

> 在 2026-9-9 19:11, Kirill Makurin 写道:
>> I really don't like dealing with code like this:
>>
>> 1. We will "signal" before second thread calls `pthread_mutex_lock` again, 
>> the one which deadlocks
>> 2. Once "signaled", main thread calls `pthread_mutex_unlock` so that second 
>> thread can grab lock again
>> and continue execution
>>
>> It is possible, though unlikely, that main will unlock the mutex before 
>> second thread deadlocks by
>> entering the wait state; that would result in a deadlock in main. I wrote 
>> code that accounts for it, that
>> is no problem, although I don't like how unnecessary messier it gets.
>>
>> I thought maybe it would be acceptable to simply return 77 (report test as 
>> skipped), instead of
>> assert'ing, if call to `pthread_mutex_trylock` does not return EBUSY? I did 
>> not see original version to
>> assert in either local testing or CI.
>
> How about this?
>
> while (pthread_mutex_trylock (&mutex) == 0) {
>   pthread_mutex_unlock (&mutex);
>   Sleep(100);
>}

I'll go with my change for now. I'll push new version for CI run later today, 
and if it passes, I'll send it to the list.

- Kirill Makurin

___
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] winpthreads: update mutex implementation [V2]

2026-09-09 Thread LIU Hao

在 2026-9-9 19:11, Kirill Makurin 写道:

I really don't like dealing with code like this:

1. We will "signal" before second thread calls `pthread_mutex_lock` again, the 
one which deadlocks
2. Once "signaled", main thread calls `pthread_mutex_unlock` so that second thread can grab lock again 
and continue execution


It is possible, though unlikely, that main will unlock the mutex before second thread deadlocks by 
entering the wait state; that would result in a deadlock in main. I wrote code that accounts for it, that 
is no problem, although I don't like how unnecessary messier it gets.


I thought maybe it would be acceptable to simply return 77 (report test as skipped), instead of 
assert'ing, if call to `pthread_mutex_trylock` does not return EBUSY? I did not see original version to 
assert in either local testing or CI.


How about this?

   while (pthread_mutex_trylock (&mutex) == 0) {
 pthread_mutex_unlock (&mutex);
 Sleep(100);
   }


--
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


Re: [Mingw-w64-public] winpthreads: update mutex implementation [V2]

2026-09-09 Thread Kirill Makurin
LIU Hao wrote:

>>  > 0023 has this:
>>  >
>>  > assert(pthread_create(&thread, NULL, ThreadA, &mutex) == 0);
>>  > Sleep(100);
>>  > /**
>>  >  * Ensure we do not dead lock if thread did not lock mutex fast 
>> enough.
>>  >  */
>>  > assert(pthread_mutex_trylock(&mutex) == EBUSY);
>>  >
>>  > I think this is a bit fragile; you can use a barrier here.
>>
>> Yeah, I had mixing feeling about this. Will it be ok to loop with 
>> `InterlockedExchange` in main until
>> thread sets a variable? I hesitate to use `pthread_barrier_t` because its 
>> implementation uses
>> `pthread_mutex_t`, so it would be a bit awkward.
>
> Right; probably you want a Windows event which will be set after the child 
> thread has acquired the mutex.

I really don't like dealing with code like this:

1. We will "signal" before second thread calls `pthread_mutex_lock` again, the 
one which deadlocks
2. Once "signaled", main thread calls `pthread_mutex_unlock` so that second 
thread can grab lock again and continue execution

It is possible, though unlikely, that main will unlock the mutex before second 
thread deadlocks by entering the wait state; that would result in a deadlock in 
main. I wrote code that accounts for it, that is no problem, although I don't 
like how unnecessary messier it gets.

I thought maybe it would be acceptable to simply return 77 (report test as 
skipped), instead of assert'ing, if call to `pthread_mutex_trylock` does not 
return EBUSY? I did not see original version to assert in either local testing 
or CI.

- Kirill Makurin

___
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] winpthreads: update mutex implementation [V2]

2026-09-09 Thread Kirill Makurin
LIU Hao wrote:

> 在 2026-9-9 00:06, Kirill Makurin 写道:
>> However, if you insist on keeping tests for `pthread_mutexattr_gettype` for 
>> now, I can change 0019.txt,
>> 0020.txt and 0021.txt to preserve it. What you say?
>
> It should be preferred to keep existing tests.

I think my reason for removing these `pthread_mutexattr_gettype` check was to 
make general logic in all tests as similar as possible, and other tests which 
use `pthread_mutexattr_settype` did not call `pthread_mutexattr_gettype`.

Worth to mention that some tests still use static initializer instead of 
calling `pthread_mutex_init`. The mutex3*.c tests are an example.

- Kirill Makurin

___
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] winpthreads: update mutex implementation [V2]

2026-09-08 Thread LIU Hao

在 2026-9-9 00:06, Kirill Makurin 写道:

 > 0019, 0020, 0021 delete tests for `pthread_mutexattr_gettype()`.

I mentioned that I want to add support for POSIX robust mutexes next, and this would require adding 
`pthread_mutexattr_{set,get}robust`. As a preparation step, I want to update `pthread_mutexattr_*` 
functions and add tests for each of them.


However, if you insist on keeping tests for `pthread_mutexattr_gettype` for now, I can change 0019.txt, 
0020.txt and 0021.txt to preserve it. What you say?


It should be preferred to keep existing tests.



 > 0023 has this:
 >
 >     assert(pthread_create(&thread, NULL, ThreadA, &mutex) == 0);
 >     Sleep(100);
 >     /**
 >      * Ensure we do not dead lock if thread did not lock mutex fast enough.
 >      */
 >     assert(pthread_mutex_trylock(&mutex) == EBUSY);
 >
 > I think this is a bit fragile; you can use a barrier here.

Yeah, I had mixing feeling about this. Will it be ok to loop with `InterlockedExchange` in main until 
thread sets a variable? I hesitate to use `pthread_barrier_t` because its implementation uses 
`pthread_mutex_t`, so it would be a bit awkward.


Right; probably you want a Windows event which will be set after the child 
thread has acquired the mutex.




--
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


Re: [Mingw-w64-public] winpthreads: update mutex implementation [V2]

2026-09-08 Thread Kirill Makurin
LIU Hao wrote:

> 0010:
>
> If I understand correctly, `WinpthreadsMutexImpl` is a vtable, so maybe 
> `WinpthreadsMutexVtable` is a
> better name? `xxImpl` reminds me about a derived class.

Sure, I don't mind changing the name. I wasn't sure what naming convention to 
stick to, so I chose one similar to one I use in my posix32 library.

> And the union of pointers in `WinpthreadsMutex` makes less sense now; the 
> overhead and complexity of an
> extra allocation may cancel any benefits of a union. How about
>
> ```
> struct WinpthreadsMutex {
>   const WinpthreadsMutexVtable *Vtable;
>   union {
> WinpthreadsNormalMutex Normal;
> WinpthreadsErrorCheckMutex ErrorCheck;
> WinpthreadsRecursiveMutex Recursive;
>   } Mutex;
> };
>
> // ...
> WinpthreadsRecursiveMutex *mutex = malloc (
> RTL_SIZEOF_THROUGH_FIELD (WinpthreadsRecursiveMutex, Recursive));
>
>```

I just learnt something new! That's a very clever approach. I'll send updated 
version.

> 0019, 0020, 0021 delete tests for `pthread_mutexattr_gettype()`.

I mentioned that I want to add support for POSIX robust mutexes next, and this 
would require adding `pthread_mutexattr_{set,get}robust`. As a preparation 
step, I want to update `pthread_mutexattr_*` functions and add tests for each 
of them.

However, if you insist on keeping tests for `pthread_mutexattr_gettype` for 
now, I can change 0019.txt, 0020.txt and 0021.txt to preserve it. What you say?

> 0023 has this:
>
> assert(pthread_create(&thread, NULL, ThreadA, &mutex) == 0);
> Sleep(100);
> /**
>  * Ensure we do not dead lock if thread did not lock mutex fast enough.
>  */
> assert(pthread_mutex_trylock(&mutex) == EBUSY);
>
> I think this is a bit fragile; you can use a barrier here.

Yeah, I had mixing feeling about this. Will it be ok to loop with 
`InterlockedExchange` in main until thread sets a variable? I hesitate to use 
`pthread_barrier_t` because its implementation uses `pthread_mutex_t`, so it 
would be a bit awkward.

- Kirill Makurin

___
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] winpthreads: update mutex implementation [V2]

2026-09-08 Thread LIU Hao

在 2026-9-6 21:27, Kirill Makurin 写道:

Hello,

This is updated version of the mutex changes.
GitHub CI run: https://github.com/maiddaisuki/mingw-w64/actions/runs/34029615558 


The changes are:

- patch "winpthreads: mutex.c: simplify `pthread_mutex_*lock` functions'" was 
dropped
- patch "winpthreads: mutex.c: improve `pthread_mutex_destroy`" was updated
- patch "winpthreads: mutex.c: refactor implementation" was updated


0010:

If I understand correctly, `WinpthreadsMutexImpl` is a vtable, so maybe `WinpthreadsMutexVtable` is a 
better name? `xxImpl` reminds me about a derived class.


And the union of pointers in `WinpthreadsMutex` makes less sense now; the overhead and complexity of an 
extra allocation may cancel any benefits of a union. How about


   ```
   struct WinpthreadsMutex {
 const WinpthreadsMutexVtable *Vtable;
 union {
   WinpthreadsNormalMutex Normal;
   WinpthreadsErrorCheckMutex ErrorCheck;
   WinpthreadsRecursiveMutex Recursive;
 } Mutex;
   };

   // ...
   WinpthreadsRecursiveMutex *mutex = malloc (
   RTL_SIZEOF_THROUGH_FIELD (WinpthreadsRecursiveMutex, Recursive));

   ```

---

0019, 0020, 0021 delete tests for `pthread_mutexattr_gettype()`.

---

0023 has this:

   assert(pthread_create(&thread, NULL, ThreadA, &mutex) == 0);
   Sleep(100);
   /**
* Ensure we do not dead lock if thread did not lock mutex fast enough.
*/
   assert(pthread_mutex_trylock(&mutex) == EBUSY);

I think this is a bit fragile; you can use a barrier here.


--
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


Re: [Mingw-w64-public] winpthreads: update mutex implementation

2026-09-04 Thread Kirill Makurin
LIU Hao wrote:

> 在 2026-9-5 07:20, Kirill Makurin 写道:
>> This change was one of my biggest concerns and I mentioned it in my original 
>> email. Do we want to have
>> fast paths for all mutex types or only normal mutexes?
>
> There should fast paths for all of them.
>
>> I see two ways to move forward:
>>
>> 1. I drop changes from 09/24, and in updated 11/24, each `Winpthraads*Lock` 
>> function (or, perhaps only
>> implementation for normal mutexes) will contain the fast path.
>> 2. I keep 09/24 as-is as an intermediate change, and introduce fast path 
>> back in 11/24.
>>
>> The first one probably makes more sense.
>
> Yes.

Ok. I'll send new version of changes in coming days.

>> Are there any other issues with these patches, and most
>> importantly 0011.txt?
>
> It probably makes little sense to have a union in `WinpthreadsMutex`; you can 
> always allocate all fields
> in one structure, and ignore unused ones.

Note that in future we might need to implement more mutex types (e.g. robust 
POSIX mutexes), which may or may not require extra fields. Given that now logic 
for each mutex type is moved to a separate function, I think having a structure 
for each mutex type goes well along with the change. A minor, but somewhat 
speculative benefit, is that normal mutexes now will require slightly less heap 
memory than other mutex types.

- Kirill Makurin

___
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] winpthreads: update mutex implementation

2026-09-04 Thread LIU Hao

在 2026-9-5 07:20, Kirill Makurin 写道:
This change was one of my biggest concerns and I mentioned it in my original email. Do we want to have 
fast paths for all mutex types or only normal mutexes?


There should fast paths for all of them.



I see two ways to move forward:

1. I drop changes from 09/24, and in updated 11/24, each `Winpthraads*Lock` function (or, perhaps only 
implementation for normal mutexes) will contain the fast path.

2. I keep 09/24 as-is as an intermediate change, and introduce fast path back 
in 11/24.

The first one probably makes more sense.


Yes.


Are there any other issues with these patches, and most 
importantly 0011.txt?


It probably makes little sense to have a union in `WinpthreadsMutex`; you can always allocate all fields 
in one structure, and ignore unused ones.




--
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


Re: [Mingw-w64-public] winpthreads: update mutex implementation

2026-09-04 Thread Kirill Makurin
LIU Hao wrote:

>在 2026-9-3 14:23, Kirill Makurin 写道:
>>  >   /**
>>  >* Obtain pointer to `WinpthreadsMutex` structure pointed to by `m`.
>>  >*
>>  > - * If `m` points to statically initialzied `pthread_mutex_t` object,
>>  > + * If `m` points to statically initialized `pthread_mutex_t` object,
>>  >* allocate `WinpthreadsMutex` structure and store its address in `*m`.
>>  >*
>>  >* On success, stores pointer to `WinpthreadsMutex` structure in 
>> `*wMutex`.
>>
>> This one and other typos are also nice catches.
>>
>> Will you be able to apply them on top of commits where they seem appropriate?
>
> In '[PATCH 09/24] winpthreads: mutex.c: simplify `pthread_mutex_*lock` 
> functions' and '[PATCH 11/24]
> winpthreads: mutex.c: refactor implementation', I see that for normal mutexes 
> there's no longer a fast
> path and now `_pthread_wait_for_single_object()` is always called which leads 
> to a syscall. That is a
> severe performance regression and is unacceptable; see attached figure.

This change was one of my biggest concerns and I mentioned it in my original 
email. Do we want to have fast paths for all mutex types or only normal mutexes?

I see two ways to move forward:

1. I drop changes from 09/24, and in updated 11/24, each `Winpthraads*Lock` 
function (or, perhaps only implementation for normal mutexes) will contain the 
fast path.
2. I keep 09/24 as-is as an intermediate change, and introduce fast path back 
in 11/24.

The first one probably makes more sense. Are there any other issues with these 
patches, and most importantly 0011.txt?

- Kirill Makurin

___
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] winpthreads: update mutex implementation

2026-09-03 Thread LIU Hao

在 2026-9-3 14:23, Kirill Makurin 写道:

 >   /**
 >    * Obtain pointer to `WinpthreadsMutex` structure pointed to by `m`.
 >    *
 > - * If `m` points to statically initialzied `pthread_mutex_t` object,
 > + * If `m` points to statically initialized `pthread_mutex_t` object,
 >    * allocate `WinpthreadsMutex` structure and store its address in `*m`.
 >    *
 >    * On success, stores pointer to `WinpthreadsMutex` structure in `*wMutex`.

This one and other typos are also nice catches.

Will you be able to apply them on top of commits where they seem appropriate?



In '[PATCH 09/24] winpthreads: mutex.c: simplify `pthread_mutex_*lock` functions' and '[PATCH 11/24] 
winpthreads: mutex.c: refactor implementation', I see that for normal mutexes there's no longer a fast 
path and now `_pthread_wait_for_single_object()` is always called which leads to a syscall. That is a 
severe performance regression and is unacceptable; see attached figure.



--
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


Re: [Mingw-w64-public] winpthreads: update mutex implementation

2026-09-02 Thread Kirill Makurin
LIU Hao wrote:

> 在 2026-9-2 18:31, Kirill Makurin 写道:
>> Hello, I would like to remind about these patches.
>>
>
> I'll take a look later.

Thanks!

> For the time being, Claude Sonnet 5 suggests these changes:
>
>   HANDLE event = InterlockedExchangePointer ((void **) &mutex->Event, 
> NULL);
>
>   if (event != NULL) {
> -  CloseHandle (mutex->Event);
> +  CloseHandle (event);
>   }
>
>   free (mutex);

This is a nice catch! I originally passed `mutex->Event`, but they decided it 
would be a good idea to atomically invalidate `mutex->Event` (this avoid vert 
unlikely case when the same event handle is passed twice to `CloseHandle`), and 
in a few cases I forgot to update calls to `CloseHandle`.

>   /**
>* Obtain pointer to `WinpthreadsMutex` structure pointed to by `m`.
>*
> - * If `m` points to statically initialzied `pthread_mutex_t` object,
> + * If `m` points to statically initialized `pthread_mutex_t` object,
>* allocate `WinpthreadsMutex` structure and store its address in `*m`.
>*
>* On success, stores pointer to `WinpthreadsMutex` structure in `*wMutex`.

This one and other typos are also nice catches.

Will you be able to apply them on top of commits where they seem appropriate?

- Kirill Makurin

___
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] winpthreads: update mutex implementation

2026-09-02 Thread LIU Hao

在 2026-9-2 18:31, Kirill Makurin 写道:

Hello, I would like to remind about these patches.



I'll take a look later. For the time being, Claude Sonnet 5 suggests these 
changes:


diff --git a/mingw-w64-libraries/winpthreads/src/mutex.c 
b/mingw-w64-libraries/winpthreads/src/mutex.c
index 042c3879d..891ba5506 100644
--- a/mingw-w64-libraries/winpthreads/src/mutex.c
+++ b/mingw-w64-libraries/winpthreads/src/mutex.c
@@ -348,7 +351,7 @@ static void WinpthreadsErrorCheckMutexDestroy 
(WinpthreadsMutex *wMutex) {
 HANDLE event = InterlockedExchangePointer ((void **) &mutex->Event, NULL);

 if (event != NULL) {
-  CloseHandle (mutex->Event);
+  CloseHandle (event);
 }

 free (mutex);
@@ -476,7 +481,7 @@ static void WinpthreadsRecursiveMutexDestroy 
(WinpthreadsMutex *wMutex) {
 HANDLE event = InterlockedExchangePointer ((void **) &mutex->Event, NULL);

 if (event != NULL) {
-  CloseHandle (mutex->Event);
+  CloseHandle (event);
 }

 free (mutex);
@@ -608,7 +613,7 @@ static const WinpthreadsMutexImpl 
WinpthreadsRecursiveMutexImpl = {
 /**
  * Obtain pointer to `WinpthreadsMutex` structure pointed to by `m`.
  *
- * If `m` points to statically initialzied `pthread_mutex_t` object,
+ * If `m` points to statically initialized `pthread_mutex_t` object,
  * allocate `WinpthreadsMutex` structure and store its address in `*m`.
  *
  * On success, stores pointer to `WinpthreadsMutex` structure in `*wMutex`.
@@ -728,7 +733,7 @@ int pthread_mutex_timedlock64(pthread_mutex_t *m, const 
struct _timespec64 *ts)
  */
 case 0:
 /**
- * An unexpected error has occured.
+ * An unexpected error has occurred.
  */
 default:
   return error_code;
diff --git a/mingw-w64-libraries/winpthreads/tests/pthread_mutex/default-trylock-recursive.c 
b/mingw-w64-libraries/winpthreads/tests/pthread_mutex/default-trylock-recursive.c

index 970569ef6..a11ee5b45 100644
--- 
a/mingw-w64-libraries/winpthreads/tests/pthread_mutex/default-trylock-recursive.c
+++ 
b/mingw-w64-libraries/winpthreads/tests/pthread_mutex/default-trylock-recursive.c
@@ -37,7 +37,7 @@
  *
  * Thread A locks L.
  *
- * Thread A attmpts to lock L again; the call to `pthread_mutex_trylock` must
+ * Thread A attempts to lock L again; the call to `pthread_mutex_trylock` must
  * fail with EBUSY.
  *
  * Thread A unlocks L.
diff --git a/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-trylock-recursive.c 
b/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-trylock-recursive.c

index 24e5fa445..3cc7f3c1f 100644
--- 
a/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-trylock-recursive.c
+++ 
b/mingw-w64-libraries/winpthreads/tests/pthread_mutex/errorcheck-trylock-recursive.c
@@ -37,7 +37,7 @@
  *
  * Thread A locks L.
  *
- * Thread A attmpts to lock L again; the call to `pthread_mutex_trylock` must
+ * Thread A attempts to lock L again; the call to `pthread_mutex_trylock` must
  * fail with EBUSY.
  *
  * Thread A unlocks L.
diff --git a/mingw-w64-libraries/winpthreads/tests/pthread_mutex/normal-trylock-recursive.c 
b/mingw-w64-libraries/winpthreads/tests/pthread_mutex/normal-trylock-recursive.c

index 92b6f192e..79cc085b2 100644
--- 
a/mingw-w64-libraries/winpthreads/tests/pthread_mutex/normal-trylock-recursive.c
+++ 
b/mingw-w64-libraries/winpthreads/tests/pthread_mutex/normal-trylock-recursive.c
@@ -37,7 +37,7 @@
  *
  * Thread A locks L.
  *
- * Thread A attmpts to lock L again; the call to `pthread_mutex_trylock` must
+ * Thread A attempts to lock L again; the call to `pthread_mutex_trylock` must
  * fail with EBUSY.
  *
  * Thread A unlocks L.
diff --git a/mingw-w64-libraries/winpthreads/tests/pthread_mutex/recursive-trylock-recursive.c 
b/mingw-w64-libraries/winpthreads/tests/pthread_mutex/recursive-trylock-recursive.c

index 1fdd16078..5a4b7ef32 100644
--- 
a/mingw-w64-libraries/winpthreads/tests/pthread_mutex/recursive-trylock-recursive.c
+++ 
b/mingw-w64-libraries/winpthreads/tests/pthread_mutex/recursive-trylock-recursive.c
@@ -37,7 +37,7 @@
  *
  * Thread A locks L.
  *
- * Thread A attmpts to lock L again; the call to `pthread_mutex_trylock` must
+ * Thread A attempts to lock L again; the call to `pthread_mutex_trylock` must
  * succeed.
  *
  * Thread A unlocks L.





--
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


Re: [Mingw-w64-public] winpthreads: update mutex implementation

2026-09-02 Thread Kirill Makurin
Hello, I would like to remind about these patches.

- Kirill Makurin

___
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public