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