c11: Remove mtx_try from mtx enums as it's not a part of c11 standard

And we support for four types of mtx init enum values that define by C11 standard:
0 mtx_plain - a simple, non-recursive mutex is created.
2 mtx_timed - a non-recursive mutex, that supports timeout, is created.
1 mtx_plain | mtx_recursive - a recursive mutex is created.
3 mtx_timed | mtx_recursive - a recursive mutex, that supports timeout, is created.

musl library also use these enum combination

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18036>
This commit is contained in:
Yonggang Luo 2022-08-13 00:41:33 +08:00 committed by Marge Bot
parent 7b9d3ebe42
commit 4579b702f6
3 changed files with 5 additions and 8 deletions

View file

@ -177,10 +177,9 @@ mtx_init(mtx_t *mtx, int type)
{
pthread_mutexattr_t attr;
assert(mtx != NULL);
if (type != mtx_plain && type != mtx_timed && type != mtx_try
if (type != mtx_plain && type != mtx_timed
&& type != (mtx_plain|mtx_recursive)
&& type != (mtx_timed|mtx_recursive)
&& type != (mtx_try|mtx_recursive))
&& type != (mtx_timed|mtx_recursive))
return thrd_error;
if ((type & mtx_recursive) == 0) {

View file

@ -266,10 +266,9 @@ int
mtx_init(mtx_t *mtx, int type)
{
assert(mtx != NULL);
if (type != mtx_plain && type != mtx_timed && type != mtx_try
if (type != mtx_plain && type != mtx_timed
&& type != (mtx_plain|mtx_recursive)
&& type != (mtx_timed|mtx_recursive)
&& type != (mtx_try|mtx_recursive))
&& type != (mtx_timed|mtx_recursive))
return thrd_error;
InitializeCriticalSection((PCRITICAL_SECTION)mtx);
return thrd_success;

View file

@ -133,9 +133,8 @@ typedef pthread_once_t once_flag;
enum
{
mtx_plain = 0,
mtx_try = 1,
mtx_recursive = 1,
mtx_timed = 2,
mtx_recursive = 4
};
enum