mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-18 12:30:47 +02:00
c11/threads: create mutexattrs only when needed
If the mutexattrs are the default one can just pass NULL to pthread_mutex_init. As the compiler does not know this detail it unnecessarily creates/destroys the attrs. Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
This commit is contained in:
parent
4424bf5da4
commit
6ce11e7e2c
1 changed files with 7 additions and 2 deletions
|
|
@ -180,9 +180,14 @@ mtx_init(mtx_t *mtx, int type)
|
|||
&& type != (mtx_timed|mtx_recursive)
|
||||
&& type != (mtx_try|mtx_recursive))
|
||||
return thrd_error;
|
||||
|
||||
if ((type & mtx_recursive) == 0) {
|
||||
pthread_mutex_init(mtx, NULL);
|
||||
return thrd_success;
|
||||
}
|
||||
|
||||
pthread_mutexattr_init(&attr);
|
||||
if ((type & mtx_recursive) != 0)
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
pthread_mutex_init(mtx, &attr);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
return thrd_success;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue