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