#include <stdlib.h>
#include <string.h>
#include <assert.h>
+#include "c11/threads.h"
#include "util/macros.h"
#include "u_current.h"
-#include "u_thread.h"
#include "entry.h"
#include "stub.h"
#include "table.h"
void
stub_init_once(void)
{
-#ifdef HAVE_PTHREAD
- static pthread_once_t once = PTHREAD_ONCE_INIT;
- pthread_once(&once, entry_patch_public);
-#else
- static int first = 1;
- if (first) {
- first = 0;
- entry_patch_public();
- }
-#endif
+ static once_flag flag = ONCE_FLAG_INIT;
+ call_once(&flag, entry_patch_public);
}
static int
* drivers! No changes to the public glapi interface.
*/
+#include "c11/threads.h"
#include "u_current.h"
-#include "u_thread.h"
#ifndef MAPI_MODE_UTIL
(struct mapi_table *) table_noop_array;
void *u_current_context;
-struct u_tsd u_current_table_tsd;
-static struct u_tsd u_current_context_tsd;
+tss_t u_current_table_tsd;
+static tss_t u_current_context_tsd;
static int ThreadSafe;
#endif /* defined(GLX_USE_TLS) */
u_current_destroy(void)
{
#if !defined(GLX_USE_TLS)
- u_tsd_destroy(&u_current_table_tsd);
- u_tsd_destroy(&u_current_context_tsd);
+ tss_delete(u_current_table_tsd);
+ tss_delete(u_current_context_tsd);
#endif
}
static void
u_current_init_tsd(void)
{
- u_tsd_init(&u_current_table_tsd);
- u_tsd_init(&u_current_context_tsd);
+ tss_create(&u_current_table_tsd, NULL);
+ tss_create(&u_current_context_tsd, NULL);
}
/**
#if defined(GLX_USE_TLS)
u_current_context = (void *) ptr;
#else
- u_tsd_set(&u_current_context_tsd, (void *) ptr);
+ tss_set(u_current_context_tsd, (void *) ptr);
u_current_context = (ThreadSafe) ? NULL : (void *) ptr;
#endif
}
#if defined(GLX_USE_TLS)
return u_current_context;
#else
- return (ThreadSafe)
- ? u_tsd_get(&u_current_context_tsd)
- : u_current_context;
+ return ThreadSafe ? tss_get(u_current_context_tsd) : u_current_context;
#endif
}
#if defined(GLX_USE_TLS)
u_current_table = (struct mapi_table *) tbl;
#else
- u_tsd_set(&u_current_table_tsd, (void *) tbl);
+ tss_set(u_current_table_tsd, (void *) tbl);
u_current_table = (ThreadSafe) ? NULL : (void *) tbl;
#endif
}
#if defined(GLX_USE_TLS)
return u_current_table;
#else
- return (struct mapi_table *) ((ThreadSafe) ?
- u_tsd_get(&u_current_table_tsd) : (void *) u_current_table);
+ if (ThreadSafe)
+ return (struct mapi_table *) tss_get(u_current_table_tsd);
+ else
+ return (struct mapi_table *) u_current_table;
#endif
}