|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62636 - in trunk: boost/thread/detail libs/thread/src/win32
From: anthony_at_[hidden]
Date: 2010-06-09 03:37:48
Author: anthonyw
Date: 2010-06-09 03:37:44 EDT (Wed, 09 Jun 2010)
New Revision: 62636
URL: http://svn.boost.org/trac/boost/changeset/62636
Log:
Moved thread startup and shutdown hooks to namespace boost
Text files modified:
trunk/boost/thread/detail/tss_hooks.hpp | 33 ++++++---------------------
trunk/libs/thread/src/win32/thread.cpp | 24 ++++++++++----------
trunk/libs/thread/src/win32/tss_dll.cpp | 18 +++++++++-----
trunk/libs/thread/src/win32/tss_pe.cpp | 47 ++++++++++++++++-----------------------
4 files changed, 50 insertions(+), 72 deletions(-)
Modified: trunk/boost/thread/detail/tss_hooks.hpp
==============================================================================
--- trunk/boost/thread/detail/tss_hooks.hpp (original)
+++ trunk/boost/thread/detail/tss_hooks.hpp 2010-06-09 03:37:44 EDT (Wed, 09 Jun 2010)
@@ -12,27 +12,9 @@
#if defined(BOOST_HAS_WINTHREADS)
- typedef void (__cdecl *thread_exit_handler)(void);
-
- extern "C" BOOST_THREAD_DECL int at_thread_exit(
- thread_exit_handler exit_handler
- );
- //Add a function to the list of functions that will
- //be called when a thread is about to exit.
- //Currently only implemented for Win32, but should
- //later be implemented for all platforms.
- //Used by Win32 implementation of Boost.Threads
- //tss to perform cleanup.
- //Like the C runtime library atexit() function,
- //which it mimics, at_thread_exit() returns
- //zero if successful and a nonzero
- //value if an error occurs.
-
-#endif //defined(BOOST_HAS_WINTHREADS)
-
-#if defined(BOOST_HAS_WINTHREADS)
-
- extern "C" BOOST_THREAD_DECL void on_process_enter(void);
+namespace boost
+{
+ BOOST_THREAD_DECL void __cdecl on_process_enter(void);
//Function to be called when the exe or dll
//that uses Boost.Threads first starts
//or is first loaded.
@@ -42,7 +24,7 @@
//a method for doing so has been discovered.
//May be omitted; may be called multiple times.
- extern "C" BOOST_THREAD_DECL void on_process_exit(void);
+ BOOST_THREAD_DECL void __cdecl on_process_exit(void);
//Function to be called when the exe or dll
//that uses Boost.Threads first starts
//or is first loaded.
@@ -52,7 +34,7 @@
//a method for doing so has been discovered.
//Must not be omitted; may be called multiple times.
- extern "C" BOOST_THREAD_DECL void on_thread_enter(void);
+ BOOST_THREAD_DECL void __cdecl on_thread_enter(void);
//Function to be called just after a thread starts
//in an exe or dll that uses Boost.Threads.
//Must be called in the context of the thread
@@ -61,7 +43,7 @@
//a method for doing so has been discovered.
//May be omitted; may be called multiple times.
- extern "C" BOOST_THREAD_DECL void __cdecl on_thread_exit(void);
+ BOOST_THREAD_DECL void __cdecl on_thread_exit(void);
//Function to be called just be fore a thread ends
//in an exe or dll that uses Boost.Threads.
//Must be called in the context of the thread
@@ -70,10 +52,11 @@
//a method for doing so has been discovered.
//Must not be omitted; may be called multiple times.
- extern "C" void tss_cleanup_implemented(void);
+ void tss_cleanup_implemented();
//Dummy function used both to detect whether tss cleanup
//cleanup has been implemented and to force
//it to be linked into the Boost.Threads library.
+}
#endif //defined(BOOST_HAS_WINTHREADS)
Modified: trunk/libs/thread/src/win32/thread.cpp
==============================================================================
--- trunk/libs/thread/src/win32/thread.cpp (original)
+++ trunk/libs/thread/src/win32/thread.cpp 2010-06-09 03:37:44 EDT (Wed, 09 Jun 2010)
@@ -591,22 +591,22 @@
}
}
}
-}
+ BOOST_THREAD_DECL void __cdecl on_process_enter()
+ {}
+ BOOST_THREAD_DECL void __cdecl on_thread_enter()
+ {}
-extern "C" BOOST_THREAD_DECL void on_process_enter()
-{}
+ BOOST_THREAD_DECL void __cdecl on_process_exit()
+ {
+ boost::cleanup_tls_key();
+ }
-extern "C" BOOST_THREAD_DECL void on_thread_enter()
-{}
+ BOOST_THREAD_DECL void __cdecl on_thread_exit()
+ {
+ boost::run_thread_exit_callbacks();
+ }
-extern "C" BOOST_THREAD_DECL void on_process_exit()
-{
- boost::cleanup_tls_key();
}
-extern "C" BOOST_THREAD_DECL void on_thread_exit()
-{
- boost::run_thread_exit_callbacks();
-}
Modified: trunk/libs/thread/src/win32/tss_dll.cpp
==============================================================================
--- trunk/libs/thread/src/win32/tss_dll.cpp (original)
+++ trunk/libs/thread/src/win32/tss_dll.cpp 2010-06-09 03:37:44 EDT (Wed, 09 Jun 2010)
@@ -24,27 +24,27 @@
{
case DLL_PROCESS_ATTACH:
{
- on_process_enter();
- on_thread_enter();
+ boost::on_process_enter();
+ boost::on_thread_enter();
break;
}
case DLL_THREAD_ATTACH:
{
- on_thread_enter();
+ boost::on_thread_enter();
break;
}
case DLL_THREAD_DETACH:
{
- on_thread_exit();
+ boost::on_thread_exit();
break;
}
case DLL_PROCESS_DETACH:
{
- on_thread_exit();
- on_process_exit();
+ boost::on_thread_exit();
+ boost::on_process_exit();
break;
}
}
@@ -52,7 +52,9 @@
return TRUE;
}
- extern "C" void tss_cleanup_implemented(void)
+namespace boost
+{
+ void tss_cleanup_implemented()
{
/*
This function's sole purpose is to cause a link error in cases where
@@ -68,5 +70,7 @@
longer needed and can be removed.
*/
}
+}
+
#endif //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_DLL)
Modified: trunk/libs/thread/src/win32/tss_pe.cpp
==============================================================================
--- trunk/libs/thread/src/win32/tss_pe.cpp (original)
+++ trunk/libs/thread/src/win32/tss_pe.cpp 2010-06-09 03:37:44 EDT (Wed, 09 Jun 2010)
@@ -19,7 +19,10 @@
#include <cstdlib>
-extern "C" void tss_cleanup_implemented(void) {}
+namespace boost
+{
+ void tss_cleanup_implemented() {}
+}
namespace {
void NTAPI on_tls_callback(void* h, DWORD dwReason, PVOID pv)
@@ -28,33 +31,18 @@
{
case DLL_THREAD_DETACH:
{
- on_thread_exit();
+ boost::on_thread_exit();
break;
}
}
}
-
- void on_after_ctors(void)
- {
- on_process_enter();
- }
-
- void on_before_dtors(void)
- {
- on_thread_exit();
- }
-
- void on_after_dtors(void)
- {
- on_process_exit();
- }
}
extern "C" {
- void (* after_ctors )(void) __attribute__((section(".ctors"))) = on_after_ctors;
- void (* before_dtors)(void) __attribute__((section(".dtors"))) = on_before_dtors;
- void (* after_dtors )(void) __attribute__((section(".dtors.zzz"))) = on_after_dtors;
+ void (* after_ctors )(void) __attribute__((section(".ctors"))) = boost::on_process_enter;
+ void (* before_dtors)(void) __attribute__((section(".dtors"))) = boost::on_thread_exit;
+ void (* after_dtors )(void) __attribute__((section(".dtors.zzz"))) = boost::on_process_exit;
ULONG __tls_index__ = 0;
char __tls_end__ __attribute__((section(".tls$zzz"))) = 0;
@@ -221,18 +209,18 @@
//for destructors of global objects, so that
//shouldn't be a problem.
- atexit(on_thread_exit);
+ atexit(boost::on_thread_exit);
//Call Boost process entry callback here
- on_process_enter();
+ boost::on_process_enter();
return INIRETSUCCESS;
}
PVAPI on_process_term(void)
{
- on_process_exit();
+ boost::on_process_exit();
return INIRETSUCCESS;
}
@@ -241,7 +229,7 @@
switch (dwReason)
{
case DLL_THREAD_DETACH:
- on_thread_exit();
+ boost::on_thread_exit();
break;
}
}
@@ -251,10 +239,10 @@
switch (dwReason)
{
case DLL_THREAD_DETACH:
- on_thread_exit();
+ boost::on_thread_exit();
break;
case DLL_PROCESS_DETACH:
- on_process_exit();
+ boost::on_process_exit();
break;
}
return true;
@@ -265,8 +253,9 @@
{
extern BOOL (WINAPI * const _pRawDllMain)(HANDLE, DWORD, LPVOID)=&dll_callback;
}
-
- extern "C" void tss_cleanup_implemented(void)
+namespace boost
+{
+ void tss_cleanup_implemented()
{
/*
This function's sole purpose is to cause a link error in cases where
@@ -282,6 +271,8 @@
longer needed and can be removed.
*/
}
+}
+
#endif //defined(_MSC_VER) && !defined(UNDER_CE)
#endif //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_LIB)
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