OSDN Git Service

libmudflap/
authorjiez <jiez@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 23 Jan 2009 04:58:03 +0000 (04:58 +0000)
committerjiez <jiez@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 23 Jan 2009 04:58:03 +0000 (04:58 +0000)
* mf-impl.h (__mf_get_state, __mf_set_state): Don't use
__thread when TLS support is emulated.
* mf-hooks3.c (__mf_get_state, __mf_set_state): Likewise.
* mf-runtime.c (__mf_state_1): Likewise.
* configure.ac: Use GCC_CHECK_EMUTLS.
* configure: Regenerate.
* config.h.in: Regenerate.

config/
* tls.m4 (GCC_CHECK_EMUTLS): Define.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143583 138bc75d-0d04-0410-961f-82ee72b054a4

config/ChangeLog
config/tls.m4
libmudflap/ChangeLog
libmudflap/config.h.in
libmudflap/configure
libmudflap/configure.ac
libmudflap/mf-hooks3.c
libmudflap/mf-impl.h
libmudflap/mf-runtime.c

index c57ec35..feb73b9 100644 (file)
@@ -1,3 +1,7 @@
+2009-01-23  Jie Zhang  <jie.zhang@analog.com>
+
+       * tls.m4 (GCC_CHECK_EMUTLS): Define.
+
 2008-12-21  Andrew Pinski  <pinskia@gmail.com>
 
        PR target/38300
 2008-12-21  Andrew Pinski  <pinskia@gmail.com>
 
        PR target/38300
index acb123f..e77742c 100644 (file)
@@ -86,3 +86,21 @@ AC_DEFUN([GCC_CHECK_CC_TLS], [
     AC_DEFINE(HAVE_CC_TLS, 1,
              [Define to 1 if the target assembler supports thread-local storage.])
   fi])
     AC_DEFINE(HAVE_CC_TLS, 1,
              [Define to 1 if the target assembler supports thread-local storage.])
   fi])
+
+dnl Check whether TLS is emulated.
+AC_DEFUN([GCC_CHECK_EMUTLS], [
+  AC_CACHE_CHECK([whether the thread-local storage support is from emutls],
+                gcc_cv_use_emutls, [
+    gcc_cv_use_emutls=no
+    echo '__thread int a; int b; int main() { return a = b; }' > conftest.c
+    if AC_TRY_COMMAND(${CC-cc} -Werror -S -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD); then
+      if grep __emutls_get_address conftest.s > /dev/null; then
+       gcc_cv_use_emutls=yes
+      fi
+    fi
+    rm -f conftest.*
+    ])
+  if test "$gcc_cv_use_emutls" = "yes" ; then
+    AC_DEFINE(USE_EMUTLS, 1,
+             [Define to 1 if the target use emutls for thread-local storage.])
+  fi])
index 25dcdf9..e42a15b 100644 (file)
@@ -1,3 +1,13 @@
+2009-01-23  Jie Zhang  <jie.zhang@analog.com>
+
+       * mf-impl.h (__mf_get_state, __mf_set_state): Don't use
+       __thread when TLS support is emulated.
+       * mf-hooks3.c (__mf_get_state, __mf_set_state): Likewise.
+       * mf-runtime.c (__mf_state_1): Likewise.
+       * configure.ac: Use GCC_CHECK_EMUTLS.
+       * configure: Regenerate.
+       * config.h.in: Regenerate.
+
 2008-12-18  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * configure: Regenerate.
 2008-12-18  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * configure: Regenerate.
index 94b2b8a..0c88f61 100644 (file)
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
 
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
 
+/* Define to 1 if the target use emutls for thread-local storage. */
+#undef USE_EMUTLS
+
 /* Version number of package */
 #undef VERSION
 /* Version number of package */
 #undef VERSION
index ad10a2c..758ac8f 100755 (executable)
@@ -13028,6 +13028,37 @@ _ACEOF
 
   fi
 
 
   fi
 
