diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-09-03 16:20:38 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-09-03 16:20:38 +0200 |
commit | 0e2ae18a97fd507bac872031888d34c3a7d8b17b (patch) | |
tree | 3f9a551486969d2bc05f272e2da372c1a55d34cf /odb/details/win32/dll.cxx | |
parent | 137b1eb3e41578d9d4a066ef75c6abfa597c46cd (diff) |
Implement Win32 TLS support
Diffstat (limited to 'odb/details/win32/dll.cxx')
-rw-r--r-- | odb/details/win32/dll.cxx | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/odb/details/win32/dll.cxx b/odb/details/win32/dll.cxx new file mode 100644 index 0000000..843be8d --- /dev/null +++ b/odb/details/win32/dll.cxx @@ -0,0 +1,52 @@ +// file : odb/details/win32/dll.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +// If we are building a static library from VC++ (LIBODB_STATIC_LIB) or +// a static library from automake (!DLL_EXPORT), then omit DllMain. +// +#if defined(LIBODB_STATIC_LIB) || !defined (_MSC_VER) && !defined(DLL_EXPORT) + +#include <windows.h> + +#include <odb/details/win32/init.hxx> + +using namespace odb::details; + +extern "C" BOOL WINAPI +DllMain (HINSTANCE, DWORD reason, LPVOID reserved) +{ + switch (reason) + { + case DLL_PROCESS_ATTACH: + { + process_start (); + thread_start (); + break; + } + + case DLL_THREAD_ATTACH: + { + thread_start (); + break; + } + + case DLL_THREAD_DETACH: + { + thread_end (); + break; + } + + case DLL_PROCESS_DETACH: + { + thread_end (); + process_end (reserved == NULL); + break; + } + } + + return 1; +} + +#endif |