aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mapi
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mapi')
-rw-r--r--mesalib/src/mapi/entry.c4
-rw-r--r--mesalib/src/mapi/glapi/gen/ARB_debug_output.xml8
-rw-r--r--mesalib/src/mapi/glapi/gen/GL4x.xml2
-rw-r--r--mesalib/src/mapi/glapi/gen/KHR_debug.xml150
-rwxr-xr-xmesalib/src/mapi/glapi/gen/gl_API.xml144
-rw-r--r--mesalib/src/mapi/glapi/glapi.c4
-rwxr-xr-x[-rw-r--r--]mesalib/src/mapi/glapi/glapi.h0
-rw-r--r--mesalib/src/mapi/mapi.c12
-rw-r--r--mesalib/src/mapi/mapi_glapi.c10
-rw-r--r--mesalib/src/mapi/stub.c6
-rw-r--r--mesalib/src/mapi/u_current.c44
-rw-r--r--mesalib/src/mapi/u_current.h30
-rw-r--r--mesalib/src/mapi/u_execmem.c6
-rw-r--r--mesalib/src/mapi/u_thread.h32
14 files changed, 231 insertions, 221 deletions
diff --git a/mesalib/src/mapi/entry.c b/mesalib/src/mapi/entry.c
index 128f0115d..b6e8db28d 100644
--- a/mesalib/src/mapi/entry.c
+++ b/mesalib/src/mapi/entry.c
@@ -36,7 +36,7 @@
#ifdef MAPI_MODE_BRIDGE
#define ENTRY_CURRENT_TABLE_GET "_glapi_get_dispatch"
#else
-#define ENTRY_CURRENT_TABLE_GET U_STRINGIFY(u_current_get_internal)
+#define ENTRY_CURRENT_TABLE_GET U_STRINGIFY(u_current_get_table_internal)
#endif
#if defined(USE_X86_ASM) && defined(__GNUC__)
@@ -57,7 +57,7 @@ entry_current_get(void)
#ifdef MAPI_MODE_BRIDGE
return GET_DISPATCH();
#else
- return u_current_get();
+ return u_current_get_table();
#endif
}
diff --git a/mesalib/src/mapi/glapi/gen/ARB_debug_output.xml b/mesalib/src/mapi/glapi/gen/ARB_debug_output.xml
index 11f268dc6..0468d570c 100644
--- a/mesalib/src/mapi/glapi/gen/ARB_debug_output.xml
+++ b/mesalib/src/mapi/glapi/gen/ARB_debug_output.xml
@@ -52,7 +52,7 @@
<enum name="DEBUG_SEVERITY_LOW_ARB" value="0x9148"/>
- <function name="DebugMessageControlARB" offset="assign">
+ <function name="DebugMessageControlARB" alias="DebugMessageControl">
<param name="source" type="GLenum"/>
<param name="type" type="GLenum"/>
<param name="severity" type="GLenum"/>
@@ -61,7 +61,7 @@
<param name="enabled" type="GLboolean"/>
</function>
- <function name="DebugMessageInsertARB" offset="assign">
+ <function name="DebugMessageInsertARB" alias="DebugMessageInsert">
<param name="source" type="GLenum"/>
<param name="type" type="GLenum"/>
<param name="id" type="GLuint"/>
@@ -70,12 +70,12 @@
<param name="buf" type="const GLcharARB *"/>
</function>
- <function name="DebugMessageCallbackARB" offset="assign">
+ <function name="DebugMessageCallbackARB" alias="DebugMessageCallback">
<param name="callback" type="GLDEBUGPROCARB"/>
<param name="userParam" type="const GLvoid *"/>
</function>
- <function name="GetDebugMessageLogARB" offset="assign">
+ <function name="GetDebugMessageLogARB" alias="GetDebugMessageLog">
<return type="GLuint"/>
<param name="count" type="GLuint"/>
<param name="bufsize" type="GLsizei"/>
diff --git a/mesalib/src/mapi/glapi/gen/GL4x.xml b/mesalib/src/mapi/glapi/gen/GL4x.xml
index 6706278ce..8efef0b91 100644
--- a/mesalib/src/mapi/glapi/gen/GL4x.xml
+++ b/mesalib/src/mapi/glapi/gen/GL4x.xml
@@ -15,7 +15,7 @@
</category>
<category name="4.3">
-
+ <enum name="DEPTH_STENCIL_TEXTURE_MODE" value="0x90EA"/>
</category>
</OpenGLAPI>
diff --git a/mesalib/src/mapi/glapi/gen/KHR_debug.xml b/mesalib/src/mapi/glapi/gen/KHR_debug.xml
new file mode 100644
index 000000000..48f7fa762
--- /dev/null
+++ b/mesalib/src/mapi/glapi/gen/KHR_debug.xml
@@ -0,0 +1,150 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<OpenGLAPI>
+
+<category name="GL_KHR_debug" number="119">
+ <enum name="DEBUG_OUTPUT" value="0x92E0"/>
+ <enum name="DEBUG_OUTPUT_SYNCHRONOUS" value="0x8242"/>
+
+ <enum name="CONTEXT_FLAG_DEBUG_BIT" value="0x00000002"/>
+
+ <enum name="MAX_DEBUG_MESSAGE_LENGTH" count="1" value="0x9143">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_DEBUG_LOGGED_MESSAGES" count="1" value="0x9144">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DEBUG_LOGGED_MESSAGES" count="1" value="0x9145">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DEBUG_NEXT_LOGGED_MESSAGE_LENGTH" count="1" value="0x8243">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_DEBUG_GROUP_STACK_DEPTH" count="1" value="0x826C">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DEBUG_GROUP_STACK_DEPTH" count="1" value="0x826D">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_LABEL_LENGTH" count="1" value="0x82E8">
+ <size name="Get" mode="get"/>
+ </enum>
+
+ <enum name="DEBUG_CALLBACK_FUNCTION" count="1" value="0x8244">
+ <size name="GetPointerv" mode="get"/>
+ </enum>
+ <enum name="DEBUG_CALLBACK_USER_PARAM" count="1" value="0x8245">
+ <size name="GetPointerv" mode="get"/>
+ </enum>
+
+ <enum name="DEBUG_SOURCE_API" value="0x8246"/>
+ <enum name="DEBUG_SOURCE_WINDOW_SYSTEM" value="0x8247"/>
+ <enum name="DEBUG_SOURCE_SHADER_COMPILER" value="0x8248"/>
+ <enum name="DEBUG_SOURCE_THIRD_PARTY" value="0x8249"/>
+ <enum name="DEBUG_SOURCE_APPLICATION" value="0x824A"/>
+ <enum name="DEBUG_SOURCE_OTHER" value="0x824B"/>
+
+ <enum name="DEBUG_TYPE_ERROR" value="0x824C"/>
+ <enum name="DEBUG_TYPE_DEPRECATED_BEHAVIOR" value="0x824D"/>
+ <enum name="DEBUG_TYPE_UNDEFINED_BEHAVIOR" value="0x824E"/>
+ <enum name="DEBUG_TYPE_PORTABILITY" value="0x824F"/>
+ <enum name="DEBUG_TYPE_PERFORMANCE" value="0x8250"/>
+ <enum name="DEBUG_TYPE_OTHER" value="0x8251"/>
+ <enum name="DEBUG_TYPE_MARKER" value="0x8268"/>
+
+ <enum name="DEBUG_TYPE_PUSH_GROUP" value="0x8269"/>
+ <enum name="DEBUG_TYPE_POP_GROUP" value="0x826A"/>
+
+ <enum name="DEBUG_SEVERITY_HIGH" value="0x9146"/>
+ <enum name="DEBUG_SEVERITY_MEDIUM" value="0x9147"/>
+ <enum name="DEBUG_SEVERITY_LOW" value="0x9148"/>
+ <enum name="DEBUG_SEVERITY_NOTIFICATION" value="0x826B"/>
+
+ <enum name="STACK_UNDERFLOW" value="0x0504"/>
+ <enum name="STACK_OVERFLOW" value="0x0503"/>
+
+ <enum name="BUFFER" value="0x82E0"/>
+ <enum name="SHADER" value="0x82E1"/>
+ <enum name="PROGRAM" value="0x82E2"/>
+ <enum name="QUERY" value="0x82E3"/>
+ <enum name="PROGRAM_PIPELINE" value="0x82E4"/>
+ <enum name="SAMPLER" value="0x82E6"/>
+ <!-- Compatibility Profile -->
+ <enum name="DISPLAY_LIST" value="0x82E7"/>
+
+ <function name="DebugMessageControl" offset="assign">
+ <param name="source" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="severity" type="GLenum"/>
+ <param name="count" type="GLsizei" counter="true"/>
+ <param name="ids" type="const GLuint *" count="count"/>
+ <param name="enabled" type="GLboolean"/>
+ </function>
+
+ <function name="DebugMessageInsert" offset="assign">
+ <param name="source" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="id" type="GLuint"/>
+ <param name="severity" type="GLenum"/>
+ <param name="length" type="GLsizei"/>
+ <param name="buf" type="const GLchar *"/>
+ </function>
+
+ <function name="DebugMessageCallback" offset="assign">
+ <param name="callback" type="GLDEBUGPROC"/>
+ <param name="userParam" type="const GLvoid *"/>
+ </function>
+
+ <function name="GetDebugMessageLog" offset="assign">
+ <return type="GLuint"/>
+ <param name="count" type="GLuint"/>
+ <param name="bufsize" type="GLsizei"/>
+ <param name="sources" type="GLenum *" output="true"/>
+ <param name="types" type="GLenum *" output="true"/>
+ <param name="ids" type="GLuint *" output="true"/>
+ <param name="severities" type="GLenum *" output="true"/>
+ <param name="lengths" type="GLsizei *" output="true"/>
+ <param name="messageLog" type="GLchar *" output="true"/>
+ </function>
+
+ <function name="PushDebugGroup" offset="assign">
+ <param name="source" type="GLenum"/>
+ <param name="id" type="GLuint"/>
+ <param name="length" type="GLsizei"/>
+ <param name="message" type="const GLchar *"/>
+ </function>
+
+ <function name="PopDebugGroup" offset="assign"/>
+
+ <function name="ObjectLabel" offset="assign">
+ <param name="identifier" type="GLenum"/>
+ <param name="name" type="GLuint"/>
+ <param name="length" type="GLsizei"/>
+ <param name="label" type="const GLchar *"/>
+ </function>
+
+ <function name="GetObjectLabel" offset="assign">
+ <param name="identifier" type="GLenum"/>
+ <param name="name" type="GLuint"/>
+ <param name="bufSize" type="GLsizei"/>
+ <param name="length" type="GLsizei *"/>
+ <param name="label" type="GLchar *"/>
+ </function>
+
+ <function name="ObjectPtrLabel" offset="assign">
+ <param name="ptr" type="const GLvoid *"/>
+ <param name="length" type="GLsizei"/>
+ <param name="label" type="const GLchar *"/>
+ </function>
+
+ <function name="GetObjectPtrLabel" offset="assign">
+ <param name="ptr" type="const GLvoid *"/>
+ <param name="bufSize" type="GLsizei"/>
+ <param name="length" type="GLsizei *"/>
+ <param name="label" type="GLchar *"/>
+ </function>
+
+</category>
+
+</OpenGLAPI>
diff --git a/mesalib/src/mapi/glapi/gen/gl_API.xml b/mesalib/src/mapi/glapi/gen/gl_API.xml
index 8f175e6be..6c4fb9506 100755
--- a/mesalib/src/mapi/glapi/gen/gl_API.xml
+++ b/mesalib/src/mapi/glapi/gen/gl_API.xml
@@ -8324,149 +8324,7 @@
<!-- ARB extension #118 -->
-<category name="GL_KHR_debug" number="119">
- <enum name="DEBUG_OUTPUT" value="0x92E0"/>
- <enum name="DEBUG_OUTPUT_SYNCHRONOUS" value="0x8242"/>
-
- <enum name="CONTEXT_FLAG_DEBUG_BIT" value="0x00000002"/>
-
- <enum name="MAX_DEBUG_MESSAGE_LENGTH" count="1" value="0x9143">
- <size name="Get" mode="get"/>
- </enum>
- <enum name="MAX_DEBUG_LOGGED_MESSAGES" count="1" value="0x9144">
- <size name="Get" mode="get"/>
- </enum>
- <enum name="DEBUG_LOGGED_MESSAGES" count="1" value="0x9145">
- <size name="Get" mode="get"/>
- </enum>
- <enum name="DEBUG_NEXT_LOGGED_MESSAGE_LENGTH" count="1" value="0x8243">
- <size name="Get" mode="get"/>
- </enum>
- <enum name="MAX_DEBUG_GROUP_STACK_DEPTH" count="1" value="0x826C">
- <size name="Get" mode="get"/>
- </enum>
- <enum name="DEBUG_GROUP_STACK_DEPTH" count="1" value="0x826D">
- <size name="Get" mode="get"/>
- </enum>
- <enum name="MAX_LABEL_LENGTH" count="1" value="0x82E8">
- <size name="Get" mode="get"/>
- </enum>
-
- <enum name="DEBUG_CALLBACK_FUNCTION" count="1" value="0x8244">
- <size name="GetPointerv" mode="get"/>
- </enum>
- <enum name="DEBUG_CALLBACK_USER_PARAM" count="1" value="0x8245">
- <size name="GetPointerv" mode="get"/>
- </enum>
-
- <enum name="DEBUG_SOURCE_API" value="0x8246"/>
- <enum name="DEBUG_SOURCE_WINDOW_SYSTEM" value="0x8247"/>
- <enum name="DEBUG_SOURCE_SHADER_COMPILER" value="0x8248"/>
- <enum name="DEBUG_SOURCE_THIRD_PARTY" value="0x8249"/>
- <enum name="DEBUG_SOURCE_APPLICATION" value="0x824A"/>
- <enum name="DEBUG_SOURCE_OTHER" value="0x824B"/>
-
- <enum name="DEBUG_TYPE_ERROR" value="0x824C"/>
- <enum name="DEBUG_TYPE_DEPRECATED_BEHAVIOR" value="0x824D"/>
- <enum name="DEBUG_TYPE_UNDEFINED_BEHAVIOR" value="0x824E"/>
- <enum name="DEBUG_TYPE_PORTABILITY" value="0x824F"/>
- <enum name="DEBUG_TYPE_PERFORMANCE" value="0x8250"/>
- <enum name="DEBUG_TYPE_OTHER" value="0x8251"/>
- <enum name="DEBUG_TYPE_MARKER" value="0x8268"/>
-
- <enum name="DEBUG_TYPE_PUSH_GROUP" value="0x8269"/>
- <enum name="DEBUG_TYPE_POP_GROUP" value="0x826A"/>
-
- <enum name="DEBUG_SEVERITY_HIGH" value="0x9146"/>
- <enum name="DEBUG_SEVERITY_MEDIUM" value="0x9147"/>
- <enum name="DEBUG_SEVERITY_LOW" value="0x9148"/>
- <enum name="DEBUG_SEVERITY_NOTIFICATION" value="0x826B"/>
-
- <enum name="STACK_UNDERFLOW" value="0x0504"/>
- <enum name="STACK_OVERFLOW" value="0x0503"/>
-
- <enum name="BUFFER" value="0x82E0"/>
- <enum name="SHADER" value="0x82E1"/>
- <enum name="PROGRAM" value="0x82E2"/>
- <enum name="QUERY" value="0x82E3"/>
- <enum name="PROGRAM_PIPELINE" value="0x82E4"/>
- <enum name="SAMPLER" value="0x82E6"/>
- <!-- Compatibility Profile -->
- <enum name="DISPLAY_LIST" value="0x82E7"/>
-
- <function name="DebugMessageControl" offset="assign">
- <param name="source" type="GLenum"/>
- <param name="type" type="GLenum"/>
- <param name="severity" type="GLenum"/>
- <param name="count" type="GLsizei" counter="true"/>
- <param name="ids" type="const GLuint *" count="count"/>
- <param name="enabled" type="GLboolean"/>
- </function>
-
- <function name="DebugMessageInsert" offset="assign">
- <param name="source" type="GLenum"/>
- <param name="type" type="GLenum"/>
- <param name="id" type="GLuint"/>
- <param name="severity" type="GLenum"/>
- <param name="length" type="GLsizei"/>
- <param name="buf" type="const GLchar *"/>
- </function>
-
- <function name="DebugMessageCallback" offset="assign">
- <param name="callback" type="GLDEBUGPROC"/>
- <param name="userParam" type="const GLvoid *"/>
- </function>
-
- <function name="GetDebugMessageLog" offset="assign">
- <return type="GLuint"/>
- <param name="count" type="GLuint"/>
- <param name="bufsize" type="GLsizei"/>
- <param name="sources" type="GLenum *" output="true"/>
- <param name="types" type="GLenum *" output="true"/>
- <param name="ids" type="GLuint *" output="true"/>
- <param name="severities" type="GLenum *" output="true"/>
- <param name="lengths" type="GLsizei *" output="true"/>
- <param name="messageLog" type="GLchar *" output="true"/>
- </function>
-
- <function name="PushDebugGroup" offset="assign">
- <param name="source" type="GLenum"/>
- <param name="id" type="GLuint"/>
- <param name="length" type="GLsizei"/>
- <param name="message" type="const GLchar *"/>
- </function>
-
- <function name="PopDebugGroup" offset="assign"/>
-
- <function name="ObjectLabel" offset="assign">
- <param name="identifier" type="GLenum"/>
- <param name="name" type="GLuint"/>
- <param name="length" type="GLsizei"/>
- <param name="label" type="const GLchar *"/>
- </function>
-
- <function name="GetObjectLabel" offset="assign">
- <param name="identifier" type="GLenum"/>
- <param name="name" type="GLuint"/>
- <param name="bufSize" type="GLsizei"/>
- <param name="length" type="GLsizei *"/>
- <param name="label" type="GLchar *"/>
- </function>
-
- <function name="ObjectPtrLabel" offset="assign">
- <param name="ptr" type="const GLvoid *"/>
- <param name="length" type="GLsizei"/>
- <param name="label" type="const GLchar *"/>
- </function>
-
- <function name="GetObjectPtrLabel" offset="assign">
- <param name="ptr" type="const GLvoid *"/>
- <param name="bufSize" type="GLsizei"/>
- <param name="length" type="GLsizei *"/>
- <param name="label" type="GLchar *"/>
- </function>
-
-</category>
+<xi:include href="KHR_debug.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<!-- ARB extension #120 -->
diff --git a/mesalib/src/mapi/glapi/glapi.c b/mesalib/src/mapi/glapi/glapi.c
index 3a0b638f7..194b9ee86 100644
--- a/mesalib/src/mapi/glapi/glapi.c
+++ b/mesalib/src/mapi/glapi/glapi.c
@@ -54,11 +54,11 @@ _glapi_check_multithread(void)
void
_glapi_set_context(void *context)
{
- u_current_set_user((const void *) context);
+ u_current_set_context((const void *) context);
}
void
_glapi_set_dispatch(struct _glapi_table *dispatch)
{
- u_current_set((const struct mapi_table *) dispatch);
+ u_current_set_table((const struct mapi_table *) dispatch);
}
diff --git a/mesalib/src/mapi/glapi/glapi.h b/mesalib/src/mapi/glapi/glapi.h
index 67bf1f42e..67bf1f42e 100644..100755
--- a/mesalib/src/mapi/glapi/glapi.h
+++ b/mesalib/src/mapi/glapi/glapi.h
diff --git a/mesalib/src/mapi/mapi.c b/mesalib/src/mapi/mapi.c
index 56f209bfa..aa6b91b42 100644
--- a/mesalib/src/mapi/mapi.c
+++ b/mesalib/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);
}
/**
@@ -186,5 +186,5 @@ mapi_table_fill(struct mapi_table *tbl, const mapi_proc *procs)
void
mapi_table_make_current(const struct mapi_table *tbl)
{
- u_current_set(tbl);
+ u_current_set_table(tbl);
}
diff --git a/mesalib/src/mapi/mapi_glapi.c b/mesalib/src/mapi/mapi_glapi.c
index 7b9f1aee4..7b0903be9 100644
--- a/mesalib/src/mapi/mapi_glapi.c
+++ b/mesalib/src/mapi/mapi_glapi.c
@@ -58,13 +58,13 @@ _glapi_check_multithread(void)
void
_glapi_set_context(void *context)
{
- u_current_set_user((const void *) context);
+ u_current_set_context((const void *) context);
}
void
_glapi_set_dispatch(struct _glapi_table *dispatch)
{
- u_current_set((const struct mapi_table *) dispatch);
+ u_current_set_table((const struct mapi_table *) dispatch);
}
/**
@@ -222,12 +222,6 @@ _glapi_get_proc_name(unsigned int offset)
return stub ? stub_get_name(stub) : NULL;
}
-unsigned long
-_glthread_GetID(void)
-{
- return u_thread_self();
-}
-
void
_glapi_noop_enable_warnings(unsigned char enable)
{
diff --git a/mesalib/src/mapi/stub.c b/mesalib/src/mapi/stub.c
index acd2c0a79..dfadbe1a5 100644
--- a/mesalib/src/mapi/stub.c
+++ b/mesalib/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;
struct mapi_stub *stub = NULL;
int count, i;
- u_mutex_lock(dynamic_mutex);
+ mtx_lock(&dynamic_mutex);
if (generate)
assert(!stub_find_public(name));
@@ -147,7 +147,7 @@ stub_find_dynamic(const char *name, int generate)
if (generate && !stub)
stub = stub_add_dynamic(name);
- u_mutex_unlock(dynamic_mutex);
+ mtx_unlock(&dynamic_mutex);
return stub;
}
diff --git a/mesalib/src/mapi/u_current.c b/mesalib/src/mapi/u_current.c
index 07213380d..afa887e06 100644
--- a/mesalib/src/mapi/u_current.c
+++ b/mesalib/src/mapi/u_current.c
@@ -103,18 +103,18 @@ __thread struct mapi_table *u_current_table
__attribute__((tls_model("initial-exec")))
= (struct mapi_table *) table_noop_array;
-__thread void *u_current_user
+__thread void *u_current_context
__attribute__((tls_model("initial-exec")));
#else
struct mapi_table *u_current_table =
(struct mapi_table *) table_noop_array;
-void *u_current_user;
+void *u_current_context;
#ifdef THREADS
struct u_tsd u_current_table_tsd;
-static struct u_tsd u_current_user_tsd;
+static struct u_tsd u_current_context_tsd;
static int ThreadSafe;
#endif /* THREADS */
@@ -127,7 +127,7 @@ u_current_destroy(void)
{
#if defined(THREADS) && defined(_WIN32)
u_tsd_destroy(&u_current_table_tsd);
- u_tsd_destroy(&u_current_user_tsd);
+ u_tsd_destroy(&u_current_context_tsd);
#endif
}
@@ -138,13 +138,13 @@ static void
u_current_init_tsd(void)
{
u_tsd_init(&u_current_table_tsd);
- u_tsd_init(&u_current_user_tsd);
+ u_tsd_init(&u_current_context_tsd);
}
/**
* Mutex for multithread check.
*/
-u_mutex_declare_static(ThreadCheckMutex);
+static mtx_t ThreadCheckMutex = _MTX_INITIALIZER_NP;
/**
* We should call this periodically from a function such as glXMakeCurrent
@@ -159,7 +159,7 @@ u_current_init(void)
if (ThreadSafe)
return;
- u_mutex_lock(ThreadCheckMutex);
+ mtx_lock(&ThreadCheckMutex);
if (firstCall) {
u_current_init_tsd();
@@ -168,10 +168,10 @@ u_current_init(void)
}
else if (knownID != u_thread_self()) {
ThreadSafe = 1;
- u_current_set(NULL);
- u_current_set_user(NULL);
+ u_current_set_table(NULL);
+ u_current_set_context(NULL);
}
- u_mutex_unlock(ThreadCheckMutex);
+ mtx_unlock(&ThreadCheckMutex);
}
#else
@@ -191,17 +191,17 @@ u_current_init(void)
* void from the real context pointer type.
*/
void
-u_current_set_user(const void *ptr)
+u_current_set_context(const void *ptr)
{
u_current_init();
#if defined(GLX_USE_TLS)
- u_current_user = (void *) ptr;
+ u_current_context = (void *) ptr;
#elif defined(THREADS)
- u_tsd_set(&u_current_user_tsd, (void *) ptr);
- u_current_user = (ThreadSafe) ? NULL : (void *) ptr;
+ u_tsd_set(&u_current_context_tsd, (void *) ptr);
+ u_current_context = (ThreadSafe) ? NULL : (void *) ptr;
#else
- u_current_user = (void *) ptr;
+ u_current_context = (void *) ptr;
#endif
}
@@ -211,16 +211,16 @@ u_current_set_user(const void *ptr)
* void to the real context pointer type.
*/
void *
-u_current_get_user_internal(void)
+u_current_get_context_internal(void)
{
#if defined(GLX_USE_TLS)
- return u_current_user;
+ return u_current_context;
#elif defined(THREADS)
return (ThreadSafe)
- ? u_tsd_get(&u_current_user_tsd)
- : u_current_user;
+ ? u_tsd_get(&u_current_context_tsd)
+ : u_current_context;
#else
- return u_current_user;
+ return u_current_context;
#endif
}
@@ -230,7 +230,7 @@ u_current_get_user_internal(void)
* table (__glapi_noop_table).
*/
void
-u_current_set(const struct mapi_table *tbl)
+u_current_set_table(const struct mapi_table *tbl)
{
u_current_init();
@@ -253,7 +253,7 @@ u_current_set(const struct mapi_table *tbl)
* Return pointer to current dispatch table for calling thread.
*/
struct mapi_table *
-u_current_get_internal(void)
+u_current_get_table_internal(void)
{
#if defined(GLX_USE_TLS)
return u_current_table;
diff --git a/mesalib/src/mapi/u_current.h b/mesalib/src/mapi/u_current.h
index f9cffd8c3..72708d433 100644
--- a/mesalib/src/mapi/u_current.h
+++ b/mesalib/src/mapi/u_current.h
@@ -11,14 +11,14 @@
#ifdef GLX_USE_TLS
#define u_current_table _glapi_tls_Dispatch
-#define u_current_user _glapi_tls_Context
+#define u_current_context _glapi_tls_Context
#else
#define u_current_table _glapi_Dispatch
-#define u_current_user _glapi_Context
+#define u_current_context _glapi_Context
#endif
-#define u_current_get_internal _glapi_get_dispatch
-#define u_current_get_user_internal _glapi_get_context
+#define u_current_get_table_internal _glapi_get_dispatch
+#define u_current_get_context_internal _glapi_get_context
#define u_current_table_tsd _gl_DispatchTSD
@@ -33,13 +33,13 @@ struct mapi_table;
extern __thread struct mapi_table *u_current_table
__attribute__((tls_model("initial-exec")));
-extern __thread void *u_current_user
+extern __thread void *u_current_context
__attribute__((tls_model("initial-exec")));
#else /* GLX_USE_TLS */
extern struct mapi_table *u_current_table;
-extern void *u_current_user;
+extern void *u_current_context;
#endif /* GLX_USE_TLS */
@@ -52,35 +52,35 @@ void
u_current_destroy(void);
void
-u_current_set(const struct mapi_table *tbl);
+u_current_set_table(const struct mapi_table *tbl);
struct mapi_table *
-u_current_get_internal(void);
+u_current_get_table_internal(void);
void
-u_current_set_user(const void *ptr);
+u_current_set_context(const void *ptr);
void *
-u_current_get_user_internal(void);
+u_current_get_context_internal(void);
static INLINE const struct mapi_table *
-u_current_get(void)
+u_current_get_table(void)
{
#ifdef GLX_USE_TLS
return u_current_table;
#else
return (likely(u_current_table) ?
- u_current_table : u_current_get_internal());
+ u_current_table : u_current_get_table_internal());
#endif
}
static INLINE const void *
-u_current_get_user(void)
+u_current_get_context(void)
{
#ifdef GLX_USE_TLS
- return u_current_user;
+ return u_current_context;
#else
- return likely(u_current_user) ? u_current_user : u_current_get_user_internal();
+ return likely(u_current_context) ? u_current_context : u_current_get_context_internal();
#endif
}
diff --git a/mesalib/src/mapi/u_execmem.c b/mesalib/src/mapi/u_execmem.c
index 357365263..ac1cae093 100644
--- a/mesalib/src/mapi/u_execmem.c
+++ b/mesalib/src/mapi/u_execmem.c
@@ -39,7 +39,7 @@
#define EXEC_MAP_SIZE (4*1024)
-u_mutex_declare_static(exec_mutex);
+static mtx_t exec_mutex = _MTX_INITIALIZER_NP;
static unsigned int head = 0;
@@ -123,7 +123,7 @@ u_execmem_alloc(unsigned int size)
{
void *addr = NULL;
- u_mutex_lock(exec_mutex);
+ mtx_lock(&exec_mutex);
if (!init_map())
goto bail;
@@ -137,7 +137,7 @@ u_execmem_alloc(unsigned int size)
head += size;
bail:
- u_mutex_unlock(exec_mutex);
+ mtx_unlock(&exec_mutex);
return addr;
}
diff --git a/mesalib/src/mapi/u_thread.h b/mesalib/src/mapi/u_thread.h
index ba5d98ea9..57c3b076a 100644
--- a/mesalib/src/mapi/u_thread.h
+++ b/mesalib/src/mapi/u_thread.h
@@ -57,9 +57,9 @@
/*
* Error messages
*/
-#define INIT_TSD_ERROR "_glthread_: failed to allocate key for thread specific data"
-#define GET_TSD_ERROR "_glthread_: failed to get thread specific data"
-#define SET_TSD_ERROR "_glthread_: thread failed to set thread specific data"
+#define INIT_TSD_ERROR "Mesa: failed to allocate key for thread specific data"
+#define GET_TSD_ERROR "Mesa: failed to get thread specific data"
+#define SET_TSD_ERROR "Mesa: thread failed to set thread specific data"
/*
@@ -79,20 +79,28 @@ struct u_tsd {
unsigned initMagic;
};
-typedef mtx_t u_mutex;
-
-#define u_mutex_declare_static(name) \
- static u_mutex name = _MTX_INITIALIZER_NP
-
-#define u_mutex_init(name) mtx_init(&(name), mtx_plain)
-#define u_mutex_destroy(name) mtx_destroy(&(name))
-#define u_mutex_lock(name) (void) mtx_lock(&(name))
-#define u_mutex_unlock(name) (void) mtx_unlock(&(name))
static INLINE unsigned long
u_thread_self(void)
{
+ /*
+ * XXX: Callers of u_thread_self assume it is a lightweight function,
+ * returning a numeric value. But unfortunately C11's thrd_current() gives
+ * no such guarantees. In fact, it's pretty hard to have a compliant
+ * implementation of thrd_current() on Windows with such characteristics.
+ * So for now, we side-step this mess and use Windows thread primitives
+ * directly here.
+ *
+ * FIXME: On the other hand, u_thread_self() is a bad
+ * abstraction. Even with pthreads, there is no guarantee that
+ * pthread_self() will return numeric IDs -- we should be using
+ * pthread_equal() instead of assuming we can compare thread ids...
+ */
+#ifdef _WIN32
+ return GetCurrentThreadId();
+#else
return (unsigned long) (uintptr_t) thrd_current();
+#endif
}