michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef prinit_h___ michael@0: #define prinit_h___ michael@0: michael@0: #include "prthread.h" michael@0: #include "prtypes.h" michael@0: #include "prwin16.h" michael@0: #include michael@0: michael@0: PR_BEGIN_EXTERN_C michael@0: michael@0: /************************************************************************/ michael@0: /**************************IDENTITY AND VERSIONING***********************/ michael@0: /************************************************************************/ michael@0: michael@0: /* michael@0: ** NSPR's name, this should persist until at least the turn of the michael@0: ** century. michael@0: */ michael@0: #define PR_NAME "NSPR" michael@0: michael@0: /* michael@0: ** NSPR's version is used to determine the likelihood that the version you michael@0: ** used to build your component is anywhere close to being compatible with michael@0: ** what is in the underlying library. michael@0: ** michael@0: ** The format of the version string is michael@0: ** ".[.] []" michael@0: */ michael@0: #define PR_VERSION "4.10.6" michael@0: #define PR_VMAJOR 4 michael@0: #define PR_VMINOR 10 michael@0: #define PR_VPATCH 6 michael@0: #define PR_BETA PR_FALSE michael@0: michael@0: /* michael@0: ** PRVersionCheck michael@0: ** michael@0: ** The basic signature of the function that is called to provide version michael@0: ** checking. The result will be a boolean that indicates the likelihood michael@0: ** that the underling library will perform as the caller expects. michael@0: ** michael@0: ** The only argument is a string, which should be the verson identifier michael@0: ** of the library in question. That string will be compared against an michael@0: ** equivalent string that represents the actual build version of the michael@0: ** exporting library. michael@0: ** michael@0: ** The result will be the logical union of the directly called library michael@0: ** and all dependent libraries. michael@0: */ michael@0: michael@0: typedef PRBool (*PRVersionCheck)(const char*); michael@0: michael@0: /* michael@0: ** PR_VersionCheck michael@0: ** michael@0: ** NSPR's existance proof of the version check function. michael@0: ** michael@0: ** Note that NSPR has no cooperating dependencies. michael@0: */ michael@0: michael@0: NSPR_API(PRBool) PR_VersionCheck(const char *importedVersion); michael@0: michael@0: /* michael@0: * Returns a const string of the NSPR library version. michael@0: */ michael@0: NSPR_API(const char*) PR_GetVersion(void); michael@0: michael@0: michael@0: /************************************************************************/ michael@0: /*******************************INITIALIZATION***************************/ michael@0: /************************************************************************/ michael@0: michael@0: /* michael@0: ** Initialize the runtime. Attach a thread object to the currently michael@0: ** executing native thread of type "type". michael@0: ** michael@0: ** The specificaiton of 'maxPTDs' is ignored. michael@0: */ michael@0: NSPR_API(void) PR_Init( michael@0: PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs); michael@0: michael@0: /* michael@0: ** And alternate form of initialization, one that may become the default if michael@0: ** not the only mechanism, provides a method to get the NSPR runtime init- michael@0: ** ialized and place NSPR between the caller and the runtime library. This michael@0: ** allows main() to be treated as any other thread root function, signalling michael@0: ** its compeletion by returning and allowing the runtime to coordinate the michael@0: ** completion of the other threads of the runtime. michael@0: ** michael@0: ** The priority of the main (or primordial) thread will be PR_PRIORITY_NORMAL. michael@0: ** The thread may adjust its own priority by using PR_SetPriority(), though michael@0: ** at this time the support for priorities is somewhat weak. michael@0: ** michael@0: ** The specificaiton of 'maxPTDs' is ignored. michael@0: ** michael@0: ** The value returned by PR_Initialize is the value returned from the root michael@0: ** function, 'prmain'. michael@0: */ michael@0: michael@0: typedef PRIntn (PR_CALLBACK *PRPrimordialFn)(PRIntn argc, char **argv); michael@0: michael@0: NSPR_API(PRIntn) PR_Initialize( michael@0: PRPrimordialFn prmain, PRIntn argc, char **argv, PRUintn maxPTDs); michael@0: michael@0: /* michael@0: ** Return PR_TRUE if PR_Init has already been called. michael@0: */ michael@0: NSPR_API(PRBool) PR_Initialized(void); michael@0: michael@0: /* michael@0: * Perform a graceful shutdown of NSPR. PR_Cleanup() may be called by michael@0: * the primordial thread near the end of the main() function. michael@0: * michael@0: * PR_Cleanup() attempts to synchronize the natural termination of michael@0: * process. It does that by blocking the caller, if and only if it is michael@0: * the primordial thread, until the number of user threads has dropped michael@0: * to zero. When the primordial thread returns from main(), the process michael@0: * will immediately and silently exit. That is, it will (if necessary) michael@0: * forcibly terminate any existing threads and exit without significant michael@0: * blocking and there will be no error messages or core files. michael@0: * michael@0: * PR_Cleanup() returns PR_SUCCESS if NSPR is successfully shutdown, michael@0: * or PR_FAILURE if the calling thread of this function is not the michael@0: * primordial thread. michael@0: */ michael@0: NSPR_API(PRStatus) PR_Cleanup(void); michael@0: michael@0: /* michael@0: ** Disable Interrupts michael@0: ** Disables timer signals used for pre-emptive scheduling. michael@0: */ michael@0: NSPR_API(void) PR_DisableClockInterrupts(void); michael@0: michael@0: /* michael@0: ** Enables Interrupts michael@0: ** Enables timer signals used for pre-emptive scheduling. michael@0: */ michael@0: NSPR_API(void) PR_EnableClockInterrupts(void); michael@0: michael@0: /* michael@0: ** Block Interrupts michael@0: ** Blocks the timer signal used for pre-emptive scheduling michael@0: */ michael@0: NSPR_API(void) PR_BlockClockInterrupts(void); michael@0: michael@0: /* michael@0: ** Unblock Interrupts michael@0: ** Unblocks the timer signal used for pre-emptive scheduling michael@0: */ michael@0: NSPR_API(void) PR_UnblockClockInterrupts(void); michael@0: michael@0: /* michael@0: ** Create extra virtual processor threads. Generally used with MP systems. michael@0: */ michael@0: NSPR_API(void) PR_SetConcurrency(PRUintn numCPUs); michael@0: michael@0: /* michael@0: ** Control the method and size of the file descriptor (PRFileDesc*) michael@0: ** cache used by the runtime. Setting 'high' to zero is for performance, michael@0: ** any other value probably for debugging (see memo on FD caching). michael@0: */ michael@0: NSPR_API(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high); michael@0: michael@0: /* michael@0: * Cause an immediate, nongraceful, forced termination of the process. michael@0: * It takes a PRIntn argument, which is the exit status code of the michael@0: * process. michael@0: */ michael@0: NSPR_API(void) PR_ProcessExit(PRIntn status); michael@0: michael@0: /* michael@0: ** Abort the process in a non-graceful manner. This will cause a core file, michael@0: ** call to the debugger or other moral equivalent as well as causing the michael@0: ** entire process to stop. michael@0: */ michael@0: NSPR_API(void) PR_Abort(void); michael@0: michael@0: /* michael@0: **************************************************************** michael@0: * michael@0: * Module initialization: michael@0: * michael@0: **************************************************************** michael@0: */ michael@0: michael@0: typedef struct PRCallOnceType { michael@0: PRIntn initialized; michael@0: PRInt32 inProgress; michael@0: PRStatus status; michael@0: } PRCallOnceType; michael@0: michael@0: typedef PRStatus (PR_CALLBACK *PRCallOnceFN)(void); michael@0: michael@0: typedef PRStatus (PR_CALLBACK *PRCallOnceWithArgFN)(void *arg); michael@0: michael@0: NSPR_API(PRStatus) PR_CallOnce( michael@0: PRCallOnceType *once, michael@0: PRCallOnceFN func michael@0: ); michael@0: michael@0: NSPR_API(PRStatus) PR_CallOnceWithArg( michael@0: PRCallOnceType *once, michael@0: PRCallOnceWithArgFN func, michael@0: void *arg michael@0: ); michael@0: michael@0: michael@0: PR_END_EXTERN_C michael@0: michael@0: #endif /* prinit_h___ */