aboutsummaryrefslogtreecommitdiff
path: root/odb/details/win32/dll.cxx
blob: 843be8daded47bc219b6683cfc1643a8bda8f221 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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