summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test1/testlib.cpp
blob: 53b66d13576d343f6df2f8803c0727682073e8fb (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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

/*=====================================================================
**
** Source:  testlib.c
**
** Purpose: Simple library that counts thread attach/detach notifications
**
**
**===================================================================*/

#include <palsuite.h>

static int Count;

BOOL __stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{

    if (fdwReason == DLL_PROCESS_ATTACH)
    {
        Count = 0;
    }
    else if (fdwReason == DLL_THREAD_ATTACH ||
        fdwReason == DLL_THREAD_DETACH)
    {
        Count++;
    }

    return TRUE;
}

#ifdef WIN32
BOOL __stdcall _DllMainCRTStartup(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    return DllMain(hinstDLL, fdwReason, lpvReserved);
}
#endif

#ifdef WIN32
__declspec(dllexport)
#endif
int __stdcall GetCallCount()
{
    return Count;
}