| 1 | dnl Copyright © 2011 Apple Inc. |
| 2 | dnl |
| 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: |
| 9 | dnl |
| 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 |
| 12 | dnl Software. |
| 13 | dnl |
| 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. |
| 21 | dnl |
| 22 | dnl Authors: Jeremy Huddleston <jeremyhu@apple.com> |
| 23 | |
| 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, [ |
| 28 | ac_cv_tls=none |
| 29 | keywords="__thread __declspec(thread)" |
| 30 | for kw in $keywords ; do |
| 31 | AC_TRY_COMPILE([int $kw test;], [], ac_cv_tls=$kw ; break ;) |
| 32 | done |
| 33 | ]) |
| 34 | AC_MSG_RESULT($ac_cv_tls) |
| 35 | |
| 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, [ |
| 39 | save_CFLAGS="$CFLAGS" |
| 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) |
| 43 | CFLAGS="$save_CFLAGS" |
| 44 | ]) |
| 45 | AC_MSG_RESULT($ac_cv_tls_model) |
| 46 | |
| 47 | if test "x$ac_cv_tls_model" = "xyes" ; then |
| 48 | xorg_tls=$ac_cv_tls' __attribute__((tls_model("initial-exec")))' |
| 49 | else |
| 50 | xorg_tls=$ac_cv_tls |
| 51 | fi |
| 52 | |
| 53 | AC_DEFINE_UNQUOTED([TLS], $xorg_tls, [The compiler supported TLS storage class, prefering initial-exec if tls_model is supported]) |
| 54 | fi |
| 55 | ]) |