Ian Romanick wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Chia-I Wu wrote:
>> There is a possbile race that _glapi_Context is reset by another thread
>> after it is tested in GET_CURRENT_CONTEXT but before it is returned.  To
>> avoid the race in a lockless fashion, no threads should reset
>> _glapi_Context (or _glapi_Dispatch).
>>
>> This patch renames ThreadSafe to _glapi_ThreadSafe and makes it global
>> so that it can be tested for thread-safe mode.  This also removes a
>> __builtin_expect so that multithreaded apps are not punished.
>> ---
>>  src/mesa/glapi/glapi.c    |   32 ++++++++++++++++----------------
>>  src/mesa/glapi/glapi.h    |    3 ++-
>>  src/mesa/glapi/glthread.h |    2 +-
>>  3 files changed, 19 insertions(+), 18 deletions(-)
>>
>> diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c
>> index b9ab9c0..b05f80c 100644
>> --- a/src/mesa/glapi/glapi.c
>> +++ b/src/mesa/glapi/glapi.c
>> @@ -172,8 +172,8 @@ static GLint NoOpUnused(void)
>>   * There is a race condition in setting \c _glapi_Dispatch to \c NULL.  It 
>> is
>>   * possible for the original thread to be setting it at the same instant a 
>> new
>>   * thread, perhaps running on a different processor, is clearing it.  
>> Because
>> - * of that, \c ThreadSafe, which can only ever be changed to \c GL_TRUE, is
>> - * used to determine whether or not the application is multithreaded.
>> + * of that, \c _glapi_ThreadSafe, which can only ever be changed to \c 
>> GL_TRUE,
>> + * is used to determine whether or not the application is multithreaded.
>>   * 
>>   * In the TLS case, the variables \c _glapi_Dispatch and \c _glapi_Context 
>> are
>>   * hardcoded to \c NULL.  Instead the TLS variables \c _glapi_tls_Dispatch 
>> and
>> @@ -199,7 +199,7 @@ PUBLIC const void *_glapi_Context = NULL;
>>  #if defined(THREADS)
>>  
>>  _glthread_DECLARE_STATIC_MUTEX(ThreadCheckMutex);
>> -static GLboolean ThreadSafe = GL_FALSE;  /**< In thread-safe mode? */
>> +GLboolean _glapi_ThreadSafe = GL_FALSE;  /**< In thread-safe mode? */
> 
> I've never been a fan of this variable name.  Unless Brian objects, I'd
> like to see this changed to _glapi_SingleThreaded or something similar.
>  That makes the real meaning a bit more clear, I think.  Also, shouldn't
> this be declared volatile?  (I'm not 100% sure one way or the other.)

I'm OK with changing the name.

-Brian

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to