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