From 76e097956175fd03e1cf8d247a39fe105a944e1a Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Tue, 20 Nov 2007 07:41:38 +0000 Subject: [PATCH] Merged revisions 41161-41246 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r41161 | bemandawes | 2007-11-16 15:21:47 -0800 (Fri, 16 Nov 2007) | 1 line Fix markup error ........ r41163 | bgubenko | 2007-11-16 17:28:10 -0800 (Fri, 16 Nov 2007) | 1 line mark some fusion library tests for acc toolset ........ r41164 | djowel | 2007-11-16 17:51:04 -0800 (Fri, 16 Nov 2007) | 1 line fix for trac ticket #1450 ........ r41165 | lbourdev | 2007-11-16 19:38:25 -0800 (Fri, 16 Nov 2007) | 10 lines Updated to version 2.1.2 Added support for more compilers. Added new flag GIL_NONWORD_POINTER_ALIGNMENT_SUPPORTED to indicate whether dereferencing on non-word boundary is supported. Enabling this flag improves performance. Fixed two bugs related to non-byte-aligned images. The image alignment parameter is now specified in bytes, and has a default of 0, which means "packed" alignment. In particular, for non-byte-aligned images alignment of 0 means there are no padding bits at the ends of rows. Added the allocator as an optional parameter to image constructors and image recreate methods. ........ r41167 | grafik | 2007-11-16 20:11:49 -0800 (Fri, 16 Nov 2007) | 1 line Add "--out-xml=xyz.xml" option that dumps the output of all actions, and the test.jam information, to the given file. Changes are mostly from Dave. ........ r41169 | johnmaddock | 2007-11-17 02:00:43 -0800 (Sat, 17 Nov 2007) | 1 line Ooops, check on wrong index, now fixed. ........ r41170 | johnmaddock | 2007-11-17 04:17:05 -0800 (Sat, 17 Nov 2007) | 1 line Fix WinCE issues. ........ r41172 | johnmaddock | 2007-11-17 10:41:29 -0800 (Sat, 17 Nov 2007) | 1 line Changed test to catch throw exceptions from thread creation. ........ r41173 | bemandawes | 2007-11-17 12:13:16 -0800 (Sat, 17 Nov 2007) | 1 line // Add or correct comment identifying Boost library this header is associated with. ........ r41174 | grafik | 2007-11-17 12:14:24 -0800 (Sat, 17 Nov 2007) | 1 line Add in Dave's comments, and expand information in XML output to include action names, sources, properties, bjam info, and platform info. This required one minor change to actions to keep track of the action object generating the targets. ........ r41175 | nesotto | 2007-11-17 12:22:05 -0800 (Sat, 17 Nov 2007) | 1 line minor update of comments ........ r41176 | nesotto | 2007-11-17 12:22:20 -0800 (Sat, 17 Nov 2007) | 1 line last updates ........ r41177 | nesotto | 2007-11-17 12:44:29 -0800 (Sat, 17 Nov 2007) | 1 line works after local test with vc8 ........ r41178 | nesotto | 2007-11-17 13:02:22 -0800 (Sat, 17 Nov 2007) | 1 line added missing header ........ r41180 | nesotto | 2007-11-17 13:19:13 -0800 (Sat, 17 Nov 2007) | 1 line iostream macro patch ........ r41181 | nesotto | 2007-11-17 13:21:53 -0800 (Sat, 17 Nov 2007) | 1 line removed some warnings ........ r41182 | grafik | 2007-11-17 13:22:40 -0800 (Sat, 17 Nov 2007) | 1 line Add working dir to build description, move jam version to an attribute. ........ r41183 | nesotto | 2007-11-17 13:24:16 -0800 (Sat, 17 Nov 2007) | 1 line macro patch ........ r41185 | nesotto | 2007-11-17 13:43:32 -0800 (Sat, 17 Nov 2007) | 1 line minor change to define the value type of the iterators better ........ r41186 | grafik | 2007-11-17 14:09:26 -0800 (Sat, 17 Nov 2007) | 1 line Change "actual" to the more natural "target", and change "target" to "path". Add bjam command and bb version to XML. ........ r41187 | bemandawes | 2007-11-17 14:48:06 -0800 (Sat, 17 Nov 2007) | 1 line Add or correct comment identifying Boost library this header is associated with. ........ r41188 | andreas_huber69 | 2007-11-17 16:08:46 -0800 (Sat, 17 Nov 2007) | 1 line Added markup for statechart failures on msvc-8.0~wm5~stlport5.1 ........ r41192 | grafik | 2007-11-17 22:42:14 -0800 (Sat, 17 Nov 2007) | 1 line Add to XML output the known targets and dependencies to allow creation of the full build dependency graph. Merge from Dave's Bitten branch. ........ r41193 | johnmaddock | 2007-11-18 02:07:14 -0800 (Sun, 18 Nov 2007) | 1 line Ooops: previous commit broke platforms/compilers with no long double support, added workaround as fix. ........ r41194 | igaztanaga | 2007-11-18 02:41:57 -0800 (Sun, 18 Nov 2007) | 1 line Interprocess changes to support systems with filesystem-based shared memory ........ r41195 | igaztanaga | 2007-11-18 02:43:35 -0800 (Sun, 18 Nov 2007) | 1 line Added scapegoat trees and an option to store the hash value in the hook for unordered containers ........ r41196 | igaztanaga | 2007-11-18 02:44:56 -0800 (Sun, 18 Nov 2007) | 1 line Added scapegoat trees and an option to store the hash value in the hook for unordered containers ........ r41197 | igaztanaga | 2007-11-18 02:51:19 -0800 (Sun, 18 Nov 2007) | 1 line Interprocess changes to support systems with filesystem-based shared memory ........ r41198 | igaztanaga | 2007-11-18 02:54:48 -0800 (Sun, 18 Nov 2007) | 1 line Interprocess changes to support systems with filesystem-based shared memory ........ r41199 | johnmaddock | 2007-11-18 04:23:37 -0800 (Sun, 18 Nov 2007) | 1 line Added missing template argument to specialisations. ........ r41200 | johnmaddock | 2007-11-18 04:24:42 -0800 (Sun, 18 Nov 2007) | 1 line Fix IMB xlc error limits, added workarounds where these were missed by the last commit. ........ r41201 | t_schwinger | 2007-11-18 06:06:47 -0800 (Sun, 18 Nov 2007) | 3 lines adds comment to fusion aCC failure markup ........ r41202 | danieljames | 2007-11-18 08:10:12 -0800 (Sun, 18 Nov 2007) | 2 lines Move the instructions for running regression tests to the new site. Fixes #1265. ........ r41210 | danieljames | 2007-11-18 12:18:04 -0800 (Sun, 18 Nov 2007) | 2 lines Move the 'implementation variations' page to the new site. Fixes #1355. ........ r41211 | eric_niebler | 2007-11-18 12:19:55 -0800 (Sun, 18 Nov 2007) | 1 line vc6 doesn't like BOOST_MPL_ASSERT_MSG ........ r41212 | grafik | 2007-11-18 12:24:25 -0800 (Sun, 18 Nov 2007) | 1 line Inspection report fixes. ........ r41213 | grafik | 2007-11-18 12:53:28 -0800 (Sun, 18 Nov 2007) | 1 line Cleanup tools/regression to remove obsolete runner scripts, move existing docs to doc subdir, and clean html docs into valid xhtml. ........ r41214 | grafik | 2007-11-18 13:02:51 -0800 (Sun, 18 Nov 2007) | 1 line Add missing include, for std::strchr function. ........ r41215 | grafik | 2007-11-18 13:07:26 -0800 (Sun, 18 Nov 2007) | 1 line Add keyword tags. ........ r41216 | niels_dekker | 2007-11-18 14:11:57 -0800 (Sun, 18 Nov 2007) | 1 line Code refactoring: removed private base classes of value_initialized, as suggested by Fernando Cacciola. ........ r41217 | djowel | 2007-11-18 16:05:43 -0800 (Sun, 18 Nov 2007) | 1 line added link to docs ........ r41218 | johnmaddock | 2007-11-19 02:02:16 -0800 (Mon, 19 Nov 2007) | 1 line Oops: added missing template specialisation argument. ........ r41219 | johnmaddock | 2007-11-19 02:20:36 -0800 (Mon, 19 Nov 2007) | 1 line No user32.lib on WinCE ........ r41220 | joaquin | 2007-11-19 03:08:11 -0800 (Mon, 19 Nov 2007) | 1 line moved some ADL stuff out of a potentially name-hiding scope ........ r41221 | troyer | 2007-11-19 04:15:58 -0800 (Mon, 19 Nov 2007) | 1 line made complex seriaqlization more portable ........ r41222 | anthonyw | 2007-11-19 04:17:31 -0800 (Mon, 19 Nov 2007) | 1 line fixed TSS cleanup on 64-bit Windows ........ r41223 | anthonyw | 2007-11-19 04:29:14 -0800 (Mon, 19 Nov 2007) | 1 line fixed problems with TSS cleanup when using LoadLibrary and when threads finish after thread_specific_ptr instance has been destroyed ........ r41224 | garcia | 2007-11-19 05:28:00 -0800 (Mon, 19 Nov 2007) | 2 lines A bunch of review volunteers. ........ r41225 | garcia | 2007-11-19 06:01:34 -0800 (Mon, 19 Nov 2007) | 2 lines Added boost.range update ........ r41226 | anthonyw | 2007-11-19 06:29:22 -0800 (Mon, 19 Nov 2007) | 1 line added copyright ........ r41227 | aaron_windsor | 2007-11-19 07:28:26 -0800 (Mon, 19 Nov 2007) | 1 line Cleaning up #includes to avoid errors on gcc 4.1 and above. ........ r41234 | igaztanaga | 2007-11-19 08:55:23 -0800 (Mon, 19 Nov 2007) | 1 line Fixed errors detected by gcc-4.3 ........ r41235 | hljin | 2007-11-19 09:26:12 -0800 (Mon, 19 Nov 2007) | 1 line GIL: updated the design guide based on the new changes ........ r41236 | grafik | 2007-11-19 09:44:31 -0800 (Mon, 19 Nov 2007) | 1 line Make quietly actions really quiet by not printing the command output. The output for the quietly actions is still available through "__ACTION_RULE__". ........ r41237 | grafik | 2007-11-19 10:02:43 -0800 (Mon, 19 Nov 2007) | 1 line Add architecture and instruction-set values for HP/PA-RISC. ........ r41238 | igaztanaga | 2007-11-19 10:09:13 -0800 (Mon, 19 Nov 2007) | 1 line Corrected ifdef ........ r41240 | igaztanaga | 2007-11-19 10:32:12 -0800 (Mon, 19 Nov 2007) | 1 line Fixed 64 bit std::size_t specialization error ........ r41241 | hljin | 2007-11-19 10:34:59 -0800 (Mon, 19 Nov 2007) | 1 line GIL: broke the main test into small tests ........ r41242 | bgubenko | 2007-11-19 11:25:21 -0800 (Mon, 19 Nov 2007) | 1 line add OSPLAT=PARISC for HP-UX PA-RISC ........ [SVN r41247] --- include/boost/thread.hpp | 2 + .../boost/thread/win32/thread_heap_alloc.hpp | 16 +----- include/boost/thread/win32/tss.hpp | 55 +++++++++++++------ src/win32/thread.cpp | 40 ++++---------- src/win32/tss_pe.cpp | 12 +++- 5 files changed, 64 insertions(+), 61 deletions(-) diff --git a/include/boost/thread.hpp b/include/boost/thread.hpp index b9a9ed68..625e69ec 100644 --- a/include/boost/thread.hpp +++ b/include/boost/thread.hpp @@ -4,6 +4,8 @@ // 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) +// See www.boost.org/libs/thread for documentation. + #if !defined(BOOST_THREAD_WEK01082003_HPP) #define BOOST_THREAD_WEK01082003_HPP diff --git a/include/boost/thread/win32/thread_heap_alloc.hpp b/include/boost/thread/win32/thread_heap_alloc.hpp index 1835e35e..ee47e0e6 100644 --- a/include/boost/thread/win32/thread_heap_alloc.hpp +++ b/include/boost/thread/win32/thread_heap_alloc.hpp @@ -156,25 +156,13 @@ namespace boost } template - struct do_delete + struct do_heap_delete { - T* data; - - do_delete(T* data_): - data(data_) - {} - - void operator()() const + void operator()(T* data) const { detail::heap_delete(data); } }; - - template - do_delete make_heap_deleter(T* data) - { - return do_delete(data); - } } } diff --git a/include/boost/thread/win32/tss.hpp b/include/boost/thread/win32/tss.hpp index a99dfac4..fcf792bd 100644 --- a/include/boost/thread/win32/tss.hpp +++ b/include/boost/thread/win32/tss.hpp @@ -1,13 +1,26 @@ #ifndef BOOST_THREAD_WIN32_TSS_HPP #define BOOST_THREAD_WIN32_TSS_HPP +// 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) +// (C) Copyright 2007 Anthony Williams + +#include +#include "thread_heap_alloc.hpp" namespace boost { namespace detail { - typedef void(*tss_cleanup_function)(void const* key,void* value); + struct tss_cleanup_function + { + virtual ~tss_cleanup_function() + {} + + virtual void operator()(void* data)=0; + }; - BOOST_THREAD_DECL void set_tss_data(void const* key,tss_cleanup_function func,void* tss_data,bool cleanup_existing); + BOOST_THREAD_DECL void set_tss_data(void const* key,boost::shared_ptr func,void* tss_data,bool cleanup_existing); BOOST_THREAD_DECL void* get_tss_data(void const* key); } @@ -18,31 +31,39 @@ namespace boost thread_specific_ptr(thread_specific_ptr&); thread_specific_ptr& operator=(thread_specific_ptr&); - static void delete_data(void const* self,void* value) + struct delete_data: + detail::tss_cleanup_function { - static_cast(self)->cleanup((T*)value); - } + void operator()(void* data) + { + delete static_cast(data); + } + }; - void cleanup(T* data) const + struct run_custom_cleanup_function: + detail::tss_cleanup_function { - if(func) + void (*cleanup_function)(T*); + + explicit run_custom_cleanup_function(void (*cleanup_function_)(T*)): + cleanup_function(cleanup_function_) + {} + + void operator()(void* data) { - func(data); + cleanup_function(data); } - else - { - delete data; - } - } + }; - void (*func)(T*); + + boost::shared_ptr cleanup; public: thread_specific_ptr(): - func(0) + cleanup(detail::heap_new(),detail::do_heap_delete()) {} explicit thread_specific_ptr(void (*func_)(T*)): - func(func_) + cleanup(detail::heap_new(func_),detail::do_heap_delete()) {} ~thread_specific_ptr() { @@ -72,7 +93,7 @@ namespace boost T* const current_value=get(); if(current_value!=new_value) { - detail::set_tss_data(this,delete_data,new_value,true); + detail::set_tss_data(this,cleanup,new_value,true); } } }; diff --git a/src/win32/thread.cpp b/src/win32/thread.cpp index fee2b4fd..9df6a05a 100644 --- a/src/win32/thread.cpp +++ b/src/win32/thread.cpp @@ -20,28 +20,6 @@ namespace boost { namespace { -#if defined(_MSC_VER) && !defined(UNDER_CE) - __declspec(thread) detail::thread_data_base* current_thread_data=0; - detail::thread_data_base* get_current_thread_data() - { - return current_thread_data; - } - void set_current_thread_data(detail::thread_data_base* new_data) - { - current_thread_data=new_data; - } -#elif defined(__BORLANDC__) - detail::thread_data_base* __thread current_thread_data=0; - detail::thread_data_base* get_current_thread_data() - { - return current_thread_data; - } - void set_current_thread_data(detail::thread_data_base* new_data) - { - current_thread_data=new_data; - } -#else - boost::once_flag current_thread_tls_init_flag=BOOST_ONCE_INIT; DWORD current_thread_tls_key=0; @@ -62,7 +40,6 @@ namespace boost boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key); BOOST_VERIFY(TlsSetValue(current_thread_tls_key,new_data)); } -#endif #ifdef BOOST_NO_THREADEX // Windows CE doesn't define _beginthreadex @@ -135,11 +112,11 @@ namespace boost struct tss_data_node { void const* key; - boost::detail::tss_cleanup_function func; + boost::shared_ptr func; void* value; tss_data_node* next; - tss_data_node(void const* key_,boost::detail::tss_cleanup_function func_,void* value_, + tss_data_node(void const* key_,boost::shared_ptr func_,void* value_, tss_data_node* next_): key(key_),func(func_),value(value_),next(next_) {} @@ -173,7 +150,7 @@ namespace boost current_thread_data->tss_data=current_node->next; if(current_node->func) { - (*current_node->func)(current_node->key,current_node->value); + (*current_node->func)(current_node->value); } boost::detail::heap_delete(current_node); } @@ -489,7 +466,12 @@ namespace boost { void add_thread_exit_function(thread_exit_function_base* func) { - detail::thread_data_base* const current_thread_data(get_current_thread_data()); + detail::thread_data_base* current_thread_data(get_current_thread_data()); + if(!current_thread_data) + { + make_external_thread_data(); + current_thread_data=get_current_thread_data(); + } thread_exit_callback_node* const new_node= heap_new(func, current_thread_data->thread_exit_callbacks); @@ -523,14 +505,14 @@ namespace boost return NULL; } - void set_tss_data(void const* key,tss_cleanup_function func,void* tss_data,bool cleanup_existing) + void set_tss_data(void const* key,boost::shared_ptr func,void* tss_data,bool cleanup_existing) { tss_cleanup_implemented(); // if anyone uses TSS, we need the cleanup linked in if(tss_data_node* const current_node=find_tss_data(key)) { if(cleanup_existing && current_node->func) { - (current_node->func)(current_node->key,current_node->value); + (*current_node->func)(current_node->value); } current_node->func=func; current_node->value=tss_data; diff --git a/src/win32/tss_pe.cpp b/src/win32/tss_pe.cpp index 3aef63a1..4528b90f 100644 --- a/src/win32/tss_pe.cpp +++ b/src/win32/tss_pe.cpp @@ -120,6 +120,16 @@ extern "C" const IMAGE_TLS_DIRECTORY32 _tls_used __attribute__ ((section(".rdata //The .CRT$Xxx information is taken from Codeguru: //http://www.codeguru.com/Cpp/misc/misc/threadsprocesses/article.php/c6945__2/ +#if (_MSC_VER >= 1400) +#pragma section(".CRT$XIU",long,read) +#pragma section(".CRT$XCU",long,read) +#pragma section(".CRT$XTU",long,read) +#pragma section(".CRT$XLC",long,read) + static __declspec(allocate(".CRT$XLC")) _TLSCB __xl_ca=on_tls_callback; + static __declspec(allocate(".CRT$XIU"))_PVFV p_tls_prepare = on_tls_prepare; + static __declspec(allocate(".CRT$XCU"))_PVFV p_process_init = on_process_init; + static __declspec(allocate(".CRT$XTU"))_PVFV p_process_term = on_process_term; +#else #if (_MSC_VER >= 1300) // 1300 == VC++ 7.0 # pragma data_seg(push, old_seg) #endif @@ -144,7 +154,6 @@ extern "C" const IMAGE_TLS_DIRECTORY32 _tls_used __attribute__ ((section(".rdata #pragma data_seg(".CRT$XLB") _TLSCB p_thread_callback = on_tls_callback; #pragma data_seg() - //Callback for termination. #pragma data_seg(".CRT$XTU") @@ -153,6 +162,7 @@ extern "C" const IMAGE_TLS_DIRECTORY32 _tls_used __attribute__ ((section(".rdata #if (_MSC_VER >= 1300) // 1300 == VC++ 7.0 # pragma data_seg(pop, old_seg) #endif +#endif PVAPI on_tls_prepare(void) {