Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4358 | Serge | 1 | #ifndef _U_CURRENT_H_ |
2 | #define _U_CURRENT_H_ |
||
3 | |||
4 | #if defined(MAPI_MODE_UTIL) || defined(MAPI_MODE_GLAPI) || \ |
||
5 | defined(MAPI_MODE_BRIDGE) |
||
6 | |||
7 | #include "glapi/glapi.h" |
||
8 | |||
9 | /* ugly renames to match glapi.h */ |
||
10 | #define mapi_table _glapi_table |
||
11 | |||
12 | #ifdef GLX_USE_TLS |
||
13 | #define u_current_table _glapi_tls_Dispatch |
||
14 | #define u_current_user _glapi_tls_Context |
||
15 | #else |
||
16 | #define u_current_table _glapi_Dispatch |
||
17 | #define u_current_user _glapi_Context |
||
18 | #endif |
||
19 | |||
20 | #define u_current_get_internal _glapi_get_dispatch |
||
21 | #define u_current_get_user_internal _glapi_get_context |
||
22 | |||
23 | #define u_current_table_tsd _gl_DispatchTSD |
||
24 | |||
25 | #else /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */ |
||
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 |
||
34 | __attribute__((tls_model("initial-exec"))); |
||
35 | |||
36 | extern __thread void *u_current_user |
||
37 | __attribute__((tls_model("initial-exec"))); |
||
38 | |||
39 | #else /* GLX_USE_TLS */ |
||
40 | |||
41 | extern struct mapi_table *u_current_table; |
||
42 | extern void *u_current_user; |
||
43 | |||
44 | #endif /* GLX_USE_TLS */ |
||
45 | |||
46 | #endif /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */ |
||
47 | |||
48 | void |
||
49 | u_current_init(void); |
||
50 | |||
51 | void |
||
52 | u_current_destroy(void); |
||
53 | |||
54 | void |
||
55 | u_current_set(const struct mapi_table *tbl); |
||
56 | |||
57 | struct mapi_table * |
||
58 | u_current_get_internal(void); |
||
59 | |||
60 | void |
||
61 | u_current_set_user(const void *ptr); |
||
62 | |||
63 | void * |
||
64 | u_current_get_user_internal(void); |
||
65 | |||
66 | static INLINE const struct mapi_table * |
||
67 | u_current_get(void) |
||
68 | { |
||
69 | #ifdef GLX_USE_TLS |
||
70 | return u_current_table; |
||
71 | #else |
||
72 | return (likely(u_current_table) ? |
||
73 | u_current_table : u_current_get_internal()); |
||
74 | #endif |
||
75 | } |
||
76 | |||
77 | static INLINE const void * |
||
78 | u_current_get_user(void) |
||
79 | { |
||
80 | #ifdef GLX_USE_TLS |
||
81 | return u_current_user; |
||
82 | #else |
||
83 | return likely(u_current_user) ? u_current_user : u_current_get_user_internal(); |
||
84 | #endif |
||
85 | } |
||
86 | |||
87 | #endif /* _U_CURRENT_H_ */ |