summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2014-03-05 16:06:00 -0700
committerBrian Paul <[email protected]>2014-03-06 07:53:06 -0700
commit84094a273e3ceeead5b6c86d3d8244374ea6fb1c (patch)
tree8cb0771255a1074c9d903dcfd8ddb3334b78b106 /src
parent846a7e86309ab3877af6b7d3a63880468dfacbd3 (diff)
glapi: remove u_mutex wrapper code, use c99 thread mutexes directly
v2: fix initializer mistake spotted by Chia-I Wu. Reviewed-by: Chia-I Wu <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mapi/mapi.c10
-rw-r--r--src/mapi/stub.c6
-rw-r--r--src/mapi/u_current.c6
-rw-r--r--src/mapi/u_execmem.c6
-rw-r--r--src/mapi/u_thread.h10
5 files changed, 14 insertions, 24 deletions
diff --git a/src/mapi/mapi.c b/src/mapi/mapi.c
index 6f1b35fa425..aa6b91b42c7 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 acd2c0a79b1..dfadbe1a5d3 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;
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/src/mapi/u_current.c b/src/mapi/u_current.c
index 76dae91c367..afa887e0692 100644
--- a/src/mapi/u_current.c
+++ b/src/mapi/u_current.c
@@ -144,7 +144,7 @@ u_current_init_tsd(void)
/**
* 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();
@@ -171,7 +171,7 @@ u_current_init(void)
u_current_set_table(NULL);
u_current_set_context(NULL);
}
- u_mutex_unlock(ThreadCheckMutex);
+ mtx_unlock(&ThreadCheckMutex);
}
#else
diff --git a/src/mapi/u_execmem.c b/src/mapi/u_execmem.c
index 3573652635f..ac1cae093d7 100644
--- a/src/mapi/u_execmem.c
+++ b/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/src/mapi/u_thread.h b/src/mapi/u_thread.h
index 0fc93929c99..4b9ed164cda 100644
--- a/src/mapi/u_thread.h
+++ b/src/mapi/u_thread.h
@@ -79,16 +79,6 @@ 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)