blob: a6bd9f08385a60cb1bf7c7d143e62b96f1000ea9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#ifndef _U_CURRENT_H_
#define _U_CURRENT_H_
#include "u_compiler.h"
#ifdef MAPI_GLAPI_CURRENT
#include "glapi/glapi.h"
#else /* MAPI_GLAPI_CURRENT */
struct _glapi_table;
#ifdef GLX_USE_TLS
extern __thread struct _glapi_table *_glapi_tls_Dispatch
__attribute__((tls_model("initial-exec")));
extern __thread void *_glapi_tls_Context
__attribute__((tls_model("initial-exec")));
extern const struct _glapi_table *_glapi_Dispatch;
extern const void *_glapi_Context;
#else /* GLX_USE_TLS */
extern struct _glapi_table *_glapi_Dispatch;
extern void *_glapi_Context;
#endif /* GLX_USE_TLS */
void
_glapi_check_multithread(void);
void
_glapi_set_context(void *context);
void *
_glapi_get_context(void);
void
_glapi_set_dispatch(struct _glapi_table *dispatch);
struct _glapi_table *
_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
}
#endif /* MAPI_GLAPI_CURRENT */
#endif /* _U_CURRENT_H_ */
|