2010-04-23 16:06:26 +08:00
|
|
|
#ifndef _U_CURRENT_H_
|
|
|
|
|
#define _U_CURRENT_H_
|
|
|
|
|
|
2010-12-17 00:24:27 +08:00
|
|
|
#if defined(MAPI_MODE_UTIL) || defined(MAPI_MODE_GLAPI) || \
|
|
|
|
|
defined(MAPI_MODE_BRIDGE)
|
2010-04-23 16:06:26 +08:00
|
|
|
|
2010-08-21 11:50:22 +08:00
|
|
|
#include "glapi/glapi.h"
|
|
|
|
|
|
2010-08-21 12:10:02 +08:00
|
|
|
/* ugly renames to match glapi.h */
|
|
|
|
|
#define mapi_table _glapi_table
|
|
|
|
|
|
2010-12-10 17:14:04 +08:00
|
|
|
#ifdef GLX_USE_TLS
|
|
|
|
|
#define u_current_table _glapi_tls_Dispatch
|
|
|
|
|
#define u_current_user _glapi_tls_Context
|
|
|
|
|
#else
|
2010-08-21 12:10:02 +08:00
|
|
|
#define u_current_table _glapi_Dispatch
|
|
|
|
|
#define u_current_user _glapi_Context
|
2010-12-10 17:14:04 +08:00
|
|
|
#endif
|
2010-08-21 12:10:02 +08:00
|
|
|
|
|
|
|
|
#define u_current_get_internal _glapi_get_dispatch
|
|
|
|
|
#define u_current_get_user_internal _glapi_get_context
|
|
|
|
|
|
|
|
|
|
#define u_current_table_tsd _gl_DispatchTSD
|
|
|
|
|
|
2010-12-17 00:24:27 +08:00
|
|
|
#else /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */
|
2010-04-23 16:06:26 +08:00
|
|
|
|
2010-08-21 12:10:02 +08:00
|
|
|
#include "u_compiler.h"
|
|
|
|
|
|
|
|
|
|
struct mapi_table;
|
2010-04-23 16:06:26 +08:00
|
|
|
|
|
|
|
|
#ifdef GLX_USE_TLS
|
|
|
|
|
|
2010-12-10 17:14:04 +08:00
|
|
|
extern __thread struct mapi_table *u_current_table
|
2010-04-23 16:06:26 +08:00
|
|
|
__attribute__((tls_model("initial-exec")));
|
|
|
|
|
|
2010-12-10 17:14:04 +08:00
|
|
|
extern __thread void *u_current_user
|
2010-04-23 16:06:26 +08:00
|
|
|
__attribute__((tls_model("initial-exec")));
|
|
|
|
|
|
|
|
|
|
#else /* GLX_USE_TLS */
|
|
|
|
|
|
2010-08-21 12:10:02 +08:00
|
|
|
extern struct mapi_table *u_current_table;
|
|
|
|
|
extern void *u_current_user;
|
2010-04-23 16:06:26 +08:00
|
|
|
|
|
|
|
|
#endif /* GLX_USE_TLS */
|
|
|
|
|
|
2010-12-17 00:24:27 +08:00
|
|
|
#endif /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */
|
2010-12-10 17:14:04 +08:00
|
|
|
|
2010-08-21 11:50:22 +08:00
|
|
|
void
|
2010-08-21 12:10:02 +08:00
|
|
|
u_current_init(void);
|
2010-04-23 16:06:26 +08:00
|
|
|
|
2010-08-21 11:50:22 +08:00
|
|
|
void
|
2010-08-21 12:10:02 +08:00
|
|
|
u_current_destroy(void);
|
2010-04-23 16:06:26 +08:00
|
|
|
|
2010-08-21 11:50:22 +08:00
|
|
|
void
|
2010-12-10 17:14:04 +08:00
|
|
|
u_current_set(const struct mapi_table *tbl);
|
2010-04-23 16:06:26 +08:00
|
|
|
|
2010-08-21 12:10:02 +08:00
|
|
|
struct mapi_table *
|
|
|
|
|
u_current_get_internal(void);
|
2010-04-23 16:06:26 +08:00
|
|
|
|
|
|
|
|
void
|
2010-12-10 17:14:04 +08:00
|
|
|
u_current_set_user(const void *ptr);
|
2010-04-23 16:06:26 +08:00
|
|
|
|
2010-08-21 12:10:02 +08:00
|
|
|
void *
|
|
|
|
|
u_current_get_user_internal(void);
|
2010-04-23 16:06:26 +08:00
|
|
|
|
|
|
|
|
static INLINE const struct mapi_table *
|
|
|
|
|
u_current_get(void)
|
|
|
|
|
{
|
|
|
|
|
#ifdef GLX_USE_TLS
|
2010-12-10 17:14:04 +08:00
|
|
|
return u_current_table;
|
2010-04-23 16:06:26 +08:00
|
|
|
#else
|
2010-08-21 12:10:02 +08:00
|
|
|
return (likely(u_current_table) ?
|
2010-12-10 17:14:04 +08:00
|
|
|
u_current_table : u_current_get_internal());
|
2010-04-23 16:06:26 +08:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-10 17:14:04 +08:00
|
|
|
static INLINE const void *
|
2010-04-23 16:06:26 +08:00
|
|
|
u_current_get_user(void)
|
|
|
|
|
{
|
|
|
|
|
#ifdef GLX_USE_TLS
|
2010-12-10 17:14:04 +08:00
|
|
|
return u_current_user;
|
2010-04-23 16:06:26 +08:00
|
|
|
#else
|
2010-08-21 12:10:02 +08:00
|
|
|
return likely(u_current_user) ? u_current_user : u_current_get_user_internal();
|
2010-04-23 16:06:26 +08:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-21 11:50:22 +08:00
|
|
|
#endif /* _U_CURRENT_H_ */
|