Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79524 - trunk/boost/asio/detail
From: chris_at_[hidden]
Date: 2012-07-15 00:35:09


Author: chris_kohlhoff
Date: 2012-07-15 00:35:08 EDT (Sun, 15 Jul 2012)
New Revision: 79524
URL: http://svn.boost.org/trac/boost/changeset/79524

Log:
Use the __thread keyword extension when compiling with gcc on linux x86.
Added:
   trunk/boost/asio/detail/keyword_tss_ptr.hpp (contents, props changed)
Text files modified:
   trunk/boost/asio/detail/config.hpp | 11 +++++++++++
   trunk/boost/asio/detail/tss_ptr.hpp | 6 ++++++
   2 files changed, 17 insertions(+), 0 deletions(-)

Modified: trunk/boost/asio/detail/config.hpp
==============================================================================
--- trunk/boost/asio/detail/config.hpp (original)
+++ trunk/boost/asio/detail/config.hpp 2012-07-15 00:35:08 EDT (Sun, 15 Jul 2012)
@@ -371,4 +371,15 @@
 # endif // !defined(UNDER_CE)
 #endif // !defined(BOOST_ASIO_DISABLE_SIGNAL)
 
+// Support for the __thread keyword extension.
+#if !defined(BOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION)
+# if defined(__linux__)
+# if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
+# if ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)
+# define BOOST_ASIO_HAS_THREAD_KEYWORD_EXTENSION 1
+# endif // ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)
+# endif // defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
+# endif // defined(__linux__)
+#endif // !defined(BOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION)
+
 #endif // BOOST_ASIO_DETAIL_CONFIG_HPP

Added: trunk/boost/asio/detail/keyword_tss_ptr.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/detail/keyword_tss_ptr.hpp 2012-07-15 00:35:08 EDT (Sun, 15 Jul 2012)
@@ -0,0 +1,72 @@
+//
+// detail/keyword_tss_ptr.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#ifndef BOOST_ASIO_DETAIL_KEYWORD_TSS_PTR_HPP
+#define BOOST_ASIO_DETAIL_KEYWORD_TSS_PTR_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/config.hpp>
+
+#if defined(BOOST_ASIO_HAS_THREAD_KEYWORD_EXTENSION)
+
+#include <boost/asio/detail/noncopyable.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+namespace detail {
+
+template <typename T>
+class keyword_tss_ptr
+ : private noncopyable
+{
+public:
+ // Constructor.
+ keyword_tss_ptr()
+ {
+ }
+
+ // Destructor.
+ ~keyword_tss_ptr()
+ {
+ }
+
+ // Get the value.
+ operator T*() const
+ {
+ return value_;
+ }
+
+ // Set the value.
+ void operator=(T* value)
+ {
+ value_ = value;
+ }
+
+private:
+ static __thread T* value_;
+};
+
+template <typename T>
+__thread T* keyword_tss_ptr<T>::value_;
+
+} // namespace detail
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#endif // defined(BOOST_ASIO_HAS_THREAD_KEYWORD_EXTENSION)
+
+#endif // BOOST_ASIO_DETAIL_KEYWORD_TSS_PTR_HPP

Modified: trunk/boost/asio/detail/tss_ptr.hpp
==============================================================================
--- trunk/boost/asio/detail/tss_ptr.hpp (original)
+++ trunk/boost/asio/detail/tss_ptr.hpp 2012-07-15 00:35:08 EDT (Sun, 15 Jul 2012)
@@ -19,6 +19,8 @@
 
 #if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS)
 # include <boost/asio/detail/null_tss_ptr.hpp>
+#elif defined(BOOST_ASIO_HAS_THREAD_KEYWORD_EXTENSION)
+# include <boost/asio/detail/keyword_tss_ptr.hpp>
 #elif defined(BOOST_WINDOWS)
 # include <boost/asio/detail/win_tss_ptr.hpp>
 #elif defined(BOOST_HAS_PTHREADS)
@@ -37,6 +39,8 @@
 class tss_ptr
 #if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS)
   : public null_tss_ptr<T>
+#elif defined(BOOST_ASIO_HAS_THREAD_KEYWORD_EXTENSION)
+ : public keyword_tss_ptr<T>
 #elif defined(BOOST_WINDOWS)
   : public win_tss_ptr<T>
 #elif defined(BOOST_HAS_PTHREADS)
@@ -48,6 +52,8 @@
   {
 #if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS)
     null_tss_ptr<T>::operator=(value);
+#elif defined(BOOST_ASIO_HAS_THREAD_KEYWORD_EXTENSION)
+ keyword_tss_ptr<T>::operator=(value);
 #elif defined(BOOST_WINDOWS)
     win_tss_ptr<T>::operator=(value);
 #elif defined(BOOST_HAS_PTHREADS)


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk