2010-04-23 09:06:26 +01:00
|
|
|
#ifndef _U_CURRENT_H_
|
|
|
|
#define _U_CURRENT_H_
|
|
|
|
|
|
|
|
#include "u_compiler.h"
|
|
|
|
|
|
|
|
#ifdef MAPI_GLAPI_CURRENT
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
#include "glapi/glapi.h"
|
|
|
|
|
|
|
|
#else /* MAPI_GLAPI_CURRENT */
|
2010-04-23 09:06:26 +01:00
|
|
|
|
|
|
|
struct _glapi_table;
|
|
|
|
|
|
|
|
#ifdef GLX_USE_TLS
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
extern __thread struct _glapi_table *_glapi_tls_Dispatch
|
2010-04-23 09:06:26 +01:00
|
|
|
__attribute__((tls_model("initial-exec")));
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
extern __thread void *_glapi_tls_Context
|
2010-04-23 09:06:26 +01:00
|
|
|
__attribute__((tls_model("initial-exec")));
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
extern const struct _glapi_table *_glapi_Dispatch;
|
|
|
|
extern const void *_glapi_Context;
|
2010-04-23 09:06:26 +01:00
|
|
|
|
|
|
|
#else /* GLX_USE_TLS */
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
extern struct _glapi_table *_glapi_Dispatch;
|
|
|
|
extern void *_glapi_Context;
|
2010-04-23 09:06:26 +01:00
|
|
|
|
|
|
|
#endif /* GLX_USE_TLS */
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
void
|
2010-04-23 09:06:26 +01:00
|
|
|
_glapi_check_multithread(void);
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
void
|
2010-04-23 09:06:26 +01:00
|
|
|
_glapi_set_context(void *context);
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
void *
|
2010-04-23 09:06:26 +01:00
|
|
|
_glapi_get_context(void);
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
void
|
2010-04-23 09:06:26 +01:00
|
|
|
_glapi_set_dispatch(struct _glapi_table *dispatch);
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
struct _glapi_table *
|
2010-04-23 09:06:26 +01:00
|
|
|
_glapi_get_dispatch(void);
|
|
|
|
|
|
|
|
void
|
|
|
|
_glapi_destroy_multithread(void);
|
|
|
|
|
|
|
|
|
|
|
|
struct mapi_table;
|
|
|
|
|
|
|
|
static INLINE void
|
|
|
|
u_current_set(const struct mapi_table *tbl)
|
|
|
|
{
|
|
|
|
_glapi_check_multithread();
|
|
|
|
_glapi_set_dispatch((struct _glapi_table *) tbl);
|
|
|
|
}
|
|
|
|
|
|
|
|
static INLINE const struct mapi_table *
|
|
|
|
u_current_get(void)
|
|
|
|
{
|
|
|
|
#ifdef GLX_USE_TLS
|
|
|
|
return (const struct mapi_table *) _glapi_tls_Dispatch;
|
|
|
|
#else
|
|
|
|
return (const struct mapi_table *) (likely(_glapi_Dispatch) ?
|
|
|
|
_glapi_Dispatch : _glapi_get_dispatch());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static INLINE void
|
|
|
|
u_current_set_user(void *ptr)
|
|
|
|
{
|
|
|
|
_glapi_check_multithread();
|
|
|
|
_glapi_set_context(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static INLINE void *
|
|
|
|
u_current_get_user(void)
|
|
|
|
{
|
|
|
|
#ifdef GLX_USE_TLS
|
|
|
|
return _glapi_tls_Context;
|
|
|
|
#else
|
|
|
|
return likely(_glapi_Context) ? _glapi_Context : _glapi_get_context();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-08-21 04:50:22 +01:00
|
|
|
#endif /* MAPI_GLAPI_CURRENT */
|
|
|
|
|
|
|
|
#endif /* _U_CURRENT_H_ */
|