(LIBUNWIND__THREAD): New test.

(Logical change 1.22)
diff --git a/aclocal.m4 b/aclocal.m4
index 14d1253..374f9cd 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -946,7 +946,7 @@
 	 m4_ifndef([_AM_Config_Header_Index], m4_define([_AM_Config_Header_Index], [0]))
 	 dnl prepare to store our destination file list for use in config.status
 	 AC_FOREACH([_AM_File], [$1],
-		    [m4_pushdef([_AM_Dest], m4_patsubst(_AM_File, [:.*]))
+		    [m4_pushdef([_AM_Dest], patsubst(_AM_File, [:.*]))
 		    m4_define([_AM_Config_Header_Index], m4_incr(_AM_Config_Header_Index))
 		    dnl and add it to the list of files AC keeps track of, along
 		    dnl with our hook
@@ -987,12 +987,31 @@
 # -----------------
 # Like AS_DIRNAME, only do it during macro expansion
 AC_DEFUN([_AM_DIRNAME],
-       [m4_if(m4_regexp([$1], [^.*[^/]//*[^/][^/]*/*$]), -1,
-	      m4_if(m4_regexp([$1], [^//\([^/]\|$\)]), -1,
-		    m4_if(m4_regexp([$1], [^/.*]), -1,
+       [m4_if(regexp([$1], [^.*[^/]//*[^/][^/]*/*$]), -1,
+	      m4_if(regexp([$1], [^//\([^/]\|$\)]), -1,
+		    m4_if(regexp([$1], [^/.*]), -1,
 			  [.],
-			  m4_patsubst([$1], [^\(/\).*], [\1])),
-		    m4_patsubst([$1], [^\(//\)\([^/].*\|$\)], [\1])),
-	      m4_patsubst([$1], [^\(.*[^/]\)//*[^/][^/]*/*$], [\1]))[]dnl
+			  patsubst([$1], [^\(/\).*], [\1])),
+		    patsubst([$1], [^\(//\)\([^/].*\|$\)], [\1])),
+	      patsubst([$1], [^\(.*[^/]\)//*[^/][^/]*/*$], [\1]))[]dnl
 ]) # _AM_DIRNAME
 
+AC_DEFUN([LIBUNWIND___THREAD],
+[dnl Check whether the compiler supports the __thread keyword.
+if test "x$use__thread" != xno; then
+  AC_CACHE_CHECK([for __thread], libc_cv_gcc___thread,
+		 [cat > conftest.c <<\EOF
+    __thread int a = 42;
+EOF
+  if AC_TRY_COMMAND([${CC-cc} $CFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then
+    libc_cv_gcc___thread=yes
+  else
+    libc_cv_gcc___thread=no
+  fi
+  rm -f conftest*])
+  if test "$libc_cv_gcc___thread" = yes; then
+    AC_DEFINE(HAVE___THREAD)
+  fi
+else
+  libc_cv_gcc___thread=no
+fi])