winpthreads: tests: fix pthread_mutex/mutex{4,7,7n}.c
POSIX[1] states that calling `pthread_mutex_unlock` on mutex of type
`PTHREAD_MUTEX_NORMAL` that is not owned by the calling thread is
undefined behavior.
An unlocked mutex fits into this category; it has no owner which means that
the calling thread does not own it.
With current, event-based implementation, `pthread_mutex_unlock` does not check
ownership for mutexes of type `PTHREAD_MUTEX_NORMAL`; this has effect that
`pthread_mutex_unlock` always succeeds as long as passed `pthread_mutex_t`
object is a valid mutex of type `PTHREAD_MUTEX_NORMAL`.
Tests mutex{4,7,7n}.c call `pthread_mutex_unlock` on an unlocked mutex of type
`PTHREAD_MUTEX_NORMAL`; they falied as they expected the old behavior, when
`pthread_mutex_unlock` would fail with `EPERM` in such case.
Update tests mutex{4,7,7n}.c to keep up with the current behavior and document
that we test winpthreads-specific behavior for a case when POSIX explicitly
specifies undefined behavior.
[1] https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/pthread_mutex_lock.html
Signed-off-by: Kirill Makurin <maiddaisuki@outlook.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
4 files changed