1 dnl Copyright © 2011 Apple Inc.
3 dnl Permission is hereby granted, free of charge, to any person obtaining a
4 dnl copy of this software and associated documentation files (the "Software"),
5 dnl to deal in the Software without restriction, including without limitation
6 dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 dnl and/or sell copies of the Software, and to permit persons to whom the
8 dnl Software is furnished to do so, subject to the following conditions:
10 dnl The above copyright notice and this permission notice (including the next
11 dnl paragraph) shall be included in all copies or substantial portions of the
14 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 dnl DEALINGS IN THE SOFTWARE.
22 dnl Authors: Jeremy Huddleston <jeremyhu@apple.com>
24 AC_DEFUN([XORG_TLS], [
25 AC_REQUIRE([XORG_STRICT_OPTION])
26 AC_MSG_CHECKING(for thread local storage (TLS) support)
27 AC_CACHE_VAL(ac_cv_tls, [
29 keywords="__thread __declspec(thread)"
30 for kw in $keywords ; do
31 AC_TRY_COMPILE([int $kw test;], [], ac_cv_tls=$kw ; break ;)
34 AC_MSG_RESULT($ac_cv_tls)
36 if test "$ac_cv_tls" != "none"; then
37 AC_MSG_CHECKING(for tls_model attribute support)
38 AC_CACHE_VAL(ac_cv_tls_model, [
40 CFLAGS="$CFLAGS $STRICT_CFLAGS"
41 AC_TRY_COMPILE([int $ac_cv_tls __attribute__((tls_model("initial-exec"))) test;], [],
42 ac_cv_tls_model=yes, ac_cv_tls_model=no)
45 AC_MSG_RESULT($ac_cv_tls_model)
47 if test "x$ac_cv_tls_model" = "xyes" ; then
48 xorg_tls=$ac_cv_tls' __attribute__((tls_model("initial-exec")))'
53 AC_DEFINE_UNQUOTED([TLS], $xorg_tls, [The compiler supported TLS storage class, prefering initial-exec if tls_model is supported])