PageRenderTime 44ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/gecko_api/include/nssilock.h

http://firefox-mac-pdf.googlecode.com/
C Header | 320 lines | 156 code | 35 blank | 129 comment | 0 complexity | 1ab891868aeb69c030b7d7f3c9df571c 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 _NSSILOCK_H_
  131. #define _NSSILOCK_H_
  132. #include "utilrename.h"
  133. #include "prtypes.h"
  134. #include "prmon.h"
  135. #include "prlock.h"
  136. #include "prcvar.h"
  137. #include "nssilckt.h"
  138. PR_BEGIN_EXTERN_C
  139. #if defined(NEED_NSS_ILOCK)
  140. #define PZ_NewLock(t) pz_NewLock((t),__FILE__,__LINE__)
  141. extern PZLock *
  142. pz_NewLock(
  143. nssILockType ltype,
  144. char *file,
  145. PRIntn line
  146. );
  147. #define PZ_Lock(k) pz_Lock((k),__FILE__,__LINE__)
  148. extern void
  149. pz_Lock(
  150. PZLock *lock,
  151. char *file,
  152. PRIntn line
  153. );
  154. #define PZ_Unlock(k) pz_Unlock((k),__FILE__,__LINE__)
  155. extern PRStatus
  156. pz_Unlock(
  157. PZLock *lock,
  158. char *file,
  159. PRIntn line
  160. );
  161. #define PZ_DestroyLock(k) pz_DestroyLock((k),__FILE__,__LINE__)
  162. extern void
  163. pz_DestroyLock(
  164. PZLock *lock,
  165. char *file,
  166. PRIntn line
  167. );
  168. #define PZ_NewCondVar(l) pz_NewCondVar((l),__FILE__,__LINE__)
  169. extern PZCondVar *
  170. pz_NewCondVar(
  171. PZLock *lock,
  172. char *file,
  173. PRIntn line
  174. );
  175. #define PZ_DestroyCondVar(v) pz_DestroyCondVar((v),__FILE__,__LINE__)
  176. extern void
  177. pz_DestroyCondVar(
  178. PZCondVar *cvar,
  179. char *file,
  180. PRIntn line
  181. );
  182. #define PZ_WaitCondVar(v,t) pz_WaitCondVar((v),(t),__FILE__,__LINE__)
  183. extern PRStatus
  184. pz_WaitCondVar(
  185. PZCondVar *cvar,
  186. PRIntervalTime timeout,
  187. char *file,
  188. PRIntn line
  189. );
  190. #define PZ_NotifyCondVar(v) pz_NotifyCondVar((v),__FILE__,__LINE__)
  191. extern PRStatus
  192. pz_NotifyCondVar(
  193. PZCondVar *cvar,
  194. char *file,
  195. PRIntn line
  196. );
  197. #define PZ_NotifyAllCondVar(v) pz_NotifyAllCondVar((v),__FILE__,__LINE__)
  198. extern PRStatus
  199. pz_NotifyAllCondVar(
  200. PZCondVar *cvar,
  201. char *file,
  202. PRIntn line
  203. );
  204. #define PZ_NewMonitor(t) pz_NewMonitor((t),__FILE__,__LINE__)
  205. extern PZMonitor *
  206. pz_NewMonitor(
  207. nssILockType ltype,
  208. char *file,
  209. PRIntn line
  210. );
  211. #define PZ_DestroyMonitor(m) pz_DestroyMonitor((m),__FILE__,__LINE__)
  212. extern void
  213. pz_DestroyMonitor(
  214. PZMonitor *mon,
  215. char *file,
  216. PRIntn line
  217. );
  218. #define PZ_EnterMonitor(m) pz_EnterMonitor((m),__FILE__,__LINE__)
  219. extern void
  220. pz_EnterMonitor(
  221. PZMonitor *mon,
  222. char *file,
  223. PRIntn line
  224. );
  225. #define PZ_ExitMonitor(m) pz_ExitMonitor((m),__FILE__,__LINE__)
  226. extern PRStatus
  227. pz_ExitMonitor(
  228. PZMonitor *mon,
  229. char *file,
  230. PRIntn line
  231. );
  232. #define PZ_InMonitor(m) (PZ_GetMonitorEntryCount(m) > 0 )
  233. #define PZ_GetMonitorEntryCount(m) pz_GetMonitorEntryCount((m),__FILE__,__LINE__)
  234. extern PRIntn
  235. pz_GetMonitorEntryCount(
  236. PZMonitor *mon,
  237. char *file,
  238. PRIntn line
  239. );
  240. #define PZ_Wait(m,i) pz_Wait((m),((i)),__FILE__,__LINE__)
  241. extern PRStatus
  242. pz_Wait(
  243. PZMonitor *mon,
  244. PRIntervalTime ticks,
  245. char *file,
  246. PRIntn line
  247. );
  248. #define PZ_Notify(m) pz_Notify((m),__FILE__,__LINE__)
  249. extern PRStatus
  250. pz_Notify(
  251. PZMonitor *mon,
  252. char *file,
  253. PRIntn line
  254. );
  255. #define PZ_NotifyAll(m) pz_NotifyAll((m),__FILE__,__LINE__)
  256. extern PRStatus
  257. pz_NotifyAll(
  258. PZMonitor *mon,
  259. char *file,
  260. PRIntn line
  261. );
  262. #define PZ_TraceFlush() pz_TraceFlush()
  263. extern void pz_TraceFlush( void );
  264. #else /* NEED_NSS_ILOCK */
  265. #define PZ_NewLock(t) PR_NewLock()
  266. #define PZ_DestroyLock(k) PR_DestroyLock((k))
  267. #define PZ_Lock(k) PR_Lock((k))
  268. #define PZ_Unlock(k) PR_Unlock((k))
  269. #define PZ_NewCondVar(l) PR_NewCondVar((l))
  270. #define PZ_DestroyCondVar(v) PR_DestroyCondVar((v))
  271. #define PZ_WaitCondVar(v,t) PR_WaitCondVar((v),(t))
  272. #define PZ_NotifyCondVar(v) PR_NotifyCondVar((v))
  273. #define PZ_NotifyAllCondVar(v) PR_NotifyAllCondVar((v))
  274. #define PZ_NewMonitor(t) PR_NewMonitor()
  275. #define PZ_DestroyMonitor(m) PR_DestroyMonitor((m))
  276. #define PZ_EnterMonitor(m) PR_EnterMonitor((m))
  277. #define PZ_ExitMonitor(m) PR_ExitMonitor((m))
  278. #define PZ_InMonitor(m) PR_InMonitor((m))
  279. #define PZ_Wait(m,t) PR_Wait(((m)),((t)))
  280. #define PZ_Notify(m) PR_Notify((m))
  281. #define PZ_NotifyAll(m) PR_Notify((m))
  282. #define PZ_TraceFlush() /* nothing */
  283. #endif /* NEED_NSS_ILOCK */
  284. PR_END_EXTERN_C
  285. #endif /* _NSSILOCK_H_ */