4 #include "c99_compat.h"
5 #include "util/macros.h"
8 #if defined(MAPI_MODE_UTIL) || defined(MAPI_MODE_GLAPI) || \
9 defined(MAPI_MODE_BRIDGE)
11 #include "glapi/glapi.h"
13 /* ugly renames to match glapi.h */
14 #define mapi_table _glapi_table
17 #define u_current_table _glapi_tls_Dispatch
18 #define u_current_context _glapi_tls_Context
20 #define u_current_table _glapi_Dispatch
21 #define u_current_context _glapi_Context
24 #define u_current_get_table_internal _glapi_get_dispatch
25 #define u_current_get_context_internal _glapi_get_context
27 #define u_current_table_tsd _gl_DispatchTSD
29 #else /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */
35 extern __thread
struct mapi_table
*u_current_table
36 __attribute__((tls_model("initial-exec")));
38 extern __thread
void *u_current_context
39 __attribute__((tls_model("initial-exec")));
41 #else /* GLX_USE_TLS */
43 extern struct mapi_table
*u_current_table
;
44 extern void *u_current_context
;
46 #endif /* GLX_USE_TLS */
48 #endif /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */
54 u_current_destroy(void);
57 u_current_set_table(const struct mapi_table
*tbl
);
60 u_current_get_table_internal(void);
63 u_current_set_context(const void *ptr
);
66 u_current_get_context_internal(void);
68 static inline const struct mapi_table
*
69 u_current_get_table(void)
72 return u_current_table
;
74 return (likely(u_current_table
) ?
75 u_current_table
: u_current_get_table_internal());
79 static inline const void *
80 u_current_get_context(void)
83 return u_current_context
;
85 return likely(u_current_context
) ? u_current_context
: u_current_get_context_internal();
89 #endif /* _U_CURRENT_H_ */