v2: fix initializer mistake spotted by Chia-I Wu.
Reviewed-by: Chia-I Wu <olv@lunarg.com>
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;
}
/* parse version string */
ver = atoi(p);
if (ver != 1) {
- u_mutex_unlock(mutex);
+ mtx_unlock(&mutex);
return;
}
p += strlen(p) + 1;
mapi_num_stubs = count;
- u_mutex_unlock(mutex);
+ mtx_unlock(&mutex);
}
/**
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));
if (generate && !stub)
stub = stub_add_dynamic(name);
- u_mutex_unlock(dynamic_mutex);
+ mtx_unlock(&dynamic_mutex);
return stub;
}
/**
* 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
if (ThreadSafe)
return;
- u_mutex_lock(ThreadCheckMutex);
+ mtx_lock(&ThreadCheckMutex);
if (firstCall) {
u_current_init_tsd();
u_current_set_table(NULL);
u_current_set_context(NULL);
}
- u_mutex_unlock(ThreadCheckMutex);
+ mtx_unlock(&ThreadCheckMutex);
}
#else
#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;
{
void *addr = NULL;
- u_mutex_lock(exec_mutex);
+ mtx_lock(&exec_mutex);
if (!init_map())
goto bail;
head += size;
bail:
- u_mutex_unlock(exec_mutex);
+ mtx_unlock(&exec_mutex);
return addr;
}
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)