ax_tls.m4 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # ===========================================================================
  2. # http://www.gnu.org/software/autoconf-archive/ax_tls.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_TLS([action-if-found], [action-if-not-found])
  8. #
  9. # DESCRIPTION
  10. #
  11. # Provides a test for the compiler support of thread local storage (TLS)
  12. # extensions. Defines TLS if it is found. Currently knows about GCC/ICC
  13. # and MSVC. I think SunPro uses the same as GCC, and Borland apparently
  14. # supports either.
  15. #
  16. # LICENSE
  17. #
  18. # Copyright (c) 2008 Alan Woodland <ajw05@aber.ac.uk>
  19. # Copyright (c) 2010 Diego Elio Petteno` <flameeyes@gmail.com>
  20. #
  21. # This program is free software: you can redistribute it and/or modify it
  22. # under the terms of the GNU General Public License as published by the
  23. # Free Software Foundation, either version 3 of the License, or (at your
  24. # option) any later version.
  25. #
  26. # This program is distributed in the hope that it will be useful, but
  27. # WITHOUT ANY WARRANTY; without even the implied warranty of
  28. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  29. # Public License for more details.
  30. #
  31. # You should have received a copy of the GNU General Public License along
  32. # with this program. If not, see <http://www.gnu.org/licenses/>.
  33. #
  34. # As a special exception, the respective Autoconf Macro's copyright owner
  35. # gives unlimited permission to copy, distribute and modify the configure
  36. # scripts that are the output of Autoconf when processing the Macro. You
  37. # need not follow the terms of the GNU General Public License when using
  38. # or distributing such scripts, even though portions of the text of the
  39. # Macro appear in them. The GNU General Public License (GPL) does govern
  40. # all other use of the material that constitutes the Autoconf Macro.
  41. #
  42. # This special exception to the GPL applies to versions of the Autoconf
  43. # Macro released by the Autoconf Archive. When you make and distribute a
  44. # modified version of the Autoconf Macro, you may extend this special
  45. # exception to the GPL to apply to your modified version as well.
  46. #serial 11
  47. # Define m4_ifblank and m4_ifnblank macros from introduced in
  48. # autotools 2.64 m4sugar.m4 if using an earlier autotools.
  49. ifdef([m4_ifblank], [], [
  50. m4_define([m4_ifblank],
  51. [m4_if(m4_translit([[$1]], [ ][ ][
  52. ]), [], [$2], [$3])])
  53. ])
  54. ifdef([m4_ifnblank], [], [
  55. m4_define([m4_ifnblank],
  56. [m4_if(m4_translit([[$1]], [ ][ ][
  57. ]), [], [$3], [$2])])
  58. ])
  59. AC_DEFUN([AX_TLS], [
  60. AC_MSG_CHECKING(for thread local storage (TLS) class)
  61. AC_CACHE_VAL(ac_cv_tls, [
  62. ax_tls_keywords="__thread __declspec(thread) none"
  63. for ax_tls_keyword in $ax_tls_keywords; do
  64. AS_CASE([$ax_tls_keyword],
  65. [none], [ac_cv_tls=none ; break],
  66. [AC_TRY_COMPILE(
  67. [#include <stdlib.h>
  68. static void
  69. foo(void) {
  70. static ] $ax_tls_keyword [ int bar;
  71. exit(1);
  72. }],
  73. [],
  74. [ac_cv_tls=$ax_tls_keyword ; break],
  75. ac_cv_tls=none
  76. )])
  77. done
  78. ])
  79. AC_MSG_RESULT($ac_cv_tls)
  80. AS_IF([test "$ac_cv_tls" != "none"],
  81. AC_DEFINE_UNQUOTED([TLS], $ac_cv_tls, [If the compiler supports a TLS storage class define it to that here])
  82. m4_ifnblank([$1], [$1]),
  83. m4_ifnblank([$2], [$2])
  84. )
  85. ])