Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[xsrc/trunk]: xsrc/external/mit/MesaLib/dist/src Add workaround for non-zero ...
details: https://anonhg.NetBSD.org/xsrc/rev/5ae0c3222236
branches: trunk
changeset: 10265:5ae0c3222236
user: maya <maya%NetBSD.org@localhost>
date: Tue Apr 09 14:14:59 2019 +0000
description:
Add workaround for non-zero initialized initial-exec TLS variables.
NetBSD doesn't support these with dlopen.
Ref:
https://bugs.freedesktop.org/show_bug.cgi?id=35268
https://mail-index.netbsd.org/pkgsrc-users/2015/09/11/msg022180.html
http://gnats.netbsd.org/50277
Fixes dlopen of libGL reported by prlw1 on current users.
>From tnn, via pkgsrc/graphics/MesaLib*.
diffstat:
external/mit/MesaLib/dist/src/glx/glxclient.h | 4 ++++
external/mit/MesaLib/dist/src/glx/glxcurrent.c | 16 ++++++++++++++++
external/mit/MesaLib/dist/src/mapi/entry_x86-64_tls.h | 9 +++++++++
external/mit/MesaLib/dist/src/mapi/entry_x86_tls.h | 17 +++++++++++++++++
external/mit/MesaLib/dist/src/mapi/u_current.c | 8 ++++++++
external/mit/MesaLib/dist/src/mapi/u_current.h | 2 +-
6 files changed, 55 insertions(+), 1 deletions(-)
diffs (142 lines):
diff -r 057fb6f7fe5f -r 5ae0c3222236 external/mit/MesaLib/dist/src/glx/glxclient.h
--- a/external/mit/MesaLib/dist/src/glx/glxclient.h Sun Apr 07 19:35:43 2019 +0000
+++ b/external/mit/MesaLib/dist/src/glx/glxclient.h Tue Apr 09 14:14:59 2019 +0000
@@ -659,7 +659,11 @@
extern __thread void *__glX_tls_Context
__attribute__ ((tls_model("initial-exec")));
+#if defined(__NetBSD__)
+# define __glXGetCurrentContext() (likely(__glX_tls_Context) ? __glX_tls_Context : (void*)&dummyContext)
+#else
# define __glXGetCurrentContext() __glX_tls_Context
+#endif
# else
diff -r 057fb6f7fe5f -r 5ae0c3222236 external/mit/MesaLib/dist/src/glx/glxcurrent.c
--- a/external/mit/MesaLib/dist/src/glx/glxcurrent.c Sun Apr 07 19:35:43 2019 +0000
+++ b/external/mit/MesaLib/dist/src/glx/glxcurrent.c Tue Apr 09 14:14:59 2019 +0000
@@ -40,6 +40,18 @@
#include "glx_error.h"
/*
+ * MASSIVE KLUDGE!
+ * We need these to not be extern in libGL.so because of
+ * PR toolchain/50277
+ */
+#if defined(GLX_USE_TLS) && defined(__NetBSD__)
+_X_EXPORT __thread struct _glapi_table * _glapi_tls_Dispatch
+ __attribute__((tls_model("initial-exec"))) = NULL;
+_X_EXPORT __thread void * _glapi_tls_Context
+ __attribute__((tls_model("initial-exec")));
+#endif
+
+/*
** We setup some dummy structures here so that the API can be used
** even if no context is current.
*/
@@ -77,7 +89,11 @@
* \c __glXGetCurrentContext can be implemented as trivial macro.
*/
__thread void *__glX_tls_Context __attribute__ ((tls_model("initial-exec")))
+#if defined(__NetBSD__)
+ = NULL; /* non-zero initializers not supported with dlopen */
+#else
= &dummyContext;
+#endif
_X_HIDDEN void
__glXSetCurrentContext(struct glx_context * c)
diff -r 057fb6f7fe5f -r 5ae0c3222236 external/mit/MesaLib/dist/src/mapi/entry_x86-64_tls.h
--- a/external/mit/MesaLib/dist/src/mapi/entry_x86-64_tls.h Sun Apr 07 19:35:43 2019 +0000
+++ b/external/mit/MesaLib/dist/src/mapi/entry_x86-64_tls.h Tue Apr 09 14:14:59 2019 +0000
@@ -43,10 +43,19 @@
#ifndef __ILP32__
+#if defined(__NetBSD__) && defined(MAPI_MODE_GLAPI)
+#define STUB_ASM_CODE(slot) \
+ "movq " ENTRY_CURRENT_TABLE "@GOTTPOFF(%rip), %rax\n\t" \
+ "movq %fs:(%rax), %r11\n\t" \
+ "testq %r11, %r11\n\t" \
+ "cmoveq table_noop_array@GOTPCREL(%rip), %r11\n\t" \
+ "jmp *(8 * " slot ")(%r11)"
+#else
#define STUB_ASM_CODE(slot) \
"movq " ENTRY_CURRENT_TABLE "@GOTTPOFF(%rip), %rax\n\t" \
"movq %fs:(%rax), %r11\n\t" \
"jmp *(8 * " slot ")(%r11)"
+#endif
#else
diff -r 057fb6f7fe5f -r 5ae0c3222236 external/mit/MesaLib/dist/src/mapi/entry_x86_tls.h
--- a/external/mit/MesaLib/dist/src/mapi/entry_x86_tls.h Sun Apr 07 19:35:43 2019 +0000
+++ b/external/mit/MesaLib/dist/src/mapi/entry_x86_tls.h Tue Apr 09 14:14:59 2019 +0000
@@ -56,10 +56,27 @@
".balign 16\n" \
func ":"
+#if defined(__NetBSD__) && defined(MAPI_MODE_GLAPI)
+extern const mapi_func table_noop_array[];
+#define STUB_ASM_CODE(slot) \
+ "call x86_current_tls\n\t" \
+ "movl %gs:(%eax), %eax\n\t" \
+ "testl %eax, %eax\n\t" \
+ "je 1f\n\t" \
+ "jmp *(4 * " slot ")(%eax)\n\t" \
+ "1:\n\t" \
+ "call 2f\n" \
+ "2:\n\t" \
+ "popl %eax\n\t" \
+ "addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax\n\t" \
+ "movl table_noop_array@GOT(%eax), %eax\n\t" \
+ "jmp *(4 * " slot ")(%eax)"
+#else
#define STUB_ASM_CODE(slot) \
"call x86_current_tls\n\t" \
"movl %gs:(%eax), %eax\n\t" \
"jmp *(4 * " slot ")(%eax)"
+#endif
#define MAPI_TMP_STUB_ASM_GCC
#include "mapi_tmp.h"
diff -r 057fb6f7fe5f -r 5ae0c3222236 external/mit/MesaLib/dist/src/mapi/u_current.c
--- a/external/mit/MesaLib/dist/src/mapi/u_current.c Sun Apr 07 19:35:43 2019 +0000
+++ b/external/mit/MesaLib/dist/src/mapi/u_current.c Tue Apr 09 14:14:59 2019 +0000
@@ -101,7 +101,11 @@
__thread struct _glapi_table *u_current_table
__attribute__((tls_model("initial-exec")))
+#if defined(__NetBSD__)
+ = NULL; /* non-zero initializers not supported with dlopen */
+#else
= (struct _glapi_table *) table_noop_array;
+#endif
__thread void *u_current_context
__attribute__((tls_model("initial-exec")));
@@ -283,7 +287,11 @@
u_current_get_table_internal(void)
{
#if defined(GLX_USE_TLS)
+# if defined(__NetBSD__)
+ return (likely(u_current_table) ? u_current_table : (struct _glapi_table *) table_noop_array);
+# else
return u_current_table;
+# endif
#else
if (ThreadSafe)
return (struct _glapi_table *) tss_get(u_current_table_tsd);
diff -r 057fb6f7fe5f -r 5ae0c3222236 external/mit/MesaLib/dist/src/mapi/u_current.h
--- a/external/mit/MesaLib/dist/src/mapi/u_current.h Sun Apr 07 19:35:43 2019 +0000
+++ b/external/mit/MesaLib/dist/src/mapi/u_current.h Tue Apr 09 14:14:59 2019 +0000
@@ -65,7 +65,7 @@
static inline const struct _glapi_table *
u_current_get_table(void)
{
-#ifdef GLX_USE_TLS
+#if defined(GLX_USE_TLS) && !defined(__NetBSD__)
return u_current_table;
#else
return (likely(u_current_table) ?
Home |
Main Index |
Thread Index |
Old Index