1#ifndef _U_CURRENT_H_ 2#define _U_CURRENT_H_ 3 4#include "c99_compat.h" 5#include "util/macros.h" 6 7 8#if defined(MAPI_MODE_UTIL) || defined(MAPI_MODE_GLAPI) || \ 9 defined(MAPI_MODE_BRIDGE) 10 11#include "glapi/glapi.h" 12 13#ifdef GLX_USE_TLS 14#define u_current_table _glapi_tls_Dispatch 15#define u_current_context _glapi_tls_Context 16#else 17#define u_current_table _glapi_Dispatch 18#define u_current_context _glapi_Context 19#endif 20 21#define u_current_get_table_internal _glapi_get_dispatch 22#define u_current_get_context_internal _glapi_get_context 23 24#define u_current_table_tsd _gl_DispatchTSD 25 26#else /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */ 27 28struct _glapi_table; 29 30#ifdef GLX_USE_TLS 31 32extern __thread struct _glapi_table *u_current_table 33 __attribute__((tls_model("initial-exec"))); 34 35extern __thread void *u_current_context 36 __attribute__((tls_model("initial-exec"))); 37 38#else /* GLX_USE_TLS */ 39 40extern struct _glapi_table *u_current_table; 41extern void *u_current_context; 42 43#endif /* GLX_USE_TLS */ 44 45#endif /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */ 46 47void 48u_current_init(void); 49 50void 51u_current_destroy(void); 52 53void 54u_current_set_table(const struct _glapi_table *tbl); 55 56struct _glapi_table * 57u_current_get_table_internal(void); 58 59void 60u_current_set_context(const void *ptr); 61 62void * 63u_current_get_context_internal(void); 64 65static inline const struct _glapi_table * 66u_current_get_table(void) 67{ 68#if defined(GLX_USE_TLS) && !defined(__NetBSD__) 69 return u_current_table; 70#else 71 return (likely(u_current_table) ? 72 u_current_table : u_current_get_table_internal()); 73#endif 74} 75 76static inline const void * 77u_current_get_context(void) 78{ 79#ifdef GLX_USE_TLS 80 return u_current_context; 81#else 82 return likely(u_current_context) ? u_current_context : u_current_get_context_internal(); 83#endif 84} 85 86#endif /* _U_CURRENT_H_ */ 87