1
by Mike Hommey
Import upstream version 4.6.6 |
1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2 |
/* ***** BEGIN LICENSE BLOCK *****
|
|
3 |
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
4 |
*
|
|
5 |
* The contents of this file are subject to the Mozilla Public License Version
|
|
6 |
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
7 |
* the License. You may obtain a copy of the License at
|
|
8 |
* http://www.mozilla.org/MPL/
|
|
9 |
*
|
|
10 |
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
11 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
12 |
* for the specific language governing rights and limitations under the
|
|
13 |
* License.
|
|
14 |
*
|
|
15 |
* The Original Code is the Netscape Portable Runtime (NSPR).
|
|
16 |
*
|
|
17 |
* The Initial Developer of the Original Code is
|
|
18 |
* Netscape Communications Corporation.
|
|
19 |
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
|
20 |
* the Initial Developer. All Rights Reserved.
|
|
21 |
*
|
|
22 |
* Contributor(s):
|
|
23 |
*
|
|
24 |
* Alternatively, the contents of this file may be used under the terms of
|
|
25 |
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
26 |
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
27 |
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
28 |
* of those above. If you wish to allow use of your version of this file only
|
|
29 |
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
30 |
* use your version of this file under the terms of the MPL, indicate your
|
|
31 |
* decision by deleting the provisions above and replace them with the notice
|
|
32 |
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
33 |
* the provisions above, a recipient may use your version of this file under
|
|
34 |
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
35 |
*
|
|
36 |
* ***** END LICENSE BLOCK ***** */
|
|
37 |
||
38 |
#ifndef prinit_h___
|
|
39 |
#define prinit_h___
|
|
40 |
||
41 |
#include "prthread.h" |
|
42 |
#include "prtypes.h" |
|
43 |
#include "prwin16.h" |
|
44 |
#include <stdio.h> |
|
45 |
||
46 |
PR_BEGIN_EXTERN_C
|
|
47 |
||
48 |
/************************************************************************/
|
|
49 |
/**************************IDENTITY AND VERSIONING***********************/
|
|
50 |
/************************************************************************/
|
|
51 |
||
52 |
/*
|
|
53 |
** NSPR's name, this should persist until at least the turn of the
|
|
54 |
** century.
|
|
55 |
*/
|
|
56 |
#define PR_NAME "NSPR"
|
|
57 |
||
58 |
/*
|
|
59 |
** NSPR's version is used to determine the likelihood that the version you
|
|
60 |
** used to build your component is anywhere close to being compatible with
|
|
61 |
** what is in the underlying library.
|
|
62 |
**
|
|
63 |
** The format of the version string is
|
|
64 |
** "<major version>.<minor version>[.<patch level>] [<Beta>]"
|
|
65 |
*/
|
|
1.1.6
by Fabien Tassin
Import upstream version 4.7.1~beta2 |
66 |
#define PR_VERSION "4.7.1 Beta 2"
|
1
by Mike Hommey
Import upstream version 4.6.6 |
67 |
#define PR_VMAJOR 4
|
1.1.2
by Mike Hommey
Import upstream version 4.7.0~1.9b1 |
68 |
#define PR_VMINOR 7
|
1.1.5
by Alexander Sack
Import upstream version 4.7.0~1.9b4 |
69 |
#define PR_VPATCH 1
|
1.1.2
by Mike Hommey
Import upstream version 4.7.0~1.9b1 |
70 |
#define PR_BETA PR_TRUE
|
1
by Mike Hommey
Import upstream version 4.6.6 |
71 |
|
72 |
/*
|
|
73 |
** PRVersionCheck
|
|
74 |
**
|
|
75 |
** The basic signature of the function that is called to provide version
|
|
76 |
** checking. The result will be a boolean that indicates the likelihood
|
|
77 |
** that the underling library will perform as the caller expects.
|
|
78 |
**
|
|
79 |
** The only argument is a string, which should be the verson identifier
|
|
80 |
** of the library in question. That string will be compared against an
|
|
81 |
** equivalent string that represents the actual build version of the
|
|
82 |
** exporting library.
|
|
83 |
**
|
|
84 |
** The result will be the logical union of the directly called library
|
|
85 |
** and all dependent libraries.
|
|
86 |
*/
|
|
87 |
||
88 |
typedef PRBool (*PRVersionCheck)(const char*); |
|
89 |
||
90 |
/*
|
|
91 |
** PR_VersionCheck
|
|
92 |
**
|
|
93 |
** NSPR's existance proof of the version check function.
|
|
94 |
**
|
|
95 |
** Note that NSPR has no cooperating dependencies.
|
|
96 |
*/
|
|
97 |
||
98 |
NSPR_API(PRBool) PR_VersionCheck(const char *importedVersion); |
|
99 |
||
100 |
||
101 |
/************************************************************************/
|
|
102 |
/*******************************INITIALIZATION***************************/
|
|
103 |
/************************************************************************/
|
|
104 |
||
105 |
/*
|
|
106 |
** Initialize the runtime. Attach a thread object to the currently
|
|
107 |
** executing native thread of type "type".
|
|
108 |
**
|
|
109 |
** The specificaiton of 'maxPTDs' is ignored.
|
|
110 |
*/
|
|
111 |
NSPR_API(void) PR_Init( |
|
112 |
PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs); |
|
113 |
||
114 |
/*
|
|
115 |
** And alternate form of initialization, one that may become the default if
|
|
116 |
** not the only mechanism, provides a method to get the NSPR runtime init-
|
|
117 |
** ialized and place NSPR between the caller and the runtime library. This
|
|
118 |
** allows main() to be treated as any other thread root function, signalling
|
|
119 |
** its compeletion by returning and allowing the runtime to coordinate the
|
|
120 |
** completion of the other threads of the runtime.
|
|
121 |
**
|
|
122 |
** The priority of the main (or primordial) thread will be PR_PRIORITY_NORMAL.
|
|
123 |
** The thread may adjust its own priority by using PR_SetPriority(), though
|
|
124 |
** at this time the support for priorities is somewhat weak.
|
|
125 |
**
|
|
126 |
** The specificaiton of 'maxPTDs' is ignored.
|
|
127 |
**
|
|
128 |
** The value returned by PR_Initialize is the value returned from the root
|
|
129 |
** function, 'prmain'.
|
|
130 |
*/
|
|
131 |
||
132 |
typedef PRIntn (PR_CALLBACK *PRPrimordialFn)(PRIntn argc, char **argv); |
|
133 |
||
134 |
NSPR_API(PRIntn) PR_Initialize( |
|
135 |
PRPrimordialFn prmain, PRIntn argc, char **argv, PRUintn maxPTDs); |
|
136 |
||
137 |
/*
|
|
138 |
** Return PR_TRUE if PR_Init has already been called.
|
|
139 |
*/
|
|
140 |
NSPR_API(PRBool) PR_Initialized(void); |
|
141 |
||
142 |
/*
|
|
143 |
* Perform a graceful shutdown of NSPR. PR_Cleanup() may be called by
|
|
144 |
* the primordial thread near the end of the main() function.
|
|
145 |
*
|
|
146 |
* PR_Cleanup() attempts to synchronize the natural termination of
|
|
147 |
* process. It does that by blocking the caller, if and only if it is
|
|
148 |
* the primordial thread, until the number of user threads has dropped
|
|
149 |
* to zero. When the primordial thread returns from main(), the process
|
|
150 |
* will immediately and silently exit. That is, it will (if necessary)
|
|
151 |
* forcibly terminate any existing threads and exit without significant
|
|
152 |
* blocking and there will be no error messages or core files.
|
|
153 |
*
|
|
154 |
* PR_Cleanup() returns PR_SUCCESS if NSPR is successfully shutdown,
|
|
155 |
* or PR_FAILURE if the calling thread of this function is not the
|
|
156 |
* primordial thread.
|
|
157 |
*/
|
|
158 |
NSPR_API(PRStatus) PR_Cleanup(void); |
|
159 |
||
160 |
/*
|
|
161 |
** Disable Interrupts
|
|
162 |
** Disables timer signals used for pre-emptive scheduling.
|
|
163 |
*/
|
|
164 |
NSPR_API(void) PR_DisableClockInterrupts(void); |
|
165 |
||
166 |
/*
|
|
167 |
** Enables Interrupts
|
|
168 |
** Enables timer signals used for pre-emptive scheduling.
|
|
169 |
*/
|
|
170 |
NSPR_API(void) PR_EnableClockInterrupts(void); |
|
171 |
||
172 |
/*
|
|
173 |
** Block Interrupts
|
|
174 |
** Blocks the timer signal used for pre-emptive scheduling
|
|
175 |
*/
|
|
176 |
NSPR_API(void) PR_BlockClockInterrupts(void); |
|
177 |
||
178 |
/*
|
|
179 |
** Unblock Interrupts
|
|
180 |
** Unblocks the timer signal used for pre-emptive scheduling
|
|
181 |
*/
|
|
182 |
NSPR_API(void) PR_UnblockClockInterrupts(void); |
|
183 |
||
184 |
/*
|
|
185 |
** Create extra virtual processor threads. Generally used with MP systems.
|
|
186 |
*/
|
|
187 |
NSPR_API(void) PR_SetConcurrency(PRUintn numCPUs); |
|
188 |
||
189 |
/*
|
|
190 |
** Control the method and size of the file descriptor (PRFileDesc*)
|
|
191 |
** cache used by the runtime. Setting 'high' to zero is for performance,
|
|
192 |
** any other value probably for debugging (see memo on FD caching).
|
|
193 |
*/
|
|
194 |
NSPR_API(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high); |
|
195 |
||
196 |
/*
|
|
197 |
* Cause an immediate, nongraceful, forced termination of the process.
|
|
198 |
* It takes a PRIntn argument, which is the exit status code of the
|
|
199 |
* process.
|
|
200 |
*/
|
|
201 |
NSPR_API(void) PR_ProcessExit(PRIntn status); |
|
202 |
||
203 |
/*
|
|
204 |
** Abort the process in a non-graceful manner. This will cause a core file,
|
|
205 |
** call to the debugger or other moral equivalent as well as causing the
|
|
206 |
** entire process to stop.
|
|
207 |
*/
|
|
208 |
NSPR_API(void) PR_Abort(void); |
|
209 |
||
210 |
/*
|
|
211 |
****************************************************************
|
|
212 |
*
|
|
213 |
* Module initialization:
|
|
214 |
*
|
|
215 |
****************************************************************
|
|
216 |
*/
|
|
217 |
||
218 |
typedef struct PRCallOnceType { |
|
219 |
PRIntn initialized; |
|
220 |
PRInt32 inProgress; |
|
221 |
PRStatus status; |
|
222 |
} PRCallOnceType; |
|
223 |
||
224 |
typedef PRStatus (PR_CALLBACK *PRCallOnceFN)(void); |
|
225 |
||
226 |
typedef PRStatus (PR_CALLBACK *PRCallOnceWithArgFN)(void *arg); |
|
227 |
||
228 |
NSPR_API(PRStatus) PR_CallOnce( |
|
229 |
PRCallOnceType *once, |
|
230 |
PRCallOnceFN func |
|
231 |
);
|
|
232 |
||
233 |
NSPR_API(PRStatus) PR_CallOnceWithArg( |
|
234 |
PRCallOnceType *once, |
|
235 |
PRCallOnceWithArgFN func, |
|
236 |
void *arg |
|
237 |
);
|
|
238 |
||
239 |
||
240 |
PR_END_EXTERN_C
|
|
241 |
||
242 |
#endif /* prinit_h___ */ |