summaryrefslogtreecommitdiff
path: root/src/pal/src/include/pal/init.h
blob: d478ed275b3ffbc30deff10022fc24a42f306f22 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// 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.

/*++



Module Name:

    include/pal/init.h

Abstract:
    Header file for PAL init utility functions. Those functions
    are only use by the PAL itself.

Revision History:



--*/

#ifndef _PAL_INIT_H_
#define _PAL_INIT_H_

#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus

/*++
Function:
  PALCommonCleanup

Utility function to prepare for shutdown.

--*/
void PALCommonCleanup();

extern Volatile<INT> init_count;

/*++
MACRO:
  PALIsInitialized

Returns TRUE if the PAL is in an initialized state
(#calls to PAL_Initialize > #calls to PAL_Terminate)

Warning : this will only report the PAL's state at the moment it is called. 
If it is necessary to ensure the PAL remains initialized (or not) while doing 
some work, the Initialization lock (PALInitLock()) should be held.
--*/
#define PALIsInitialized() (0 < init_count)

/*++
Function:
  PALIsThreadDataInitialized

Returns TRUE if startup has reached a point where thread data is available
--*/
BOOL
PALIsThreadDataInitialized();

/*++
Function:
  PALIsShuttingDown

Returns TRUE if the some thread has declared intent to shutdown
--*/
BOOL
PALIsShuttingDown();

/*++
Function:
  PALSetShutdownIntent

Delcares intent to shutdown
--*/
void
PALSetShutdownIntent();

/*++
Function:
  PALInitLock

Take the initializaiton critical section (init_critsec). necessary to serialize 
TerminateProcess along with PAL_Terminate and PAL_Initialize

(no parameters)

Return value :
    TRUE if critical section existed (and was acquired)
    FALSE if critical section doens't exist yet
--*/
BOOL PALInitLock(void);

/*++
Function:
  PALInitUnlock

Release the initialization critical section (init_critsec). 

(no parameters, no return value)
--*/
void PALInitUnlock(void);

#ifdef __cplusplus
}
#endif // __cplusplus

#endif /* _PAL_INIT_H_ */