4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-24 16:07:19 +08:00
Jon Turney 736618054c
Cygwin: testsuite: Update mutex tests for changed default mutex type
Default mutex type is PTHREAD_MUTEX_NORMAL.

Attempting to unlock an unowned mutex of that type is specified as
undefined behaviour, not returning EPERM.

mutex7e verfies that attempting to unlock an unowned mutex of type
PTHREAD_MUTEX_ERRORCHECK returns EPERM.
2023-01-13 17:03:56 +00:00

31 lines
698 B
C

/*
* mutex5.c
*
* Confirm the equality/inequality of the various mutex types,
* and the default not-set value.
*/
#include "test.h"
static pthread_mutexattr_t mxAttr;
int
main()
{
int mxType = -1;
int success = 0; /* Use to quell GNU compiler warnings. */
assert(success = PTHREAD_MUTEX_DEFAULT == PTHREAD_MUTEX_NORMAL);
assert(success = PTHREAD_MUTEX_DEFAULT != PTHREAD_MUTEX_RECURSIVE);
assert(success = PTHREAD_MUTEX_RECURSIVE != PTHREAD_MUTEX_ERRORCHECK);
if (success == success)
{
assert(pthread_mutexattr_init(&mxAttr) == 0);
assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0);
assert(mxType == PTHREAD_MUTEX_NORMAL);
}
return 0;
}