X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmapi%2Fu_current.c;h=7e7e275f2e37f8a02f86c5c30878dc3db49629c5;hb=ef97cc0cae687726a2a7a6c9dccc2e90d04b1d74;hp=c1a486bd0e1bd4ce5d4ce808232fffe4f660936c;hpb=458c7490c29ef2960a33a089f65490e044da5d27;p=mesa.git diff --git a/src/mapi/u_current.c b/src/mapi/u_current.c index c1a486bd0e1..7e7e275f2e3 100644 --- a/src/mapi/u_current.c +++ b/src/mapi/u_current.c @@ -48,8 +48,8 @@ * drivers! No changes to the public glapi interface. */ +#include "c11/threads.h" #include "u_current.h" -#include "u_thread.h" #ifndef MAPI_MODE_UTIL @@ -112,11 +112,9 @@ struct mapi_table *u_current_table = (struct mapi_table *) table_noop_array; void *u_current_context; -#ifdef THREADS -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 /* THREADS */ #endif /* defined(GLX_USE_TLS) */ /*@}*/ @@ -125,20 +123,20 @@ static int ThreadSafe; void u_current_destroy(void) { -#if defined(THREADS) && !defined(GLX_USE_TLS) - u_tsd_destroy(&u_current_table_tsd); - u_tsd_destroy(&u_current_context_tsd); +#if !defined(GLX_USE_TLS) + tss_delete(u_current_table_tsd); + tss_delete(u_current_context_tsd); #endif } -#if defined(THREADS) && !defined(GLX_USE_TLS) +#if !defined(GLX_USE_TLS) 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); } /** @@ -234,11 +232,9 @@ u_current_set_context(const void *ptr) #if defined(GLX_USE_TLS) u_current_context = (void *) ptr; -#elif defined(THREADS) - u_tsd_set(&u_current_context_tsd, (void *) ptr); - u_current_context = (ThreadSafe) ? NULL : (void *) ptr; #else - u_current_context = (void *) ptr; + tss_set(u_current_context_tsd, (void *) ptr); + u_current_context = (ThreadSafe) ? NULL : (void *) ptr; #endif } @@ -252,12 +248,8 @@ u_current_get_context_internal(void) { #if defined(GLX_USE_TLS) return u_current_context; -#elif defined(THREADS) - return (ThreadSafe) - ? u_tsd_get(&u_current_context_tsd) - : u_current_context; #else - return u_current_context; + return ThreadSafe ? tss_get(u_current_context_tsd) : u_current_context; #endif } @@ -278,11 +270,9 @@ u_current_set_table(const struct mapi_table *tbl) #if defined(GLX_USE_TLS) u_current_table = (struct mapi_table *) tbl; -#elif defined(THREADS) - u_tsd_set(&u_current_table_tsd, (void *) tbl); - u_current_table = (ThreadSafe) ? NULL : (void *) tbl; #else - u_current_table = (struct mapi_table *) tbl; + tss_set(u_current_table_tsd, (void *) tbl); + u_current_table = (ThreadSafe) ? NULL : (void *) tbl; #endif } @@ -294,10 +284,10 @@ u_current_get_table_internal(void) { #if defined(GLX_USE_TLS) return u_current_table; -#elif defined(THREADS) - return (struct mapi_table *) ((ThreadSafe) ? - u_tsd_get(&u_current_table_tsd) : (void *) u_current_table); #else - return u_current_table; + if (ThreadSafe) + return (struct mapi_table *) tss_get(u_current_table_tsd); + else + return (struct mapi_table *) u_current_table; #endif }