diff options
author | Jeremy Huddleston <jeremyhu@apple.com> | 2011-03-22 19:01:48 -0700 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@apple.com> | 2011-03-23 09:11:33 -0700 |
commit | c55baebf4ebf1887262cc16899eb297b9f284f6e (patch) | |
tree | d9349a14c71f893d8d08c0724a79fa7c6223efd3 | |
parent | 03f45df93469f6aef391e97007b9614e0770cc4c (diff) |
GLX: Support TLS with better portability
AX_TLS detects when toolchains support __thread or __declspec(thread),
but existing code assumed __thread.
This also adds a check to configure.ac to error out if TLS is requested
but unsupported.
Found-by: Tinderbox
http://tinderbox.x.org/builds/2011-03-22-0007
Regression-from: 82b1eaa6cad20f39dbf15573bdb3d62acbcd91f9
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Tom Fogal <tfogal@alumni.unh.edu>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | glx/glapi.c | 4 | ||||
-rw-r--r-- | glx/glapi.h | 2 | ||||
-rw-r--r-- | glx/glthread.h | 2 | ||||
-rw-r--r-- | include/dix-config.h.in | 3 |
5 files changed, 11 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac index b6811638d..9e04ff015 100644 --- a/configure.ac +++ b/configure.ac @@ -590,7 +590,10 @@ AC_ARG_ENABLE(aiglx, AS_HELP_STRING([--enable-aiglx], [Build accelerate [AIGLX=yes]) AX_TLS AC_ARG_ENABLE(glx-tls, AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: auto)]), - [GLX_USE_TLS=$enableval], + [GLX_USE_TLS=$enableval + if test "x$GLX_USE_TLS" = "xyes" && test "${ac_cv_tls}" = "none" ; then + AC_MSG_ERROR([GLX with TLS support requested, but the compiler does not support it.]) + fi], [GLX_USE_TLS=no if test "${ac_cv_tls}" != "none" ; then GLX_USE_TLS=yes diff --git a/glx/glapi.c b/glx/glapi.c index 209ae50c0..19576a775 100644 --- a/glx/glapi.c +++ b/glx/glapi.c @@ -184,11 +184,11 @@ static GLint NoOpUnused(void) /*@{*/ #if defined(GLX_USE_TLS) -PUBLIC __thread struct _glapi_table * _glapi_tls_Dispatch +PUBLIC TLS struct _glapi_table * _glapi_tls_Dispatch __attribute__((tls_model("initial-exec"))) = (struct _glapi_table *) __glapi_noop_table; -PUBLIC __thread void * _glapi_tls_Context +PUBLIC TLS void * _glapi_tls_Context __attribute__((tls_model("initial-exec"))); PUBLIC const struct _glapi_table *_glapi_Dispatch = NULL; diff --git a/glx/glapi.h b/glx/glapi.h index 80b53aa92..dec8328cd 100644 --- a/glx/glapi.h +++ b/glx/glapi.h @@ -83,7 +83,7 @@ typedef void (*_glapi_warning_func)(void *ctx, const char *str, ...); const extern void *_glapi_Context; const extern struct _glapi_table *_glapi_Dispatch; -extern __thread void * _glapi_tls_Context +extern TLS void * _glapi_tls_Context __attribute__((tls_model("initial-exec"))); # define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_tls_Context diff --git a/glx/glthread.h b/glx/glthread.h index 28793fcc7..140e2aa8e 100644 --- a/glx/glthread.h +++ b/glx/glthread.h @@ -233,7 +233,7 @@ _glthread_SetTSD(_glthread_TSD *, void *); #if defined(GLX_USE_TLS) -extern __thread struct _glapi_table * _glapi_tls_Dispatch +extern TLS struct _glapi_table * _glapi_tls_Dispatch __attribute__((tls_model("initial-exec"))); #define GET_DISPATCH() _glapi_tls_Dispatch diff --git a/include/dix-config.h.in b/include/dix-config.h.in index fc93f3ec1..fd9ecced2 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -444,6 +444,9 @@ /* Define to 1 if you have the `ffs' function. */ #undef HAVE_FFS +/* If the compiler supports a TLS storage class define it to that here */ +#undef TLS + /* Correctly set _XSERVER64 for OSX fat binaries */ #ifdef __APPLE__ #include "dix-config-apple-verbatim.h" |