Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1901 | serge | 1 | #ifndef _U_CURRENT_H_ |
2 | #define _U_CURRENT_H_ |
||
3 | |||
4 | #ifdef MAPI_GLAPI_CURRENT |
||
5 | |||
6 | #include "glapi/glapi.h" |
||
7 | |||
8 | /* ugly renames to match glapi.h */ |
||
9 | #define mapi_table _glapi_table |
||
10 | |||
11 | #define u_current_table_tls _glapi_tls_Dispatch |
||
12 | #define u_current_user_tls _glapi_tls_Context |
||
13 | #define u_current_table _glapi_Dispatch |
||
14 | #define u_current_user _glapi_Context |
||
15 | |||
16 | #define u_current_destroy _glapi_destroy_multithread |
||
17 | #define u_current_init _glapi_check_multithread |
||
18 | #define u_current_set_internal _glapi_set_dispatch |
||
19 | #define u_current_get_internal _glapi_get_dispatch |
||
20 | #define u_current_set_user_internal _glapi_set_context |
||
21 | #define u_current_get_user_internal _glapi_get_context |
||
22 | |||
23 | #define u_current_table_tsd _gl_DispatchTSD |
||
24 | |||
25 | #else /* MAPI_GLAPI_CURRENT */ |
||
26 | |||
27 | #include "u_compiler.h" |
||
28 | |||
29 | struct mapi_table; |
||
30 | |||
31 | #ifdef GLX_USE_TLS |
||
32 | |||
33 | extern __thread struct mapi_table *u_current_table_tls |
||
34 | __attribute__((tls_model("initial-exec"))); |
||
35 | |||
36 | extern __thread void *u_current_user_tls |
||
37 | __attribute__((tls_model("initial-exec"))); |
||
38 | |||
39 | extern const struct mapi_table *u_current_table; |
||
40 | extern const void *u_current_user; |
||
41 | |||
42 | #else /* GLX_USE_TLS */ |
||
43 | |||
44 | extern struct mapi_table *u_current_table; |
||
45 | extern void *u_current_user; |
||
46 | |||
47 | #endif /* GLX_USE_TLS */ |
||
48 | |||
49 | void |
||
50 | u_current_init(void); |
||
51 | |||
52 | void |
||
53 | u_current_destroy(void); |
||
54 | |||
55 | void |
||
56 | u_current_set_internal(struct mapi_table *tbl); |
||
57 | |||
58 | struct mapi_table * |
||
59 | u_current_get_internal(void); |
||
60 | |||
61 | void |
||
62 | u_current_set_user_internal(void *ptr); |
||
63 | |||
64 | void * |
||
65 | u_current_get_user_internal(void); |
||
66 | |||
67 | static INLINE void |
||
68 | u_current_set(const struct mapi_table *tbl) |
||
69 | { |
||
70 | u_current_set_internal((struct mapi_table *) tbl); |
||
71 | } |
||
72 | |||
73 | static INLINE const struct mapi_table * |
||
74 | u_current_get(void) |
||
75 | { |
||
76 | #ifdef GLX_USE_TLS |
||
77 | return (const struct mapi_table *) u_current_table_tls; |
||
78 | #else |
||
79 | return (likely(u_current_table) ? |
||
80 | (const struct mapi_table *) u_current_table : u_current_get_internal()); |
||
81 | #endif |
||
82 | } |
||
83 | |||
84 | static INLINE void |
||
85 | u_current_set_user(void *ptr) |
||
86 | { |
||
87 | u_current_set_internal(ptr); |
||
88 | } |
||
89 | |||
90 | static INLINE void * |
||
91 | u_current_get_user(void) |
||
92 | { |
||
93 | #ifdef GLX_USE_TLS |
||
94 | return u_current_user_tls; |
||
95 | #else |
||
96 | return likely(u_current_user) ? u_current_user : u_current_get_user_internal(); |
||
97 | #endif |
||
98 | } |
||
99 | |||
100 | #endif /* MAPI_GLAPI_CURRENT */ |
||
101 | |||
102 | #endif /* _U_CURRENT_H_ */ |