home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nspr30-e.zip / nspr30-e / include / prinit.h < prev    next >
C/C++ Source or Header  |  1998-11-02  |  7KB  |  224 lines

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