@$(MKLIB) -o $(ESAPI) -static $(ESAPI_OBJECTS)
$(GLAPI_OBJECTS): %.o: $(GLAPI)/%.c
- $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
+ $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) -DMAPI_GLAPI_CURRENT $< -o $@
$(GLAPI_ASM_OBJECTS): %.o: $(GEN)/%.S
$(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
@$(MKLIB) -o $(TARGET) -static $(TARGET_OBJECTS)
$(GLAPI_OBJECTS): %.o: %.c
- $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
+ $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) -DMAPI_GLAPI_CURRENT $< -o $@
$(GLAPI_ASM_OBJECTS): %.o: %.S
$(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
'glapi_getproc.c',
'glapi_nop.c',
'glthread.c',
+ 'glapi.c',
]
mapi_sources = [
--- /dev/null
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.9
+ *
+ * Copyright (C) 2010 LunarG Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Chia-I Wu <olv@lunarg.com>
+ */
+
+#include "glapi/glapi.h"
+#include "mapi/u_current.h"
+
+/*
+ * Global variables, _glapi_get_context, and _glapi_get_dispatch are defined in
+ * u_current.c.
+ */
+
+#ifdef GLX_USE_TLS
+/* not used, but defined for compatibility */
+const struct _glapi_table *_glapi_Dispatch;
+const void *_glapi_Context;
+#endif /* GLX_USE_TLS */
+
+void
+_glapi_destroy_multithread(void)
+{
+ u_current_destroy();
+}
+
+void
+_glapi_check_multithread(void)
+{
+ u_current_init();
+}
+
+void
+_glapi_set_context(void *context)
+{
+ u_current_set_user((const void *) context);
+}
+
+void
+_glapi_set_dispatch(struct _glapi_table *dispatch)
+{
+ u_current_set((const struct mapi_table *) dispatch);
+}
glapi_entrypoint.c \
glapi_getproc.c \
glapi_nop.c \
- glthread.c
+ glthread.c \
+ glapi.c
X86_API = \
glapi_x86.S
__asm__(".text");
__asm__("x86_64_current_tls:\n\t"
- "movq u_current_table_tls@GOTTPOFF(%rip), %rax\n\t"
+ "movq u_current_table@GOTTPOFF(%rip), %rax\n\t"
"ret");
#define STUB_ASM_ENTRY(func) \
func ":"
#define STUB_ASM_CODE(slot) \
- "movq u_current_table_tls@GOTTPOFF(%rip), %rax\n\t" \
+ "movq u_current_table@GOTTPOFF(%rip), %rax\n\t" \
"movq %fs:(%rax), %r11\n\t" \
"jmp *(8 * " slot ")(%r11)"
"1:\n\t"
"popl %eax\n\t"
"addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax\n\t"
- "movl u_current_table_tls@GOTNTPOFF(%eax), %eax\n\t"
+ "movl u_current_table@GOTNTPOFF(%eax), %eax\n\t"
"ret");
#ifndef GLX_X86_READONLY_TEXT
/*@{*/
#if defined(GLX_USE_TLS)
-__thread struct mapi_table *u_current_table_tls
+__thread struct mapi_table *u_current_table
__attribute__((tls_model("initial-exec")))
= (struct mapi_table *) table_noop_array;
-__thread void *u_current_user_tls
+__thread void *u_current_user
__attribute__((tls_model("initial-exec")));
-const struct mapi_table *u_current_table;
-const void *u_current_user;
-
#else
struct mapi_table *u_current_table =
}
else if (knownID != u_thread_self()) {
ThreadSafe = 1;
- u_current_set_internal(NULL);
- u_current_set_user_internal(NULL);
+ u_current_set(NULL);
+ u_current_set_user(NULL);
}
CHECK_MULTITHREAD_UNLOCK();
}
* void from the real context pointer type.
*/
void
-u_current_set_user_internal(void *ptr)
+u_current_set_user(const void *ptr)
{
u_current_init();
#if defined(GLX_USE_TLS)
- u_current_user_tls = ptr;
+ u_current_user = (void *) ptr;
#elif defined(THREADS)
- u_tsd_set(&u_current_user_tsd, ptr);
- u_current_user = (ThreadSafe) ? NULL : ptr;
+ u_tsd_set(&u_current_user_tsd, (void *) ptr);
+ u_current_user = (ThreadSafe) ? NULL : (void *) ptr;
#else
- u_current_user = ptr;
+ u_current_user = (void *) ptr;
#endif
}
u_current_get_user_internal(void)
{
#if defined(GLX_USE_TLS)
- return u_current_user_tls;
+ return u_current_user;
#elif defined(THREADS)
return (ThreadSafe)
? u_tsd_get(&u_current_user_tsd)
* table (__glapi_noop_table).
*/
void
-u_current_set_internal(struct mapi_table *tbl)
+u_current_set(const struct mapi_table *tbl)
{
u_current_init();
stub_init_once();
if (!tbl)
- tbl = (struct mapi_table *) table_noop_array;
+ tbl = (const struct mapi_table *) table_noop_array;
#if defined(GLX_USE_TLS)
- u_current_table_tls = tbl;
+ u_current_table = (struct mapi_table *) tbl;
#elif defined(THREADS)
u_tsd_set(&u_current_table_tsd, (void *) tbl);
- u_current_table = (ThreadSafe) ? NULL : tbl;
+ u_current_table = (ThreadSafe) ? NULL : (void *) tbl;
#else
- u_current_table = tbl;
+ u_current_table = (struct mapi_table *) tbl;
#endif
}
u_current_get_internal(void)
{
#if defined(GLX_USE_TLS)
- return u_current_table_tls;
+ return u_current_table;
#elif defined(THREADS)
return (struct mapi_table *) ((ThreadSafe) ?
u_tsd_get(&u_current_table_tsd) : (void *) u_current_table);
/* ugly renames to match glapi.h */
#define mapi_table _glapi_table
-#define u_current_table_tls _glapi_tls_Dispatch
-#define u_current_user_tls _glapi_tls_Context
+#ifdef GLX_USE_TLS
+#define u_current_table _glapi_tls_Dispatch
+#define u_current_user _glapi_tls_Context
+#else
#define u_current_table _glapi_Dispatch
#define u_current_user _glapi_Context
+#endif
-#define u_current_destroy _glapi_destroy_multithread
-#define u_current_init _glapi_check_multithread
-#define u_current_set_internal _glapi_set_dispatch
#define u_current_get_internal _glapi_get_dispatch
-#define u_current_set_user_internal _glapi_set_context
#define u_current_get_user_internal _glapi_get_context
#define u_current_table_tsd _gl_DispatchTSD
#ifdef GLX_USE_TLS
-extern __thread struct mapi_table *u_current_table_tls
+extern __thread struct mapi_table *u_current_table
__attribute__((tls_model("initial-exec")));
-extern __thread void *u_current_user_tls
+extern __thread void *u_current_user
__attribute__((tls_model("initial-exec")));
-extern const struct mapi_table *u_current_table;
-extern const void *u_current_user;
-
#else /* GLX_USE_TLS */
extern struct mapi_table *u_current_table;
#endif /* GLX_USE_TLS */
+#endif /* MAPI_GLAPI_CURRENT */
+
void
u_current_init(void);
u_current_destroy(void);
void
-u_current_set_internal(struct mapi_table *tbl);
+u_current_set(const struct mapi_table *tbl);
struct mapi_table *
u_current_get_internal(void);
void
-u_current_set_user_internal(void *ptr);
+u_current_set_user(const void *ptr);
void *
u_current_get_user_internal(void);
-static INLINE void
-u_current_set(const struct mapi_table *tbl)
-{
- u_current_set_internal((struct mapi_table *) tbl);
-}
-
static INLINE const struct mapi_table *
u_current_get(void)
{
#ifdef GLX_USE_TLS
- return (const struct mapi_table *) u_current_table_tls;
+ return u_current_table;
#else
return (likely(u_current_table) ?
- (const struct mapi_table *) u_current_table : u_current_get_internal());
+ u_current_table : u_current_get_internal());
#endif
}
-static INLINE void
-u_current_set_user(void *ptr)
-{
- u_current_set_internal(ptr);
-}
-
-static INLINE void *
+static INLINE const void *
u_current_get_user(void)
{
#ifdef GLX_USE_TLS
- return u_current_user_tls;
+ return u_current_user;
#else
return likely(u_current_user) ? u_current_user : u_current_get_user_internal();
#endif
}
-#endif /* MAPI_GLAPI_CURRENT */
-
#endif /* _U_CURRENT_H_ */