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