PageRenderTime 26ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/gecko_api/include/nssilckt.h

http://firefox-mac-pdf.googlecode.com/
C Header | 225 lines | 70 code | 13 blank | 142 comment | 0 complexity | 29e9bdd99ad6943024b5d33698292bfe MD5 | raw file
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/MPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * The Original Code is the Netscape security libraries.
  15. *
  16. * The Initial Developer of the Original Code is
  17. * Netscape Communications Corporation.
  18. * Portions created by the Initial Developer are Copyright (C) 1994-2000
  19. * the Initial Developer. All Rights Reserved.
  20. *
  21. * Contributor(s):
  22. *
  23. * Alternatively, the contents of this file may be used under the terms of
  24. * either the GNU General Public License Version 2 or later (the "GPL"), or
  25. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  26. * in which case the provisions of the GPL or the LGPL are applicable instead
  27. * of those above. If you wish to allow use of your version of this file only
  28. * under the terms of either the GPL or the LGPL, and not to allow others to
  29. * use your version of this file under the terms of the MPL, indicate your
  30. * decision by deleting the provisions above and replace them with the notice
  31. * and other provisions required by the GPL or the LGPL. If you do not delete
  32. * the provisions above, a recipient may use your version of this file under
  33. * the terms of any one of the MPL, the GPL or the LGPL.
  34. *
  35. * ***** END LICENSE BLOCK ***** */
  36. /*
  37. ** nssilock.h - Instrumented locking functions for NSS
  38. **
  39. ** Description:
  40. ** nssilock provides instrumentation for locks and monitors in
  41. ** the NSS libraries. The instrumentation, when enabled, causes
  42. ** each call to the instrumented function to record data about
  43. ** the call to an external file. The external file
  44. ** subsequently used to extract performance data and other
  45. ** statistical information about the operation of locks used in
  46. ** the nss library.
  47. **
  48. ** To enable compilation with instrumentation, build NSS with
  49. ** the compile time switch NEED_NSS_ILOCK defined.
  50. **
  51. ** say: "gmake OS_CFLAGS+=-DNEED_NSS_ILOCK" at make time.
  52. **
  53. ** At runtime, to enable recording from nssilock, one or more
  54. ** environment variables must be set. For each nssILockType to
  55. ** be recorded, an environment variable of the form NSS_ILOCK_x
  56. ** must be set to 1. For example:
  57. **
  58. ** set NSS_ILOCK_Cert=1
  59. **
  60. ** nssilock uses PRLOG is used to record to trace data. The
  61. ** PRLogModule name associated with nssilock data is: "nssilock".
  62. ** To enable recording of nssilock data you will need to set the
  63. ** environment variable NSPR_LOG_MODULES to enable
  64. ** recording for the nssilock log module. Similarly, you will
  65. ** need to set the environment variable NSPR_LOG_FILE to specify
  66. ** the filename to receive the recorded data. See prlog.h for usage.
  67. ** Example:
  68. **
  69. ** export NSPR_LOG_MODULES=nssilock:6
  70. ** export NSPR_LOG_FILE=xxxLogfile
  71. **
  72. ** Operation:
  73. ** nssilock wraps calls to NSPR's PZLock and PZMonitor functions
  74. ** with similarly named functions: PZ_NewLock(), etc. When NSS is
  75. ** built with lock instrumentation enabled, the PZ* functions are
  76. ** compiled into NSS; when lock instrumentation is disabled,
  77. ** calls to PZ* functions are directly mapped to PR* functions
  78. ** and the instrumentation arguments to the PZ* functions are
  79. ** compiled away.
  80. **
  81. **
  82. ** File Format:
  83. ** The format of the external file is implementation
  84. ** dependent. Where NSPR's PR_LOG() function is used, the file
  85. ** contains data defined for PR_LOG() plus the data written by
  86. ** the wrapped function. On some platforms and under some
  87. ** circumstances, platform dependent logging or
  88. ** instrumentation probes may be used. In any case, the
  89. ** relevant data provided by the lock instrumentation is:
  90. **
  91. ** lockType, func, address, duration, line, file [heldTime]
  92. **
  93. ** where:
  94. **
  95. ** lockType: a character representation of nssILockType for the
  96. ** call. e.g. ... "cert"
  97. **
  98. ** func: the function doing the tracing. e.g. "NewLock"
  99. **
  100. ** address: address of the instrumented lock or monitor
  101. **
  102. ** duration: is how long was spent in the instrumented function,
  103. ** in PRIntervalTime "ticks".
  104. **
  105. ** line: the line number within the calling function
  106. **
  107. ** file: the file from which the call was made
  108. **
  109. ** heldTime: how long the lock/monitor was held. field
  110. ** present only for PZ_Unlock() and PZ_ExitMonitor().
  111. **
  112. ** Design Notes:
  113. ** The design for lock instrumentation was influenced by the
  114. ** need to gather performance data on NSS 3.x. It is intended
  115. ** that the effort to modify NSS to use lock instrumentation
  116. ** be minimized. Existing calls to locking functions need only
  117. ** have their names changed to the instrumentation function
  118. ** names.
  119. **
  120. ** Private NSS Interface:
  121. ** nssilock.h defines a private interface for use by NSS.
  122. ** nssilock.h is experimental in nature and is subject to
  123. ** change or revocation without notice. ... Don't mess with
  124. ** it.
  125. **
  126. */
  127. /*
  128. * $Id:
  129. */
  130. #ifndef _NSSILCKT_H_
  131. #define _NSSILCKT_H_
  132. #include "utilrename.h"
  133. #include "prtypes.h"
  134. #include "prmon.h"
  135. #include "prlock.h"
  136. #include "prcvar.h"
  137. typedef enum {
  138. nssILockArena = 0,
  139. nssILockSession = 1,
  140. nssILockObject = 2,
  141. nssILockRefLock = 3,
  142. nssILockCert = 4,
  143. nssILockCertDB = 5,
  144. nssILockDBM = 6,
  145. nssILockCache = 7,
  146. nssILockSSL = 8,
  147. nssILockList = 9,
  148. nssILockSlot = 10,
  149. nssILockFreelist = 11,
  150. nssILockOID = 12,
  151. nssILockAttribute = 13,
  152. nssILockPK11cxt = 14, /* pk11context */
  153. nssILockRWLock = 15,
  154. nssILockOther = 16,
  155. nssILockSelfServ = 17,
  156. nssILockKeyDB = 18,
  157. nssILockLast /* don't use this one! */
  158. } nssILockType;
  159. /*
  160. ** Declare operation type enumerator
  161. ** enumerations identify the function being performed
  162. */
  163. typedef enum {
  164. FlushTT = 0,
  165. NewLock = 1,
  166. Lock = 2,
  167. Unlock = 3,
  168. DestroyLock = 4,
  169. NewCondVar = 5,
  170. WaitCondVar = 6,
  171. NotifyCondVar = 7,
  172. NotifyAllCondVar = 8,
  173. DestroyCondVar = 9,
  174. NewMonitor = 10,
  175. EnterMonitor = 11,
  176. ExitMonitor = 12,
  177. Notify = 13,
  178. NotifyAll = 14,
  179. Wait = 15,
  180. DestroyMonitor = 16
  181. } nssILockOp;
  182. /*
  183. ** Declare the trace record
  184. */
  185. struct pzTrace_s {
  186. PRUint32 threadID; /* PR_GetThreadID() */
  187. nssILockOp op; /* operation being performed */
  188. nssILockType ltype; /* lock type identifier */
  189. PRIntervalTime callTime; /* time spent in function */
  190. PRIntervalTime heldTime; /* lock held time, or -1 */
  191. void *lock; /* address of lock structure */
  192. PRIntn line; /* line number */
  193. char file[24]; /* filename */
  194. };
  195. PR_BEGIN_EXTERN_C
  196. /*
  197. ** conditionally compile in nssilock features
  198. */
  199. #if defined(NEED_NSS_ILOCK)
  200. /*
  201. ** declare opaque types. See: nssilock.c
  202. */
  203. typedef struct pzlock_s PZLock;
  204. typedef struct pzcondvar_s PZCondVar;
  205. typedef struct pzmonitor_s PZMonitor;
  206. #else /* NEED_NSS_ILOCK */
  207. #define PZLock PRLock
  208. #define PZCondVar PRCondVar
  209. #define PZMonitor PRMonitor
  210. #endif /* NEED_NSS_ILOCK */
  211. PR_END_EXTERN_C
  212. #endif /* _NSSILCKT_H_ */