+  echo "$as_me:$LINENO: checking whether the thread-local storage support is from emutls" >&5
+echo $ECHO_N "checking whether the thread-local storage support is from emutls... $ECHO_C" >&6
+if test "${gcc_cv_use_emutls+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+    gcc_cv_use_emutls=no
+    echo '__thread int a; int b; int main() { return a = b; }' > conftest.c
+    if { ac_try='${CC-cc} -Werror -S -o conftest.s conftest.c 1>&5'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+      if grep __emutls_get_address conftest.s > /dev/null; then
+       gcc_cv_use_emutls=yes
+      fi
+    fi
+    rm -f conftest.*
+
+fi
+echo "$as_me:$LINENO: result: $gcc_cv_use_emutls" >&5
+echo "${ECHO_T}$gcc_cv_use_emutls" >&6
+  if test "$gcc_cv_use_emutls" = "yes" ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define USE_EMUTLS 1
+_ACEOF
+
+  fi
+
                               ac_config_files="$ac_config_files Makefile testsuite/Makefile testsuite/mfconfig.exp"
 
 cat >confcache <<\_ACEOF
                               ac_config_files="$ac_config_files Makefile testsuite/Makefile testsuite/mfconfig.exp"
 
 cat >confcache <<\_ACEOF
index a22be27..8ce99a1 100644 (file)
@@ -265,6 +265,7 @@ fi
 
 # See if we support thread-local storage.
 GCC_CHECK_TLS
 
 # See if we support thread-local storage.
 GCC_CHECK_TLS
+GCC_CHECK_EMUTLS
 
 AC_CONFIG_FILES([Makefile testsuite/Makefile testsuite/mfconfig.exp])
 AC_OUTPUT
 
 AC_CONFIG_FILES([Makefile testsuite/Makefile testsuite/mfconfig.exp])
 AC_OUTPUT
index dec4cd6..5792a14 100644 (file)
@@ -78,7 +78,7 @@ DECLARE(int, pthread_create, pthread_t *thr, const pthread_attr_t *attr,
 /* Multithreading support hooks.  */
 
 
 /* Multithreading support hooks.  */
 
 
-#ifndef HAVE_TLS
+#if !defined(HAVE_TLS) || defined(USE_EMUTLS)
 /* We don't have TLS.  Ordinarily we could use pthread keys, but since we're
    commandeering malloc/free that presents a few problems.  The first is that
    we'll recurse from __mf_get_state to pthread_setspecific to malloc back to
 /* We don't have TLS.  Ordinarily we could use pthread keys, but since we're
    commandeering malloc/free that presents a few problems.  The first is that
    we'll recurse from __mf_get_state to pthread_setspecific to malloc back to
@@ -217,7 +217,7 @@ __mf_pthread_cleanup (void *arg)
   if (__mf_opts.heur_std_data)
     __mf_unregister (&errno, sizeof (errno), __MF_TYPE_GUESS);
 
   if (__mf_opts.heur_std_data)
     __mf_unregister (&errno, sizeof (errno), __MF_TYPE_GUESS);
 
-#ifndef HAVE_TLS
+#if !defined(HAVE_TLS) || defined(USE_EMUTLS)
   struct mf_thread_data *data = __mf_find_threadinfo (0);
   if (data)
     data->used_p = 0;
   struct mf_thread_data *data = __mf_find_threadinfo (0);
   if (data)
     data->used_p = 0;
index 728a58b..15d0b9a 100644 (file)
@@ -244,7 +244,7 @@ extern pthread_mutex_t __mf_biglock;
 #define UNLOCKTH() do {} while (0)
 #endif
 
 #define UNLOCKTH() do {} while (0)
 #endif
 
-#if defined(LIBMUDFLAPTH) && !defined(HAVE_TLS)
+#if defined(LIBMUDFLAPTH) && (!defined(HAVE_TLS) || defined(USE_EMUTLS))
 extern enum __mf_state_enum __mf_get_state (void);
 extern void __mf_set_state (enum __mf_state_enum);
 #else
 extern enum __mf_state_enum __mf_get_state (void);
 extern void __mf_set_state (enum __mf_state_enum);
 #else
index 79fdb32..93b895a 100644 (file)
@@ -178,7 +178,7 @@ struct __mf_options __mf_opts;
 int __mf_starting_p = 1;
 
 #ifdef LIBMUDFLAPTH
 int __mf_starting_p = 1;
 
 #ifdef LIBMUDFLAPTH
-#ifdef HAVE_TLS
+#if defined(HAVE_TLS) && !defined(USE_EMUTLS)
 __thread enum __mf_state_enum __mf_state_1 = reentrant;
 #endif
 #else
 __thread enum __mf_state_enum __mf_state_1 = reentrant;
 #endif
 #else