]>
git.saurik.com Git - apple/security.git/blob - Security/libsecurity_asn1/lib/nssilock.h
2 * The contents of this file are subject to the Mozilla Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/MPL/
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
12 * The Original Code is the Netscape security libraries.
14 * The Initial Developer of the Original Code is Netscape
15 * Communications Corporation. Portions created by Netscape are
16 * Copyright (C) 1994-2000 Netscape Communications Corporation. All
21 * Alternatively, the contents of this file may be used under the
22 * terms of the GNU General Public License Version 2 or later (the
23 * "GPL"), in which case the provisions of the GPL are applicable
24 * instead of those above. If you wish to allow use of your
25 * version of this file only under the terms of the GPL and not to
26 * allow others to use your version of this file under the MPL,
27 * indicate your decision by deleting the provisions above and
28 * replace them with the notice and other provisions required by
29 * the GPL. If you do not delete the provisions above, a recipient
30 * may use your version of this file under either the MPL or the
35 ** nssilock.h - Instrumented locking functions for NSS
38 ** nssilock provides instrumentation for locks and monitors in
39 ** the NSS libraries. The instrumentation, when enabled, causes
40 ** each call to the instrumented function to record data about
41 ** the call to an external file. The external file
42 ** subsequently used to extract performance data and other
43 ** statistical information about the operation of locks used in
46 ** To enable compilation with instrumentation, build NSS with
47 ** the compile time switch NEED_NSS_ILOCK defined.
49 ** say: "gmake OS_CFLAGS+=-DNEED_NSS_ILOCK" at make time.
51 ** At runtime, to enable recording from nssilock, one or more
52 ** environment variables must be set. For each nssILockType to
53 ** be recorded, an environment variable of the form NSS_ILOCK_x
54 ** must be set to 1. For example:
56 ** set NSS_ILOCK_Cert=1
58 ** nssilock uses PRLOG is used to record to trace data. The
59 ** PRLogModule name associated with nssilock data is: "nssilock".
60 ** To enable recording of nssilock data you will need to set the
61 ** environment variable NSPR_LOG_MODULES to enable
62 ** recording for the nssilock log module. Similarly, you will
63 ** need to set the environment variable NSPR_LOG_FILE to specify
64 ** the filename to receive the recorded data. See prlog.h for usage.
67 ** export NSPR_LOG_MODULES=nssilock:6
68 ** export NSPR_LOG_FILE=xxxLogfile
71 ** nssilock wraps calls to NSPR's PZLock and PZMonitor functions
72 ** with similarly named functions: PZ_NewLock(), etc. When NSS is
73 ** built with lock instrumentation enabled, the PZ* functions are
74 ** compiled into NSS; when lock instrumentation is disabled,
75 ** calls to PZ* functions are directly mapped to PR* functions
76 ** and the instrumentation arguments to the PZ* functions are
81 ** The format of the external file is implementation
82 ** dependent. Where NSPR's PR_LOG() function is used, the file
83 ** contains data defined for PR_LOG() plus the data written by
84 ** the wrapped function. On some platforms and under some
85 ** circumstances, platform dependent logging or
86 ** instrumentation probes may be used. In any case, the
87 ** relevant data provided by the lock instrumentation is:
89 ** lockType, func, address, duration, line, file [heldTime]
93 ** lockType: a character representation of nssILockType for the
94 ** call. e.g. ... "cert"
96 ** func: the function doing the tracing. e.g. "NewLock"
98 ** address: address of the instrumented lock or monitor
100 ** duration: is how long was spent in the instrumented function,
101 ** in PRIntervalTime "ticks".
103 ** line: the line number within the calling function
105 ** file: the file from which the call was made
107 ** heldTime: how long the lock/monitor was held. field
108 ** present only for PZ_Unlock() and PZ_ExitMonitor().
111 ** The design for lock instrumentation was influenced by the
112 ** need to gather performance data on NSS 3.x. It is intended
113 ** that the effort to modify NSS to use lock instrumentation
114 ** be minimized. Existing calls to locking functions need only
115 ** have their names changed to the instrumentation function
118 ** Private NSS Interface:
119 ** nssilock.h defines a private interface for use by NSS.
120 ** nssilock.h is experimental in nature and is subject to
121 ** change or revocation without notice. ... Don't mess with
138 #include "nssilckt.h"
142 #if defined(NEED_NSS_ILOCK)
144 #define PZ_NewLock(t) pz_NewLock((t),__FILE__,__LINE__)
152 #define PZ_Lock(k) pz_Lock((k),__FILE__,__LINE__)
160 #define PZ_Unlock(k) pz_Unlock((k),__FILE__,__LINE__)
168 #define PZ_DestroyLock(k) pz_DestroyLock((k),__FILE__,__LINE__)
177 #define PZ_NewCondVar(l) pz_NewCondVar((l),__FILE__,__LINE__)
185 #define PZ_DestroyCondVar(v) pz_DestroyCondVar((v),__FILE__,__LINE__)
193 #define PZ_WaitCondVar(v,t) pz_WaitCondVar((v),(t),__FILE__,__LINE__)
197 PRIntervalTime timeout
,
202 #define PZ_NotifyCondVar(v) pz_NotifyCondVar((v),__FILE__,__LINE__)
210 #define PZ_NotifyAllCondVar(v) pz_NotifyAllCondVar((v),__FILE__,__LINE__)
219 #define PZ_NewMonitor(t) pz_NewMonitor((t),__FILE__,__LINE__)
227 #define PZ_DestroyMonitor(m) pz_DestroyMonitor((m),__FILE__,__LINE__)
235 #define PZ_EnterMonitor(m) pz_EnterMonitor((m),__FILE__,__LINE__)
244 #define PZ_ExitMonitor(m) pz_ExitMonitor((m),__FILE__,__LINE__)
252 #define PZ_InMonitor(m) (PZ_GetMonitorEntryCount(m) > 0 )
253 #define PZ_GetMonitorEntryCount(m) pz_GetMonitorEntryCount((m),__FILE__,__LINE__)
255 pz_GetMonitorEntryCount(
261 #define PZ_Wait(m,i) pz_Wait((m),((i)),__FILE__,__LINE__)
265 PRIntervalTime ticks
,
270 #define PZ_Notify(m) pz_Notify((m),__FILE__,__LINE__)
278 #define PZ_NotifyAll(m) pz_NotifyAll((m),__FILE__,__LINE__)
286 #define PZ_TraceFlush() pz_TraceFlush()
287 extern void pz_TraceFlush( void );
289 #else /* NEED_NSS_ILOCK */
291 #define PZ_NewLock(t) PR_NewLock()
292 #define PZ_DestroyLock(k) PR_DestroyLock((k))
293 #define PZ_Lock(k) PR_Lock((k))
294 #define PZ_Unlock(k) PR_Unlock((k))
296 #define PZ_NewCondVar(l) PR_NewCondVar((l))
297 #define PZ_DestroyCondVar(v) PR_DestroyCondVar((v))
298 #define PZ_WaitCondVar(v,t) PR_WaitCondVar((v),(t))
299 #define PZ_NotifyCondVar(v) PR_NotifyCondVar((v))
300 #define PZ_NotifyAllCondVar(v) PR_NotifyAllCondVar((v))
302 #define PZ_NewMonitor(t) PR_NewMonitor()
303 #define PZ_DestroyMonitor(m) PR_DestroyMonitor((m))
304 #define PZ_EnterMonitor(m) PR_EnterMonitor((m))
305 #define PZ_ExitMonitor(m) PR_ExitMonitor((m))
306 #define PZ_InMonitor(m) PR_InMonitor((m))
307 #define PZ_Wait(m,t) PR_Wait(((m)),((t)))
308 #define PZ_Notify(m) PR_Notify((m))
309 #define PZ_NotifyAll(m) PR_Notify((m))
310 #define PZ_TraceFlush() /* nothing */
313 #endif /* NEED_NSS_ILOCK */
316 #endif /* _NSSILOCK_H_ */