home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / include / prinit.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  6.4 KB  |  208 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  "2.1 yyyymmdd"
  48.  
  49. /*
  50. ** PRVersionCheck
  51. **
  52. ** The basic signature of the function that is called to provide version
  53. ** checking. The result will be a boolean that indicates the likelihood
  54. ** that the underling library will perform as the caller expects.
  55. **
  56. ** The only argument is a string, which should be the verson identifier
  57. ** of the library in question. That string will be compared against an
  58. ** equivalent string that represents the actual build version of the
  59. ** exporting library.
  60. **
  61. ** The result will be the logical union of the directly called library
  62. ** and all dependent libraries.
  63. */
  64.  
  65. typedef PRBool (*PRVersionCheck)(const char*);
  66.  
  67. /*
  68. ** PR_VersionCheck
  69. **
  70. ** NSPR's existance proof of the version check function.
  71. **
  72. ** Note that NSPR has no cooperating dependencies.
  73. */
  74.  
  75. PR_EXTERN(PRBool) PR_VersionCheck(const char *importedVersion);
  76.  
  77.  
  78. /************************************************************************/
  79. /*******************************INITIALIZATION***************************/
  80. /************************************************************************/
  81.  
  82. /*
  83. ** Initialize the runtime. Attach a thread object to the currently
  84. ** executing native thread of type "type" (as if PR_AttachThread were
  85. ** called).
  86. **
  87. ** The specificaiton of 'maxPTDs' is ignored.
  88. */
  89. PR_EXTERN(void) PR_Init(
  90.     PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs);
  91.  
  92. /*
  93. ** And alternate form of initialization, one that may become the default if
  94. ** not the only mechanism, provides a method to get the NSPR runtime init-
  95. ** ialized and place NSPR between the caller and the runtime library. This
  96. ** allows main() to be treated as any other thread root function, signalling
  97. ** its compeletion by returning and allowing the runtime to coordinate the
  98. ** completion of the other threads of the runtime.
  99. **
  100. ** The priority of the main (or primordial) thread will be PR_PRIORITY_NORMAL.
  101. ** The thread may adjust its own priority by using PR_SetPriority(), though
  102. ** at this time the support for priorities is somewhat weak.
  103. **
  104. ** The specificaiton of 'maxPTDs' is ignored.
  105. **
  106. ** The value returned by PR_Initialize is the value returned from the root
  107. ** function, 'prmain'.
  108. */
  109.  
  110. typedef PRIntn (PR_CALLBACK *PRPrimordialFn)(PRIntn argc, char **argv);
  111.  
  112. PR_EXTERN(PRIntn) PR_Initialize(
  113.     PRPrimordialFn prmain, PRIntn argc, char **argv, PRUintn maxPTDs);
  114.  
  115. /*
  116. ** Return PR_TRUE if PR_Init has already been called.
  117. */
  118. PR_EXTERN(PRBool) PR_Initialized(void);
  119.  
  120. /*
  121.  * Perform a graceful shutdown of NSPR.  PR_Cleanup() may be called by
  122.  * the primordial thread near the end of the main() function.
  123.  *
  124.  * PR_Cleanup() attempts to synchronize the natural termination of
  125.  * process.  It does that by blocking the caller, if and only if it is
  126.  * the primordial thread, until the number of user threads has dropped
  127.  * to zero.  When the primordial thread returns from main(), the process
  128.  * will immediately and silently exit.  That is, it will (if necessary)
  129.  * forcibly terminate any existing threads and exit without significant
  130.  * blocking and there will be no error messages or core files.
  131.  *
  132.  * PR_Cleanup() returns PR_SUCCESS if NSPR is successfully shutdown,
  133.  * or PR_FAILURE if the calling thread of this function is not the
  134.  * primordial thread.
  135.  */
  136. PR_EXTERN(PRStatus) PR_Cleanup(void);
  137.  
  138. /*
  139. ** Disable Interrupts
  140. **        Disables timer signals used for pre-emptive scheduling.
  141. */
  142. PR_EXTERN(void) PR_DisableClockInterrupts(void);
  143.  
  144. /*
  145. ** Block Interrupts
  146. **        Blocks the timer signal used for pre-emptive scheduling
  147. */
  148. PR_EXTERN(void) PR_BlockClockInterrupts(void);
  149.  
  150. /*
  151. ** Unblock Interrupts
  152. **        Unblocks the timer signal used for pre-emptive scheduling
  153. */
  154. PR_EXTERN(void) PR_UnblockClockInterrupts(void);
  155.  
  156. /*
  157. ** Create extra virtual processor threads. Generally used with MP systems.
  158. */
  159. PR_EXTERN(void) PR_SetConcurrency(PRUintn numCPUs);
  160.  
  161. /*
  162.  * Cause an immediate, nongraceful, forced termination of the process.
  163.  * It takes a PRIntn argument, which is the exit status code of the
  164.  * process.
  165.  */
  166. PR_EXTERN(void) PR_ProcessExit(PRIntn status);
  167.  
  168. /*
  169. ** Abort the process in a non-graceful manner. This will cause a core file,
  170. ** call to the debugger or other moral equivalent as well as causing the
  171. ** entire process to stop.
  172. */
  173. PR_EXTERN(void) PR_Abort(void);
  174.  
  175. /*
  176.  ****************************************************************
  177.  *
  178.  * Module initialization:
  179.  *
  180.  ****************************************************************
  181.  */
  182.  
  183. typedef struct PRCallOnceType {
  184.     PRIntn initialized;
  185.     PRInt32 inProgress;
  186.     PRStatus status;
  187. } PRCallOnceType;
  188.  
  189. typedef PRStatus (PR_CALLBACK *PRCallOnceFN)(void);
  190.  
  191. PR_EXTERN(PRStatus) PR_CallOnce(
  192.     PRCallOnceType *once,
  193.     PRCallOnceFN    func
  194. );
  195.  
  196.  
  197. PR_END_EXTERN_C
  198.  
  199. #endif /* prinit_h___ */
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.