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"
14 #define u_current_table _glapi_tls_Dispatch
15 #define u_current_context _glapi_tls_Context
17 #define u_current_table _glapi_Dispatch
18 #define u_current_context _glapi_Context
21 #define u_current_get_table_internal _glapi_get_dispatch
22 #define u_current_get_context_internal _glapi_get_context
24 #define u_current_table_tsd _gl_DispatchTSD
26 #else /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */
32 extern __thread
struct _glapi_table
*u_current_table
33 __attribute__((tls_model("initial-exec")));
35 extern __thread
void *u_current_context
36 __attribute__((tls_model("initial-exec")));
38 #else /* USE_ELF_TLS */
40 extern struct _glapi_table
*u_current_table
;
41 extern void *u_current_context
;
43 #endif /* USE_ELF_TLS */
45 #endif /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */
51 u_current_destroy(void);
54 u_current_set_table(const struct _glapi_table
*tbl
);
57 u_current_get_table_internal(void);
60 u_current_set_context(const void *ptr
);
63 u_current_get_context_internal(void);
65 static inline const struct _glapi_table
*
66 u_current_get_table(void)
69 return u_current_table
;
71 return (likely(u_current_table
) ?
72 u_current_table
: u_current_get_table_internal());
76 static inline const void *
77 u_current_get_context(void)
80 return u_current_context
;
82 return likely(u_current_context
) ? u_current_context
: u_current_get_context_internal();
86 #endif /* _U_CURRENT_H_ */