[PATCH v2] glx: Silence warnings when building with clang

Jamey Sharp jamey at minilop.net
Mon Apr 25 11:24:38 PDT 2011


OK, I understand your reluctance to touch code under a license you're
not comfortable with, but I don't think making the code more complicated
is the right way to fix this warning. If folks with a stake in the GLX
code want to comment, I'll happily defer to them, but personally I'd NAK
this patch and its predecessor.

Jamey

On Mon, Apr 25, 2011 at 11:09:00AM -0700, Jeremy Huddleston wrote:
> In file included from glapi.c:46:
> In file included from ./glapi.h:51:
> ./glthread.h:237:20: error: unknown attribute 'tls_model' ignored [-Werror,-Wunknown-attributes]
>     __attribute__((tls_model("initial-exec")));
>                    ^
> In file included from glapi.c:46:
> ./glapi.h:92:20: error: unknown attribute 'tls_model' ignored [-Werror,-Wunknown-attributes]
>     __attribute__((tls_model("initial-exec")));
>                    ^
> glapi.c:82:20: error: unknown attribute 'tls_model' ignored [-Werror,-Wunknown-attributes]
>     __attribute__((tls_model("initial-exec"))) = NULL;
>                    ^
> glapi.c:85:20: error: unknown attribute 'tls_model' ignored [-Werror,-Wunknown-attributes]
>     __attribute__((tls_model("initial-exec")));
>                    ^
> 4 errors generated.
> 
> Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
> ---
>  configure.ac            |   21 +++++++++++++++++++++
>  glx/glapi.c             |    6 ++----
>  glx/glapi.h             |    3 +--
>  glx/glthread.h          |    3 +--
>  include/dix-config.h.in |    3 +++
>  5 files changed, 28 insertions(+), 8 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 86e67f0..974861b 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -590,7 +590,28 @@ dnl GLX build options
>  AC_ARG_ENABLE(aiglx,          AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]),
>                                  [AIGLX=$enableval],
>                                  [AIGLX=yes])
> +
>  AX_TLS
> +if test "$ac_cv_tls" != "none"; then
> +  AC_MSG_CHECKING(if thread local storage (TLS) class supports the tls_model attribute)
> +
> +  AC_CACHE_VAL(ac_cv_tls_model, [
> +    save_CFLAGS="$CFLAGS"
> +    CFLAGS="$CFLAGS -Werror=unknown-attributes"
> +    AC_TRY_COMPILE([], [TLS int bar __attribute__((tls_model("initial-exec")));],
> +                   ac_cv_tls_model=yes, ac_cv_tls_model=no)
> +    CFLAGS="$save_CFLAGS"
> +  ])
> +
> +  AC_MSG_RESULT($ac_cv_tls_model)
> +
> +  ac_tls_initial_exec="$ac_cv_tls"
> +  if test "x$ac_cv_tls_model" = "xyes" ; then
> +    ac_tls_initial_exec="$ac_tls_initial_exec __attribute__((tls_model("initial-exec")))"
> +  fi
> +  AC_DEFINE_UNQUOTED([TLS_MODEL_INITIAL_EXEC], $ac_tls_initial_exec, [If the compiler supports the tls_model attribute, we prefer initial-exec])
> +fi
> +
>  AC_ARG_ENABLE(glx-tls,        AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: auto)]),
>                                  [GLX_USE_TLS=$enableval
>                                   if test "x$GLX_USE_TLS" = "xyes" && test "${ac_cv_tls}" = "none" ; then
> diff --git a/glx/glapi.c b/glx/glapi.c
> index 7cb8495..7ffffc2 100644
> --- a/glx/glapi.c
> +++ b/glx/glapi.c
> @@ -78,11 +78,9 @@ static void init_glapi_relocs(void);
>  /*@{*/
>  #if defined(GLX_USE_TLS)
>  
> -PUBLIC TLS struct _glapi_table * _glapi_tls_Dispatch
> -    __attribute__((tls_model("initial-exec"))) = NULL;
> +PUBLIC TLS_MODEL_INITIAL_EXEC struct _glapi_table * _glapi_tls_Dispatch = NULL;
>  
> -PUBLIC TLS void * _glapi_tls_Context
> -    __attribute__((tls_model("initial-exec")));
> +PUBLIC TLS_MODEL_INITIAL_EXEC void * _glapi_tls_Context;
>  
>  PUBLIC const struct _glapi_table *_glapi_Dispatch = NULL;
>  PUBLIC const void *_glapi_Context = NULL;
> diff --git a/glx/glapi.h b/glx/glapi.h
> index 6521f31..f837ef4 100644
> --- a/glx/glapi.h
> +++ b/glx/glapi.h
> @@ -83,8 +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 TLS void * _glapi_tls_Context
> -    __attribute__((tls_model("initial-exec")));
> +extern TLS_MODEL_INITIAL_EXEC void * _glapi_tls_Context;
>  
>  # define GET_CURRENT_CONTEXT(C)  GLcontext *C = (GLcontext *) _glapi_tls_Context
>  
> diff --git a/glx/glthread.h b/glx/glthread.h
> index 140e2aa..c558926 100644
> --- a/glx/glthread.h
> +++ b/glx/glthread.h
> @@ -233,8 +233,7 @@ _glthread_SetTSD(_glthread_TSD *, void *);
>  
>  #if defined(GLX_USE_TLS)
>  
> -extern TLS struct _glapi_table * _glapi_tls_Dispatch
> -    __attribute__((tls_model("initial-exec")));
> +extern TLS_MODEL_INITIAL_EXEC struct _glapi_table * _glapi_tls_Dispatch;
>  
>  #define GET_DISPATCH() _glapi_tls_Dispatch
>  
> diff --git a/include/dix-config.h.in b/include/dix-config.h.in
> index f00c767..9b2f053 100644
> --- a/include/dix-config.h.in
> +++ b/include/dix-config.h.in
> @@ -447,6 +447,9 @@
>  /* If the compiler supports a TLS storage class define it to that here */
>  #undef TLS
>  
> +/* If the compiler supports the tls_model attribute, we prefer initial-exec */
> +#undef TLS_MODEL_INITIAL_EXEC
> +
>  /* Correctly set _XSERVER64 for OSX fat binaries */
>  #ifdef __APPLE__
>  #include "dix-config-apple-verbatim.h"
> -- 
> 1.7.4.1
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.x.org/archives/xorg-devel/attachments/20110425/25b8f3e7/attachment.pgp>


More information about the xorg-devel mailing list