PageRenderTime 83ms CodeModel.GetById 40ms app.highlight 5ms RepoModel.GetById 35ms 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/*
 38** nssilock.h - Instrumented locking functions for NSS
 39**
 40** Description:
 41**    nssilock provides instrumentation for locks and monitors in
 42**    the NSS libraries. The instrumentation, when enabled, causes
 43**    each call to the instrumented function to record data about
 44**    the call to an external file. The external file
 45**    subsequently used to extract performance data and other
 46**    statistical information about the operation of locks used in
 47**    the nss library.
 48**     
 49**    To enable compilation with instrumentation, build NSS with 
 50**    the compile time switch NEED_NSS_ILOCK defined.
 51**
 52**    say:  "gmake OS_CFLAGS+=-DNEED_NSS_ILOCK" at make time.
 53**
 54**    At runtime, to enable recording from nssilock, one or more
 55**    environment variables must be set. For each nssILockType to
 56**    be recorded, an environment variable of the form NSS_ILOCK_x
 57**    must be set to 1. For example:
 58**
 59**       set NSS_ILOCK_Cert=1
 60**
 61**    nssilock uses PRLOG is used to record to trace data. The
 62**    PRLogModule name associated with nssilock data is: "nssilock".
 63**    To enable recording of nssilock data you will need to set the
 64**    environment variable NSPR_LOG_MODULES to enable
 65**    recording for the nssilock log module. Similarly, you will
 66**    need to set the environment variable NSPR_LOG_FILE to specify
 67**    the filename to receive the recorded data. See prlog.h for usage.
 68**    Example:
 69**
 70**        export NSPR_LOG_MODULES=nssilock:6
 71**        export NSPR_LOG_FILE=xxxLogfile
 72**
 73** Operation:
 74**    nssilock wraps calls to NSPR's PZLock and PZMonitor functions
 75**    with similarly named functions: PZ_NewLock(), etc. When NSS is
 76**    built with lock instrumentation enabled, the PZ* functions are
 77**    compiled into NSS; when lock instrumentation is disabled,
 78**    calls to PZ* functions are directly mapped to PR* functions
 79**    and the instrumentation arguments to the PZ* functions are
 80**    compiled away.
 81**
 82**
 83** File Format:
 84**    The format of the external file is implementation
 85**    dependent. Where NSPR's PR_LOG() function is used, the file
 86**    contains data defined for PR_LOG() plus the data written by
 87**    the wrapped function. On some platforms and under some
 88**    circumstances, platform dependent logging or
 89**    instrumentation probes may be used. In any case, the
 90**    relevant data provided by the lock instrumentation is:
 91**    
 92**      lockType, func, address, duration, line, file [heldTime]
 93** 
 94**    where:
 95**    
 96**       lockType: a character representation of nssILockType for the
 97**       call. e.g. ... "cert"
 98**    
 99**       func: the function doing the tracing. e.g. "NewLock"
100**    
101**       address: address of the instrumented lock or monitor
102**    
103**       duration: is how long was spent in the instrumented function,
104**       in PRIntervalTime "ticks".
105**    
106**       line: the line number within the calling function
107**    
108**       file: the file from which the call was made
109**    
110**       heldTime: how long the lock/monitor was held. field
111**       present only for PZ_Unlock() and PZ_ExitMonitor().
112**    
113** Design Notes:
114**    The design for lock instrumentation was influenced by the
115**    need to gather performance data on NSS 3.x. It is intended
116**    that the effort to modify NSS to use lock instrumentation
117**    be minimized. Existing calls to locking functions need only
118**    have their names changed to the instrumentation function
119**    names.
120**    
121** Private NSS Interface:
122**    nssilock.h defines a private interface for use by NSS.
123**    nssilock.h is experimental in nature and is subject to
124**    change or revocation without notice. ... Don't mess with
125**    it.
126**    
127*/
128
129/*
130 * $Id:
131 */
132
133#ifndef _NSSILCKT_H_
134#define _NSSILCKT_H_
135
136#include "utilrename.h"
137#include "prtypes.h"
138#include "prmon.h"
139#include "prlock.h"
140#include "prcvar.h"
141
142typedef enum {
143    nssILockArena = 0,
144    nssILockSession = 1,
145    nssILockObject = 2,
146    nssILockRefLock = 3,
147    nssILockCert = 4,
148    nssILockCertDB = 5,
149    nssILockDBM = 6,
150    nssILockCache = 7,
151    nssILockSSL = 8,
152    nssILockList = 9,
153    nssILockSlot = 10,
154    nssILockFreelist = 11,
155    nssILockOID = 12,
156    nssILockAttribute = 13,
157    nssILockPK11cxt = 14,  /* pk11context */
158    nssILockRWLock = 15,
159    nssILockOther = 16,
160    nssILockSelfServ = 17,
161    nssILockKeyDB = 18,
162    nssILockLast  /* don't use this one! */
163} nssILockType;
164
165/*
166** Declare operation type enumerator
167** enumerations identify the function being performed
168*/
169typedef enum  {
170    FlushTT = 0,
171    NewLock = 1,
172    Lock = 2,
173    Unlock = 3,
174    DestroyLock = 4,
175    NewCondVar = 5,
176    WaitCondVar = 6,
177    NotifyCondVar = 7,
178    NotifyAllCondVar = 8,
179    DestroyCondVar = 9,
180    NewMonitor = 10,
181    EnterMonitor = 11,
182    ExitMonitor = 12,
183    Notify = 13,
184    NotifyAll = 14,
185    Wait = 15,
186    DestroyMonitor = 16
187} nssILockOp;
188
189/*
190** Declare the trace record
191*/
192struct pzTrace_s {
193    PRUint32        threadID; /* PR_GetThreadID() */
194    nssILockOp      op;       /* operation being performed */
195    nssILockType    ltype;    /* lock type identifier */
196    PRIntervalTime  callTime; /* time spent in function */
197    PRIntervalTime  heldTime; /* lock held time, or -1 */
198    void            *lock;    /* address of lock structure */    
199    PRIntn          line;     /* line number */
200    char            file[24]; /* filename */
201};
202
203PR_BEGIN_EXTERN_C
204/*
205** conditionally compile in nssilock features
206*/
207#if defined(NEED_NSS_ILOCK)
208
209/*
210** declare opaque types. See: nssilock.c
211*/
212typedef struct pzlock_s PZLock;
213typedef struct pzcondvar_s PZCondVar;
214typedef struct pzmonitor_s PZMonitor;
215
216#else /* NEED_NSS_ILOCK */
217
218#define PZLock                  PRLock
219#define PZCondVar               PRCondVar
220#define PZMonitor               PRMonitor
221    
222#endif /* NEED_NSS_ILOCK */
223
224PR_END_EXTERN_C
225#endif /* _NSSILCKT_H_ */