summaryrefslogtreecommitdiffstats
path: root/base/thread_local_storage_win.cc
diff options
context:
space:
mode:
authormaruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-30 13:02:03 +0000
committermaruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-30 13:02:03 +0000
commitc88873923d37e1d77d985f8fe614aaf835dcfa82 (patch)
treeef1c4f68daac23e83b2bc149c9b5802781bf3815 /base/thread_local_storage_win.cc
parentf9fb868acd8f9977254f33fc50565a9b7bdb3295 (diff)
downloadchromium_src-c88873923d37e1d77d985f8fe614aaf835dcfa82.zip
chromium_src-c88873923d37e1d77d985f8fe614aaf835dcfa82.tar.gz
chromium_src-c88873923d37e1d77d985f8fe614aaf835dcfa82.tar.bz2
Fix most issues when building base as a x64 target.
BUG=1282556 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/thread_local_storage_win.cc')
-rw-r--r--base/thread_local_storage_win.cc30
1 files changed, 25 insertions, 5 deletions
diff --git a/base/thread_local_storage_win.cc b/base/thread_local_storage_win.cc
index 7fba9ef..4d56b08 100644
--- a/base/thread_local_storage_win.cc
+++ b/base/thread_local_storage_win.cc
@@ -27,10 +27,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <windows.h>
-
#include "base/thread_local_storage.h"
+#include <windows.h>
+
#include "base/logging.h"
// In order to make TLS destructors work, we need to keep function
@@ -144,10 +144,20 @@ void ThreadLocalStorage::ThreadExit() {
// This magic is from http://www.codeproject.com/threads/tls.asp
// and it works for VC++ 7.0 and later.
+#ifdef _WIN64
+
+// This makes the linker create the TLS directory if it's not already
+// there. (e.g. if __declspec(thread) is not used).
+#pragma comment(linker, "/INCLUDE:_tls_used")
+
+#else // _WIN64
+
// This makes the linker create the TLS directory if it's not already
// there. (e.g. if __declspec(thread) is not used).
#pragma comment(linker, "/INCLUDE:__tls_used")
+#endif // _WIN64
+
// Static callback function to call with each thread termination.
void NTAPI OnThreadExit(PVOID module, DWORD reason, PVOID reserved)
{
@@ -157,9 +167,6 @@ void NTAPI OnThreadExit(PVOID module, DWORD reason, PVOID reserved)
ThreadLocalStorage::ThreadExit();
}
-// Note: .CRT section get merged with .rdata on x64 so it should be constant
-// data.
-//
// .CRT$XLA to .CRT$XLZ is an array of PIMAGE_TLS_CALLBACK pointers that are
// called automatically by the OS loader code (not the CRT) when the module is
// loaded and on thread creation. They are NOT called if the module has been
@@ -170,8 +177,21 @@ void NTAPI OnThreadExit(PVOID module, DWORD reason, PVOID reserved)
// implicitly loaded.
//
// See VC\crt\src\tlssup.c for reference.
+#ifdef _WIN64
+
+// .CRT section is merged with .rdata on x64 so it must be constant data.
+#pragma const_seg(".CRT$XLB")
+const PIMAGE_TLS_CALLBACK p_thread_callback = OnThreadExit;
+
+// Reset the default section.
+#pragma const_seg()
+
+#else // _WIN64
+
#pragma data_seg(".CRT$XLB")
PIMAGE_TLS_CALLBACK p_thread_callback = OnThreadExit;
// Reset the default section.
#pragma data_seg()
+
+#endif // _WIN64 \ No newline at end of file