1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/include/prinit.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,215 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef prinit_h___ 1.10 +#define prinit_h___ 1.11 + 1.12 +#include "prthread.h" 1.13 +#include "prtypes.h" 1.14 +#include "prwin16.h" 1.15 +#include <stdio.h> 1.16 + 1.17 +PR_BEGIN_EXTERN_C 1.18 + 1.19 +/************************************************************************/ 1.20 +/**************************IDENTITY AND VERSIONING***********************/ 1.21 +/************************************************************************/ 1.22 + 1.23 +/* 1.24 +** NSPR's name, this should persist until at least the turn of the 1.25 +** century. 1.26 +*/ 1.27 +#define PR_NAME "NSPR" 1.28 + 1.29 +/* 1.30 +** NSPR's version is used to determine the likelihood that the version you 1.31 +** used to build your component is anywhere close to being compatible with 1.32 +** what is in the underlying library. 1.33 +** 1.34 +** The format of the version string is 1.35 +** "<major version>.<minor version>[.<patch level>] [<Beta>]" 1.36 +*/ 1.37 +#define PR_VERSION "4.10.6" 1.38 +#define PR_VMAJOR 4 1.39 +#define PR_VMINOR 10 1.40 +#define PR_VPATCH 6 1.41 +#define PR_BETA PR_FALSE 1.42 + 1.43 +/* 1.44 +** PRVersionCheck 1.45 +** 1.46 +** The basic signature of the function that is called to provide version 1.47 +** checking. The result will be a boolean that indicates the likelihood 1.48 +** that the underling library will perform as the caller expects. 1.49 +** 1.50 +** The only argument is a string, which should be the verson identifier 1.51 +** of the library in question. That string will be compared against an 1.52 +** equivalent string that represents the actual build version of the 1.53 +** exporting library. 1.54 +** 1.55 +** The result will be the logical union of the directly called library 1.56 +** and all dependent libraries. 1.57 +*/ 1.58 + 1.59 +typedef PRBool (*PRVersionCheck)(const char*); 1.60 + 1.61 +/* 1.62 +** PR_VersionCheck 1.63 +** 1.64 +** NSPR's existance proof of the version check function. 1.65 +** 1.66 +** Note that NSPR has no cooperating dependencies. 1.67 +*/ 1.68 + 1.69 +NSPR_API(PRBool) PR_VersionCheck(const char *importedVersion); 1.70 + 1.71 +/* 1.72 + * Returns a const string of the NSPR library version. 1.73 + */ 1.74 +NSPR_API(const char*) PR_GetVersion(void); 1.75 + 1.76 + 1.77 +/************************************************************************/ 1.78 +/*******************************INITIALIZATION***************************/ 1.79 +/************************************************************************/ 1.80 + 1.81 +/* 1.82 +** Initialize the runtime. Attach a thread object to the currently 1.83 +** executing native thread of type "type". 1.84 +** 1.85 +** The specificaiton of 'maxPTDs' is ignored. 1.86 +*/ 1.87 +NSPR_API(void) PR_Init( 1.88 + PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs); 1.89 + 1.90 +/* 1.91 +** And alternate form of initialization, one that may become the default if 1.92 +** not the only mechanism, provides a method to get the NSPR runtime init- 1.93 +** ialized and place NSPR between the caller and the runtime library. This 1.94 +** allows main() to be treated as any other thread root function, signalling 1.95 +** its compeletion by returning and allowing the runtime to coordinate the 1.96 +** completion of the other threads of the runtime. 1.97 +** 1.98 +** The priority of the main (or primordial) thread will be PR_PRIORITY_NORMAL. 1.99 +** The thread may adjust its own priority by using PR_SetPriority(), though 1.100 +** at this time the support for priorities is somewhat weak. 1.101 +** 1.102 +** The specificaiton of 'maxPTDs' is ignored. 1.103 +** 1.104 +** The value returned by PR_Initialize is the value returned from the root 1.105 +** function, 'prmain'. 1.106 +*/ 1.107 + 1.108 +typedef PRIntn (PR_CALLBACK *PRPrimordialFn)(PRIntn argc, char **argv); 1.109 + 1.110 +NSPR_API(PRIntn) PR_Initialize( 1.111 + PRPrimordialFn prmain, PRIntn argc, char **argv, PRUintn maxPTDs); 1.112 + 1.113 +/* 1.114 +** Return PR_TRUE if PR_Init has already been called. 1.115 +*/ 1.116 +NSPR_API(PRBool) PR_Initialized(void); 1.117 + 1.118 +/* 1.119 + * Perform a graceful shutdown of NSPR. PR_Cleanup() may be called by 1.120 + * the primordial thread near the end of the main() function. 1.121 + * 1.122 + * PR_Cleanup() attempts to synchronize the natural termination of 1.123 + * process. It does that by blocking the caller, if and only if it is 1.124 + * the primordial thread, until the number of user threads has dropped 1.125 + * to zero. When the primordial thread returns from main(), the process 1.126 + * will immediately and silently exit. That is, it will (if necessary) 1.127 + * forcibly terminate any existing threads and exit without significant 1.128 + * blocking and there will be no error messages or core files. 1.129 + * 1.130 + * PR_Cleanup() returns PR_SUCCESS if NSPR is successfully shutdown, 1.131 + * or PR_FAILURE if the calling thread of this function is not the 1.132 + * primordial thread. 1.133 + */ 1.134 +NSPR_API(PRStatus) PR_Cleanup(void); 1.135 + 1.136 +/* 1.137 +** Disable Interrupts 1.138 +** Disables timer signals used for pre-emptive scheduling. 1.139 +*/ 1.140 +NSPR_API(void) PR_DisableClockInterrupts(void); 1.141 + 1.142 +/* 1.143 +** Enables Interrupts 1.144 +** Enables timer signals used for pre-emptive scheduling. 1.145 +*/ 1.146 +NSPR_API(void) PR_EnableClockInterrupts(void); 1.147 + 1.148 +/* 1.149 +** Block Interrupts 1.150 +** Blocks the timer signal used for pre-emptive scheduling 1.151 +*/ 1.152 +NSPR_API(void) PR_BlockClockInterrupts(void); 1.153 + 1.154 +/* 1.155 +** Unblock Interrupts 1.156 +** Unblocks the timer signal used for pre-emptive scheduling 1.157 +*/ 1.158 +NSPR_API(void) PR_UnblockClockInterrupts(void); 1.159 + 1.160 +/* 1.161 +** Create extra virtual processor threads. Generally used with MP systems. 1.162 +*/ 1.163 +NSPR_API(void) PR_SetConcurrency(PRUintn numCPUs); 1.164 + 1.165 +/* 1.166 +** Control the method and size of the file descriptor (PRFileDesc*) 1.167 +** cache used by the runtime. Setting 'high' to zero is for performance, 1.168 +** any other value probably for debugging (see memo on FD caching). 1.169 +*/ 1.170 +NSPR_API(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high); 1.171 + 1.172 +/* 1.173 + * Cause an immediate, nongraceful, forced termination of the process. 1.174 + * It takes a PRIntn argument, which is the exit status code of the 1.175 + * process. 1.176 + */ 1.177 +NSPR_API(void) PR_ProcessExit(PRIntn status); 1.178 + 1.179 +/* 1.180 +** Abort the process in a non-graceful manner. This will cause a core file, 1.181 +** call to the debugger or other moral equivalent as well as causing the 1.182 +** entire process to stop. 1.183 +*/ 1.184 +NSPR_API(void) PR_Abort(void); 1.185 + 1.186 +/* 1.187 + **************************************************************** 1.188 + * 1.189 + * Module initialization: 1.190 + * 1.191 + **************************************************************** 1.192 + */ 1.193 + 1.194 +typedef struct PRCallOnceType { 1.195 + PRIntn initialized; 1.196 + PRInt32 inProgress; 1.197 + PRStatus status; 1.198 +} PRCallOnceType; 1.199 + 1.200 +typedef PRStatus (PR_CALLBACK *PRCallOnceFN)(void); 1.201 + 1.202 +typedef PRStatus (PR_CALLBACK *PRCallOnceWithArgFN)(void *arg); 1.203 + 1.204 +NSPR_API(PRStatus) PR_CallOnce( 1.205 + PRCallOnceType *once, 1.206 + PRCallOnceFN func 1.207 +); 1.208 + 1.209 +NSPR_API(PRStatus) PR_CallOnceWithArg( 1.210 + PRCallOnceType *once, 1.211 + PRCallOnceWithArgFN func, 1.212 + void *arg 1.213 +); 1.214 + 1.215 + 1.216 +PR_END_EXTERN_C 1.217 + 1.218 +#endif /* prinit_h___ */