2010-04-23 09:06:26 +01:00
|
|
|
#ifndef _U_CURRENT_H_
|
|
|
|
#define _U_CURRENT_H_
|
|
|
|
|
2010-12-16 16:24:27 +00:00
|
|
|
#if defined(MAPI_MODE_UTIL) || defined(MAPI_MODE_GLAPI) || \
|
|
|
|
defined(MAPI_MODE_BRIDGE)
|
2010-04-23 09:06:26 +01:00
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
#include "glapi/glapi.h"
|
|
|
|
|
2010-08-21 05:10:02 +01:00
|
|
|
/* ugly renames to match glapi.h */
|
|
|
|
#define mapi_table _glapi_table
|
|
|
|
|
2010-12-10 09:14:04 +00:00
|
|
|
#ifdef GLX_USE_TLS
|
|
|
|
#define u_current_table _glapi_tls_Dispatch
|
2014-03-05 14:47:41 +00:00
|
|
|
#define u_current_context _glapi_tls_Context
|
2010-12-10 09:14:04 +00:00
|
|
|
#else
|
2010-08-21 05:10:02 +01:00
|
|
|
#define u_current_table _glapi_Dispatch
|
2014-03-05 14:47:41 +00:00
|
|
|
#define u_current_context _glapi_Context
|
2010-12-10 09:14:04 +00:00
|
|
|
#endif
|
2010-08-21 05:10:02 +01:00
|
|
|
|
2014-03-05 14:47:41 +00:00
|
|
|
#define u_current_get_table_internal _glapi_get_dispatch
|
2014-03-05 14:47:41 +00:00
|
|
|
#define u_current_get_context_internal _glapi_get_context
|
2010-08-21 05:10:02 +01:00
|
|
|
|
|
|
|
#define u_current_table_tsd _gl_DispatchTSD
|
|
|
|
|
2010-12-16 16:24:27 +00:00
|
|
|
#else /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */
|
2010-04-23 09:06:26 +01:00
|
|
|
|
2010-08-21 05:10:02 +01:00
|
|
|
#include "u_compiler.h"
|
|
|
|
|
|
|
|
struct mapi_table;
|
2010-04-23 09:06:26 +01:00
|
|
|
|
|
|
|
#ifdef GLX_USE_TLS
|
|
|
|
|
2010-12-10 09:14:04 +00:00
|
|
|
extern __thread struct mapi_table *u_current_table
|
2010-04-23 09:06:26 +01:00
|
|
|
__attribute__((tls_model("initial-exec")));
|
|
|
|
|
2014-03-05 14:47:41 +00:00
|
|
|
extern __thread void *u_current_context
|
2010-04-23 09:06:26 +01:00
|
|
|
__attribute__((tls_model("initial-exec")));
|
|
|
|
|
|
|
|
#else /* GLX_USE_TLS */
|
|
|
|
|
2010-08-21 05:10:02 +01:00
|
|
|
extern struct mapi_table *u_current_table;
|
2014-03-05 14:47:41 +00:00
|
|
|
extern void *u_current_context;
|
2010-04-23 09:06:26 +01:00
|
|
|
|
|
|
|
#endif /* GLX_USE_TLS */
|
|
|
|
|
2010-12-16 16:24:27 +00:00
|
|
|
#endif /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */
|
2010-12-10 09:14:04 +00:00
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
void
|
2010-08-21 05:10:02 +01:00
|
|
|
u_current_init(void);
|
2010-04-23 09:06:26 +01:00
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
void
|
2010-08-21 05:10:02 +01:00
|
|
|
u_current_destroy(void);
|
2010-04-23 09:06:26 +01:00
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
void
|
2014-03-05 14:47:41 +00:00
|
|
|
u_current_set_table(const struct mapi_table *tbl);
|
2010-04-23 09:06:26 +01:00
|
|
|
|
2010-08-21 05:10:02 +01:00
|
|
|
struct mapi_table *
|
2014-03-05 14:47:41 +00:00
|
|
|
u_current_get_table_internal(void);
|
2010-04-23 09:06:26 +01:00
|
|
|
|
|
|
|
void
|
2014-03-05 14:47:41 +00:00
|
|
|
u_current_set_context(const void *ptr);
|
2010-04-23 09:06:26 +01:00
|
|
|
|
2010-08-21 05:10:02 +01:00
|
|
|
void *
|
2014-03-05 14:47:41 +00:00
|
|
|
u_current_get_context_internal(void);
|
2010-04-23 09:06:26 +01:00
|
|
|
|
2015-03-03 16:08:22 +00:00
|
|
|
static inline const struct mapi_table *
|
2014-03-05 14:47:41 +00:00
|
|
|
u_current_get_table(void)
|
2010-04-23 09:06:26 +01:00
|
|
|
{
|
|
|
|
#ifdef GLX_USE_TLS
|
2010-12-10 09:14:04 +00:00
|
|
|
return u_current_table;
|
2010-04-23 09:06:26 +01:00
|
|
|
#else
|
2010-08-21 05:10:02 +01:00
|
|
|
return (likely(u_current_table) ?
|
2014-03-05 14:47:41 +00:00
|
|
|
u_current_table : u_current_get_table_internal());
|
2010-04-23 09:06:26 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-03-03 16:08:22 +00:00
|
|
|
static inline const void *
|
2014-03-05 14:47:41 +00:00
|
|
|
u_current_get_context(void)
|
2010-04-23 09:06:26 +01:00
|
|
|
{
|
|
|
|
#ifdef GLX_USE_TLS
|
2014-03-05 14:47:41 +00:00
|
|
|
return u_current_context;
|
2010-04-23 09:06:26 +01:00
|
|
|
#else
|
2014-03-05 14:47:41 +00:00
|
|
|
return likely(u_current_context) ? u_current_context : u_current_get_context_internal();
|
2010-04-23 09:06:26 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
#endif /* _U_CURRENT_H_ */
|