dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] [SCM] DotGNU Portable.NET engine, compilers and to


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] [SCM] DotGNU Portable.NET engine, compilers and tools (pnet) branch, master, updated. a04e057b5b034e20efebe577146072bed4655f0a
Date: Wed, 02 Sep 2009 09:35:31 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "DotGNU Portable.NET engine, compilers and tools (pnet)".

The branch, master has been updated
       via  a04e057b5b034e20efebe577146072bed4655f0a (commit)
      from  0a670419df553f7bbe3890f87fa9ed8c25744d47 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/pnet.git/commit/?id=a04e057b5b034e20efebe577146072bed4655f0a

commit a04e057b5b034e20efebe577146072bed4655f0a
Author: Klaus Treichel <address@hidden>
Date:   Wed Sep 2 11:35:01 2009 +0200

    Allow usage of compiler thread local storage if available with the
    configure switch --enable-tls and add support for pthreads.

diff --git a/ChangeLog b/ChangeLog
index 08c90c0..930eef6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2009-09-02  Klaus Treichel  <address@hidden>
+
+       * configure.in: Add configure switch --enable-tls to allow enabling
+       usage of thread local storage if the compiler and kernel support is
+       available.
+
+       * support/pt_defs.h: Check if thread local storage should be used and
+       use it for GCC for now. Change the declarations for _ILThreadGetSelf
+       and _ILThreadSetSelf for this case and declare the thread local
+       variable _myThread to hold the pointer to the current ILThread.
+
+       * support/pt_defs.c (_ILThreadInitSystem): Don't allocate a pthread key
+       for the current thread if compiler tls is used.
+       (ThreadStart): Simply store the current thread in _myThread if
+       compiler tls is used instead of calling pthread_setspecific.
+
 2009-09-01  Klaus Treichel  <address@hidden>
 
        * configure.in: Add checks for availability of pthread_mutex_timedlock,
diff --git a/configure.in b/configure.in
index 0f44ddc..fdd6133 100644
--- a/configure.in
+++ b/configure.in
@@ -102,6 +102,17 @@ if test x$interrupts = xtrue ; then
   AC_DEFINE(USE_INTERRUPT_BASED_CHECKS, 1, [Use interrupt based NullReference 
and other checks])
 fi
 
+dnl Enable use of thread local storage.
+AC_ARG_ENABLE(tls, AS_HELP_STRING([--enable-tls], [Use compiler supported 
thread local storage]),
+[case "${enableval}" in
+  yes) tls=true ;;
+  no)  tls=false ;;
+  *)   AC_MSG_ERROR(bad value ${enableval} for --enable-tls) ;;
+esac],[tls=false])
+if test x$tls = xtrue ; then
+  AC_DEFINE(USE_COMPILER_TLS, 1, [Use compiler supported thread local storage])
+fi
+
 dnl Check for file extensions.
 AC_EXEEXT
 AC_OBJEXT
diff --git a/support/pt_defs.c b/support/pt_defs.c
index bb60fcd..22d1db8 100755
--- a/support/pt_defs.c
+++ b/support/pt_defs.c
@@ -40,10 +40,19 @@
 extern "C" {
 #endif
 
+
+#if defined(USE_COMPILER_TLS)
+/*
+ * Define the thread local variable to hold the ILThread value for the
+ * current thread.
+ */
+_THREAD_ ILThread *_myThread;
+#else
 /*
  * Thread-specific key that is used to store and retrieve thread objects.
  */
 pthread_key_t _ILThreadObjectKey;
+#endif
 
 /*
  * Default mutex attribute.
@@ -164,8 +173,10 @@ void _ILThreadInitSystem(ILThread *mainThread)
        action.sa_handler = ResumeSignal;
        sigaction(IL_SIG_RESUME, &action, (struct sigaction *)0);
 
+#if !defined(USE_COMPILER_TLS)
        /* We need a thread-specific key for storing thread objects */
        pthread_key_create(&_ILThreadObjectKey, (void (*)(void *))0);
+#endif
 
        /* Initialize the mutexattr used on this system. */
        pthread_mutexattr_init(&_ILMutexAttr);
@@ -212,8 +223,13 @@ static void *ThreadStart(void *arg)
        thread->handle = pthread_self();
        thread->identifier = thread->handle;
 
+#if defined(USE_COMPILER_TLS)
+       /* Store the thread at the thread local storage */
+       _myThread = thread;
+#else
        /* Attach the thread object to the thread identifier */
        pthread_setspecific(_ILThreadObjectKey, (void *)thread);
+#endif
 
        /* Detach ourselves because we won't be using "pthread_join"
           to detect when the thread exits */
diff --git a/support/pt_defs.h b/support/pt_defs.h
index 9a22a79..11ca5e2 100755
--- a/support/pt_defs.h
+++ b/support/pt_defs.h
@@ -87,6 +87,17 @@ extern       "C" {
 #endif
 
 /*
+ * Determine if we are using compiler thread local storage
+ */
+#if defined(USE_COMPILER_TLS)
+#if !defined(__GNUC__)
+#undef USE_COMPILER_TLS
+#else
+#define _THREAD_ __thread
+#endif
+#endif
+
+/*
  * Types that are needed elsewhere.
  */
 typedef pthread_mutex_t                _ILMutex;
@@ -310,11 +321,17 @@ int _ILMonitorTimedWait(_ILMonitor *mon, ILUInt32 ms,
 /*
  * Get or set the thread object that is associated with "self".
  */
+#if defined(USE_COMPILER_TLS)
+extern _THREAD_ ILThread *_myThread;
+#define        _ILThreadGetSelf()                      (_myThread)
+#define        _ILThreadSetSelf(object)        (_myThread = (object))
+#else
 extern pthread_key_t _ILThreadObjectKey;
 #define        _ILThreadGetSelf()      \
                        ((ILThread *)(pthread_getspecific(_ILThreadObjectKey)))
 #define        _ILThreadSetSelf(object)        \
                        (pthread_setspecific(_ILThreadObjectKey, (object)))
+#endif
 
 /*
  * Call a function "once".

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog         |   16 ++++++++++++++++
 configure.in      |   11 +++++++++++
 support/pt_defs.c |   16 ++++++++++++++++
 support/pt_defs.h |   17 +++++++++++++++++
 4 files changed, 60 insertions(+), 0 deletions(-)


hooks/post-receive
-- 
DotGNU Portable.NET engine, compilers and tools (pnet)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]