[PATCH 5/5] glx: Silence warnings when building with clang
Jeremy Huddleston
jeremyhu at freedesktop.org
Sat Apr 23 21:52:41 PDT 2011
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 freedesktop.org>
---
glx/glapi.c | 12 ++++++++----
glx/glapi.h | 6 ++++--
glx/glthread.h | 6 ++++--
include/dix-config.h.in | 3 +++
m4/ax_tls.m4 | 13 ++++++++++++-
5 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/glx/glapi.c b/glx/glapi.c
index 7cb8495..0a166ce 100644
--- a/glx/glapi.c
+++ b/glx/glapi.c
@@ -78,11 +78,15 @@ 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;
+#ifdef HAVE_TLS_MODEL
+__attribute__((tls_model("initial-exec")))
+#endif
+PUBLIC TLS struct _glapi_table * _glapi_tls_Dispatch = NULL;
-PUBLIC TLS void * _glapi_tls_Context
- __attribute__((tls_model("initial-exec")));
+#ifdef HAVE_TLS_MODEL
+__attribute__((tls_model("initial-exec")))
+#endif
+PUBLIC TLS 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..85c5ab7 100644
--- a/glx/glapi.h
+++ b/glx/glapi.h
@@ -83,8 +83,10 @@ 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")));
+#ifdef HAVE_TLS_MODEL
+__attribute__((tls_model("initial-exec")))
+#endif
+extern TLS 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..0375443 100644
--- a/glx/glthread.h
+++ b/glx/glthread.h
@@ -233,8 +233,10 @@ _glthread_SetTSD(_glthread_TSD *, void *);
#if defined(GLX_USE_TLS)
-extern TLS struct _glapi_table * _glapi_tls_Dispatch
- __attribute__((tls_model("initial-exec")));
+#ifdef HAVE_TLS_MODEL
+__attribute__((tls_model("initial-exec")))
+#endif
+extern TLS 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 14229b4..4fd49ef 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -450,6 +450,9 @@
/* If the compiler supports a TLS storage class define it to that here */
#undef TLS
+/* Is the __attribute((tls_model(...))) extension supported? */
+#undef HAVE_TLS_MODEL
+
/* Correctly set _XSERVER64 for OSX fat binaries */
#ifdef __APPLE__
#include "dix-config-apple-verbatim.h"
diff --git a/m4/ax_tls.m4 b/m4/ax_tls.m4
index 481c3d0..87c6f3c 100644
--- a/m4/ax_tls.m4
+++ b/m4/ax_tls.m4
@@ -16,6 +16,7 @@
# LICENSE
#
# Copyright (c) 2008 Alan Woodland <ajw05 at aber.ac.uk>
+# Copyright (c) 2011 Jeremy Huddleston <jeremyhu at freedesktop.org>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
@@ -64,11 +65,21 @@ AC_DEFUN([AX_TLS], [
)
esac
done
-])
+ ])
if test "$ac_cv_tls" != "none"; then
dnl AC_DEFINE([TLS], [], [If the compiler supports a TLS storage class define it to that here])
AC_DEFINE_UNQUOTED([TLS], $ac_cv_tls, [If the compiler supports a TLS storage class define it to that here])
+
+ 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"
+
+ if test "x$ac_cv_tls_model" = "xyes" ; then
+ AC_DEFINE([HAVE_TLS_MODEL], 1, [Is the __attribute((tls_model(...))) extension supported? ])
+ fi
fi
AC_MSG_RESULT($ac_cv_tls)
])
--
1.7.4.1
More information about the xorg-devel
mailing list