VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/include/prinit.h@ 43213

Last change on this file since 43213 was 11551, checked in by vboxsync, 16 years ago

API/xpcom: prefix any C symbols in VBoxXPCOM.so, to avoid namespace pollution. Enabled only on Linux at the moment.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.6 KB
Line 
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#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
47#define PR_Abort VBoxNsprPR_Abort
48#define PR_Cleanup VBoxNsprPR_Cleanup
49#define PR_DisableClockInterrupts VBoxNsprPR_DisableClockInterrupts
50#define PR_EnableClockInterrupts VBoxNsprPR_EnableClockInterrupts
51#define PR_BlockClockInterrupts VBoxNsprPR_BlockClockInterrupts
52#define PR_UnblockClockInterrupts VBoxNsprPR_UnblockClockInterrupts
53#define PR_Init VBoxNsprPR_Init
54#define PR_Initialize VBoxNsprPR_Initialize
55#define PR_Initialized VBoxNsprPR_Initialized
56#define PR_VersionCheck VBoxNsprPR_VersionCheck
57#define PR_SetConcurrency VBoxNsprPR_SetConcurrency
58#define PR_SetFDCacheSize VBoxNsprPR_SetFDCacheSize
59#define PR_ProcessExit VBoxNsprPR_ProcessExit
60#define PR_CallOnce VBoxNsprPR_CallOnce
61#define PR_CallOnceWithArg VBoxNsprPR_CallOnceWithArg
62#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
63
64PR_BEGIN_EXTERN_C
65
66/************************************************************************/
67/**************************IDENTITY AND VERSIONING***********************/
68/************************************************************************/
69
70/*
71** NSPR's name, this should persist until at least the turn of the
72** century.
73*/
74#define PR_NAME "NSPR"
75
76/*
77** NSPR's version is used to determine the likelihood that the version you
78** used to build your component is anywhere close to being compatible with
79** what is in the underlying library.
80**
81** The format of the version string is
82** "<major version>.<minor version>[.<patch level>] [<Beta>]"
83*/
84#define PR_VERSION "4.6 Beta"
85#define PR_VMAJOR 4
86#define PR_VMINOR 6
87#define PR_VPATCH 0
88#define PR_BETA PR_TRUE
89
90/*
91** PRVersionCheck
92**
93** The basic signature of the function that is called to provide version
94** checking. The result will be a boolean that indicates the likelihood
95** that the underling library will perform as the caller expects.
96**
97** The only argument is a string, which should be the verson identifier
98** of the library in question. That string will be compared against an
99** equivalent string that represents the actual build version of the
100** exporting library.
101**
102** The result will be the logical union of the directly called library
103** and all dependent libraries.
104*/
105
106typedef PRBool (*PRVersionCheck)(const char*);
107
108/*
109** PR_VersionCheck
110**
111** NSPR's existance proof of the version check function.
112**
113** Note that NSPR has no cooperating dependencies.
114*/
115
116NSPR_API(PRBool) PR_VersionCheck(const char *importedVersion);
117
118
119/************************************************************************/
120/*******************************INITIALIZATION***************************/
121/************************************************************************/
122
123/*
124** Initialize the runtime. Attach a thread object to the currently
125** executing native thread of type "type".
126**
127** The specificaiton of 'maxPTDs' is ignored.
128*/
129NSPR_API(void) PR_Init(
130 PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs);
131
132/*
133** And alternate form of initialization, one that may become the default if
134** not the only mechanism, provides a method to get the NSPR runtime init-
135** ialized and place NSPR between the caller and the runtime library. This
136** allows main() to be treated as any other thread root function, signalling
137** its compeletion by returning and allowing the runtime to coordinate the
138** completion of the other threads of the runtime.
139**
140** The priority of the main (or primordial) thread will be PR_PRIORITY_NORMAL.
141** The thread may adjust its own priority by using PR_SetPriority(), though
142** at this time the support for priorities is somewhat weak.
143**
144** The specificaiton of 'maxPTDs' is ignored.
145**
146** The value returned by PR_Initialize is the value returned from the root
147** function, 'prmain'.
148*/
149
150typedef PRIntn (PR_CALLBACK *PRPrimordialFn)(PRIntn argc, char **argv);
151
152NSPR_API(PRIntn) PR_Initialize(
153 PRPrimordialFn prmain, PRIntn argc, char **argv, PRUintn maxPTDs);
154
155/*
156** Return PR_TRUE if PR_Init has already been called.
157*/
158NSPR_API(PRBool) PR_Initialized(void);
159
160/*
161 * Perform a graceful shutdown of NSPR. PR_Cleanup() may be called by
162 * the primordial thread near the end of the main() function.
163 *
164 * PR_Cleanup() attempts to synchronize the natural termination of
165 * process. It does that by blocking the caller, if and only if it is
166 * the primordial thread, until the number of user threads has dropped
167 * to zero. When the primordial thread returns from main(), the process
168 * will immediately and silently exit. That is, it will (if necessary)
169 * forcibly terminate any existing threads and exit without significant
170 * blocking and there will be no error messages or core files.
171 *
172 * PR_Cleanup() returns PR_SUCCESS if NSPR is successfully shutdown,
173 * or PR_FAILURE if the calling thread of this function is not the
174 * primordial thread.
175 */
176NSPR_API(PRStatus) PR_Cleanup(void);
177
178/*
179** Disable Interrupts
180** Disables timer signals used for pre-emptive scheduling.
181*/
182NSPR_API(void) PR_DisableClockInterrupts(void);
183
184/*
185** Enables Interrupts
186** Enables timer signals used for pre-emptive scheduling.
187*/
188NSPR_API(void) PR_EnableClockInterrupts(void);
189
190/*
191** Block Interrupts
192** Blocks the timer signal used for pre-emptive scheduling
193*/
194NSPR_API(void) PR_BlockClockInterrupts(void);
195
196/*
197** Unblock Interrupts
198** Unblocks the timer signal used for pre-emptive scheduling
199*/
200NSPR_API(void) PR_UnblockClockInterrupts(void);
201
202/*
203** Create extra virtual processor threads. Generally used with MP systems.
204*/
205NSPR_API(void) PR_SetConcurrency(PRUintn numCPUs);
206
207/*
208** Control the method and size of the file descriptor (PRFileDesc*)
209** cache used by the runtime. Setting 'high' to zero is for performance,
210** any other value probably for debugging (see memo on FD caching).
211*/
212NSPR_API(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high);
213
214/*
215 * Cause an immediate, nongraceful, forced termination of the process.
216 * It takes a PRIntn argument, which is the exit status code of the
217 * process.
218 */
219NSPR_API(void) PR_ProcessExit(PRIntn status);
220
221/*
222** Abort the process in a non-graceful manner. This will cause a core file,
223** call to the debugger or other moral equivalent as well as causing the
224** entire process to stop.
225*/
226NSPR_API(void) PR_Abort(void);
227
228/*
229 ****************************************************************
230 *
231 * Module initialization:
232 *
233 ****************************************************************
234 */
235
236typedef struct PRCallOnceType {
237 PRIntn initialized;
238 PRInt32 inProgress;
239 PRStatus status;
240} PRCallOnceType;
241
242typedef PRStatus (PR_CALLBACK *PRCallOnceFN)(void);
243
244typedef PRStatus (PR_CALLBACK *PRCallOnceWithArgFN)(void *arg);
245
246NSPR_API(PRStatus) PR_CallOnce(
247 PRCallOnceType *once,
248 PRCallOnceFN func
249);
250
251NSPR_API(PRStatus) PR_CallOnceWithArg(
252 PRCallOnceType *once,
253 PRCallOnceWithArgFN func,
254 void *arg
255);
256
257
258PR_END_EXTERN_C
259
260#endif /* prinit_h___ */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette