ReactOS  0.4.13-dev-990-g6d23816
dll_startup.cpp
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS API tests
3  * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4  * PURPOSE: Test for static C++ object construction/destruction in a DLL
5  * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6  */
7 
8 #include <apitest.h>
9 #include "dll_startup.h"
10 
11 // we test the initial value of m_uninit variable here, so this is required
12 #ifdef __GNUC__
13 #pragma GCC diagnostic ignored "-Wuninitialized"
14 #endif
15 
17 {
18  0, 0, 0, 0, 5656, 0, 0
19 };
21 
22 static struct init_static
23 {
24  int m_uninit;
25  int m_counter;
26 
28  m_counter(2)
29  {
33  m_uninit++;
34  }
35 
37  {
38  p_counter_values->dtor_counter++;
39  }
40 } init_static;
41 
42 extern "C"
43 {
45 void
46 WINAPI
48  _Out_ struct counter_values *pcv)
49 {
50  p_counter_values = pcv;
51  memcpy(pcv, &counter_values, sizeof(counter_values));
52 }
53 
54 BOOL
55 WINAPI
57  _In_ HINSTANCE hinstDLL,
58  _In_ DWORD fdwReason,
60 {
61  if (fdwReason == DLL_PROCESS_ATTACH)
62  {
65  }
66  else if (fdwReason == DLL_PROCESS_DETACH)
67  {
68  p_counter_values->dtor_counter_at_detach = p_counter_values->dtor_counter;
69  }
70  return TRUE;
71 }
72 
73 }
void WINAPI SET_COUNTER_VALUES_POINTER(_Out_ struct counter_values *pcv)
Definition: dll_startup.h:24
#define TRUE
Definition: types.h:120
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ PVOID pvReserved)
Definition: dll_startup.cpp:56
static struct init_static init_static
int m_uninit_at_startup
Definition: dll_startup.h:12
unsigned int BOOL
Definition: ntddk_ex.h:94
int static_construct_counter
Definition: dll_startup.h:16
int static_construct_counter_at_startup
Definition: dll_startup.h:15
#define _Out_
Definition: no_sal2.h:323
#define DLL_PROCESS_DETACH
Definition: compat.h:119
static LPCSTR DWORD void * pvReserved
Definition: str.c:196
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
SET_COUNTER_VALUES_POINTER SetCounterValuesPointer
Definition: dll_startup.cpp:44
#define _In_
Definition: no_sal2.h:204
static struct counter_values * p_counter_values
Definition: dll_startup.cpp:20