[Mesa-dev] [PATCH 2/2] glapi: remove u_mutex wrapper code, use c99 thread mutexes directly

Brian Paul brianp at vmware.com
Thu Mar 6 07:03:23 PST 2014


On 03/05/2014 08:37 PM, Chia-I Wu wrote:
> On Thu, Mar 6, 2014 at 7:06 AM, Brian Paul <brianp at vmware.com> wrote:
>> ---
>>   src/mapi/mapi.c      |   10 +++++-----
>>   src/mapi/stub.c      |    6 +++---
>>   src/mapi/u_current.c |    6 +++---
>>   src/mapi/u_execmem.c |    6 +++---
>>   src/mapi/u_thread.h  |   10 ----------
>>   5 files changed, 14 insertions(+), 24 deletions(-)
>>
>> diff --git a/src/mapi/mapi.c b/src/mapi/mapi.c
>> index 56f209b..8d0baca 100644
>> --- a/src/mapi/mapi.c
>> +++ b/src/mapi/mapi.c
>> @@ -72,15 +72,15 @@ get_stub(const char *name, const struct mapi_stub *alias)
>>   void
>>   mapi_init(const char *spec)
>>   {
>> -   u_mutex_declare_static(mutex);
>> +   static mtx_t mutex = _MTX_INITIALIZER_NP;
>>      const char *p;
>>      int ver, count;
>>
>> -   u_mutex_lock(mutex);
>> +   mtx_lock(&mutex);
>>
>>      /* already initialized */
>>      if (mapi_num_stubs) {
>> -      u_mutex_unlock(mutex);
>> +      mtx_unlock(&mutex);
>>         return;
>>      }
>>
>> @@ -90,7 +90,7 @@ mapi_init(const char *spec)
>>      /* parse version string */
>>      ver = atoi(p);
>>      if (ver != 1) {
>> -      u_mutex_unlock(mutex);
>> +      mtx_unlock(&mutex);
>>         return;
>>      }
>>      p += strlen(p) + 1;
>> @@ -115,7 +115,7 @@ mapi_init(const char *spec)
>>
>>      mapi_num_stubs = count;
>>
>> -   u_mutex_unlock(mutex);
>> +   mtx_unlock(&mutex);
>>   }
>>
>>   /**
>> diff --git a/src/mapi/stub.c b/src/mapi/stub.c
>> index acd2c0a..b5db597 100644
>> --- a/src/mapi/stub.c
>> +++ b/src/mapi/stub.c
>> @@ -126,11 +126,11 @@ stub_add_dynamic(const char *name)
>>   struct mapi_stub *
>>   stub_find_dynamic(const char *name, int generate)
>>   {
>> -   u_mutex_declare_static(dynamic_mutex);
>> +   static mtx_t dynamic_mutex = _MTX_INITIALIZER_NP PTHREAD_MUTEX_INITIALIZER;
> PTHREAD_MUTEX_INITIALIZER should be dropped.  With that fixed,

Got it.  Thanks.  I guess this code didn't get compiled in my current 
configuration.  I'm still trying to figure out all the mapi/ code.  I 
don't yet understand the (four!) different mapi compile modes and when 
they're used.

-Brian



More information about the mesa-dev mailing list