summaryrefslogtreecommitdiff
path: root/libodb/odb/details/win32/dll.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2024-01-24 17:03:38 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2024-01-24 17:03:38 +0300
commit0f1f6841ce5a50d5b315c24d796a2d8e2627d136 (patch)
treee16bbf9e23ca75a88b8af032c4e3ed299ca8db66 /libodb/odb/details/win32/dll.cxx
parent823026b58211a4166de06ac243d978dcb9930271 (diff)
parent26e36b3a9d7b49d46ecfa69b447482251acba8ac (diff)
Merge branch 'libodb' into multi-package
Diffstat (limited to 'libodb/odb/details/win32/dll.cxx')
-rw-r--r--libodb/odb/details/win32/dll.cxx51
1 files changed, 51 insertions, 0 deletions
diff --git a/libodb/odb/details/win32/dll.cxx b/libodb/odb/details/win32/dll.cxx
new file mode 100644
index 0000000..49b660c
--- /dev/null
+++ b/libodb/odb/details/win32/dll.cxx
@@ -0,0 +1,51 @@
+// file : odb/details/win32/dll.cxx
+// 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(_MSC_VER) && defined(LIBODB_DYNAMIC_LIB)) || \
+ (!defined(_MSC_VER) && defined(DLL_EXPORT))
+
+#include <odb/details/win32/windows.hxx>
+#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