[JAEGER] Merge from tracemonkey.
[mozilla-central.git] / nsprpub / pr / include / prinit.h
blob0afd77b7fae80f33ea088f14b2ed673cac1e6dc1
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
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/
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.
15 * The Original Code is the Netscape Portable Runtime (NSPR).
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.
22 * Contributor(s):
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.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef prinit_h___
39 #define prinit_h___
41 #include "prthread.h"
42 #include "prtypes.h"
43 #include "prwin16.h"
44 #include <stdio.h>
46 PR_BEGIN_EXTERN_C
48 /************************************************************************/
49 /**************************IDENTITY AND VERSIONING***********************/
50 /************************************************************************/
53 ** NSPR's name, this should persist until at least the turn of the
54 ** century.
56 #define PR_NAME "NSPR"
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.
63 ** The format of the version string is
64 ** "<major version>.<minor version>[.<patch level>] [<Beta>]"
66 #define PR_VERSION "4.8.6 Beta 2"
67 #define PR_VMAJOR 4
68 #define PR_VMINOR 8
69 #define PR_VPATCH 6
70 #define PR_BETA PR_TRUE
73 ** PRVersionCheck
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.
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.
84 ** The result will be the logical union of the directly called library
85 ** and all dependent libraries.
88 typedef PRBool (*PRVersionCheck)(const char*);
91 ** PR_VersionCheck
93 ** NSPR's existance proof of the version check function.
95 ** Note that NSPR has no cooperating dependencies.
98 NSPR_API(PRBool) PR_VersionCheck(const char *importedVersion);
101 /************************************************************************/
102 /*******************************INITIALIZATION***************************/
103 /************************************************************************/
106 ** Initialize the runtime. Attach a thread object to the currently
107 ** executing native thread of type "type".
109 ** The specificaiton of 'maxPTDs' is ignored.
111 NSPR_API(void) PR_Init(
112 PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs);
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.
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.
126 ** The specificaiton of 'maxPTDs' is ignored.
128 ** The value returned by PR_Initialize is the value returned from the root
129 ** function, 'prmain'.
132 typedef PRIntn (PR_CALLBACK *PRPrimordialFn)(PRIntn argc, char **argv);
134 NSPR_API(PRIntn) PR_Initialize(
135 PRPrimordialFn prmain, PRIntn argc, char **argv, PRUintn maxPTDs);
138 ** Return PR_TRUE if PR_Init has already been called.
140 NSPR_API(PRBool) PR_Initialized(void);
143 * Perform a graceful shutdown of NSPR. PR_Cleanup() may be called by
144 * the primordial thread near the end of the main() function.
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.
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.
158 NSPR_API(PRStatus) PR_Cleanup(void);
161 ** Disable Interrupts
162 ** Disables timer signals used for pre-emptive scheduling.
164 NSPR_API(void) PR_DisableClockInterrupts(void);
167 ** Enables Interrupts
168 ** Enables timer signals used for pre-emptive scheduling.
170 NSPR_API(void) PR_EnableClockInterrupts(void);
173 ** Block Interrupts
174 ** Blocks the timer signal used for pre-emptive scheduling
176 NSPR_API(void) PR_BlockClockInterrupts(void);
179 ** Unblock Interrupts
180 ** Unblocks the timer signal used for pre-emptive scheduling
182 NSPR_API(void) PR_UnblockClockInterrupts(void);
185 ** Create extra virtual processor threads. Generally used with MP systems.
187 NSPR_API(void) PR_SetConcurrency(PRUintn numCPUs);
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).
194 NSPR_API(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high);
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.
201 NSPR_API(void) PR_ProcessExit(PRIntn status);
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.
208 NSPR_API(void) PR_Abort(void);
211 ****************************************************************
213 * Module initialization:
215 ****************************************************************
218 typedef struct PRCallOnceType {
219 PRIntn initialized;
220 PRInt32 inProgress;
221 PRStatus status;
222 } PRCallOnceType;
224 typedef PRStatus (PR_CALLBACK *PRCallOnceFN)(void);
226 typedef PRStatus (PR_CALLBACK *PRCallOnceWithArgFN)(void *arg);
228 NSPR_API(PRStatus) PR_CallOnce(
229 PRCallOnceType *once,
230 PRCallOnceFN func
233 NSPR_API(PRStatus) PR_CallOnceWithArg(
234 PRCallOnceType *once,
235 PRCallOnceWithArgFN func,
236 void *arg
240 PR_END_EXTERN_C
242 #endif /* prinit_h___ */