Depending on whether or not multithreading is support, and the type of support available, several variables are used to store the current context pointer and the current dispatch table pointer. In the non-threaded case, the variables _glapi_Dispatch and _glapi_Context are used for this purpose.
In the "normal" threaded case, the variables _glapi_Dispatch and _glapi_Context will be NULL if an application is detected as being multithreaded. Single-threaded applications will use _glapi_Dispatch and _glapi_Context just like the case without any threading support. When _glapi_Dispatch and _glapi_Context are NULL, the thread state data _gl_DispatchTSD and ContextTSD are used. Drivers and the static dispatch functions access these variables via _glapi_get_dispatch and _glapi_get_context.
There is a race condition in setting _glapi_Dispatch to 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, ThreadSafe, which can only ever be changed to GL_TRUE, is used to determine whether or not the application is multithreaded.
In the TLS case, the variables _glapi_Dispatch and _glapi_Context are hardcoded to NULL. Instead the TLS variables _glapi_tls_Dispatch and _glapi_tls_Context are used. Having _glapi_Dispatch and _glapi_Context be hardcoded to NULL maintains binary compatability between TLS enabled loaders and non-TLS DRI drivers.