]>
git.saurik.com Git - apple/security.git/blob - OSX/include/security_asn1/nssilckt.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
150 nssILockFreelist
= 11,
152 nssILockAttribute
= 13,
153 nssILockPK11cxt
= 14, /* pk11context */
156 nssILockSelfServ
= 17,
157 nssILockLast
/* don't use this one! */
161 ** Declare operation type enumerator
162 ** enumerations identify the function being performed
173 NotifyAllCondVar
= 8,
185 ** Declare the trace record
188 PRUint32 threadID
; /* PR_GetThreadID() */
189 nssILockOp op
; /* operation being performed */
190 nssILockType ltype
; /* lock type identifier */
191 PRIntervalTime callTime
; /* time spent in function */
192 PRIntervalTime heldTime
; /* lock held time, or -1 */
193 void *lock
; /* address of lock structure */
194 PRIntn line
; /* line number */
195 char file
[24]; /* filename */
200 ** conditionally compile in nssilock features
202 #if defined(NEED_NSS_ILOCK)
205 ** declare opaque types. See: nssilock.c
207 typedef struct pzlock_s PZLock
;
208 typedef struct pzcondvar_s PZCondVar
;
209 typedef struct pzmonitor_s PZMonitor
;
211 #else /* NEED_NSS_ILOCK */
213 #define PZLock PRLock
214 #define PZCondVar PRCondVar
215 #define PZMonitor PRMonitor
217 #endif /* NEED_NSS_ILOCK */
220 #endif /* _NSSILCKT_H_ */