Module: Mesa
Branch: main
Commit: 4579b702f672f265819fd59304695f17c5d6730f
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4579b702f672f265819fd59304695f17c5d6730f

Author: Yonggang Luo <[email protected]>
Date:   Sat Aug 13 00:41:33 2022 +0800

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 <[email protected]>
Reviewed-by: Jesse Natalie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18036>

---

 src/c11/impl/threads_posix.c | 5 ++---
 src/c11/impl/threads_win32.c | 5 ++---
 src/c11/threads.h            | 3 +--
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/c11/impl/threads_posix.c b/src/c11/impl/threads_posix.c
index 736fc587be2..f8ebbab5cec 100644
--- a/src/c11/impl/threads_posix.c
+++ b/src/c11/impl/threads_posix.c
@@ -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) {
diff --git a/src/c11/impl/threads_win32.c b/src/c11/impl/threads_win32.c
index 67aa29e48ac..af2add0839f 100644
--- a/src/c11/impl/threads_win32.c
+++ b/src/c11/impl/threads_win32.c
@@ -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;
diff --git a/src/c11/threads.h b/src/c11/threads.h
index ac6902f3b02..c091d22b5bc 100644
--- a/src/c11/threads.h
+++ b/src/c11/threads.h
@@ -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

Reply via email to