15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The contents of this file are subject to the Mozilla Public
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * License Version 1.1 (the "License"); you may not use this file
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * except in compliance with the License. You may obtain a copy of
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * the License at http://www.mozilla.org/MPL/
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Software distributed under the License is distributed on an "AS
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * implied. See the License for the specific language governing
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * rights and limitations under the License.
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The Original Code is the Netscape Portable Runtime (NSPR).
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The Initial Developer of the Original Code is Netscape
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Communications Corporation.  Portions created by Netscape are
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Copyright (C) 1998-2000 Netscape Communications Corporation.  All
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Rights Reserved.
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Contributor(s):
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Alternatively, the contents of this file may be used under the
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * terms of the GNU General Public License Version 2 or later (the
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * "GPL"), in which case the provisions of the GPL are applicable
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * instead of those above.  If you wish to allow use of your
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * version of this file only under the terms of the GPL and not to
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * allow others to use your version of this file under the MPL,
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * indicate your decision by deleting the provisions above and
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * replace them with the notice and other provisions required by
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * the GPL.  If you do not delete the provisions above, a recipient
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * may use your version of this file under either the MPL or the
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * GPL.
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef prcountr_h___
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define prcountr_h___
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*----------------------------------------------------------------------------
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** prcountr.h -- NSPR Instrumentation counters
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** The NSPR Counter Feature provides a means to "count
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** something." Counters can be dynamically defined, incremented,
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** decremented, set, and deleted under application program
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** control.
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** The Counter Feature is intended to be used as instrumentation,
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** not as operational data. If you need a counter for operational
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** data, use native integral types.
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Counters are 32bit unsigned intergers. On overflow, a counter
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** will wrap. No exception is recognized or reported.
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** A counter can be dynamically created using a two level naming
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** convention. A "handle" is returned when the counter is
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** created. The counter can subsequently be addressed by its
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** handle. An API is provided to get an existing counter's handle
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** given the names with  which it was originally created.
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Similarly, a counter's name can be retrieved given its handle.
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** The counter naming convention is a two-level hierarchy. The
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** QName is the higher level of the hierarchy; RName is the
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** lower level. RNames can be thought of as existing within a
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** QName. The same RName can exist within multiple QNames. QNames
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** are unique. The NSPR Counter is not a near-zero overhead
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** feature. Application designers should be aware of
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** serialization issues when using the Counter API. Creating a
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** counter locks a large asset, potentially causing a stall. This
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** suggest that applications should create counters at component
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** initialization, for example, and not create and destroy them
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** willy-nilly. ... You have been warned.
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Incrementing and Adding to counters uses atomic operations.
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** The performance of these operations will vary from platform
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** to platform. On platforms where atomic operations are not
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** supported the overhead may be substantial.
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** When traversing the counter database with FindNext functions,
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** the instantaneous values of any given counter is that at the
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** moment of extraction. The state of the entire counter database
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** may not be viewed as atomic.
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** The counter interface may be disabled (No-Op'd) at compile
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** time. When DEBUG is defined at compile time, the Counter
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Feature is compiled into NSPR and applications invoking it.
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** When DEBUG is not defined, the counter macros compile to
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** nothing. To force the Counter Feature to be compiled into an
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** optimized build, define FORCE_NSPR_COUNTERS at compile time
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** for both NSPR and the application intending to use it.
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Application designers should use the macro form of the Counter
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Feature methods to minimize performance impact in optimized
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** builds. The macros normally compile to nothing on optimized
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** builds.
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Application designers should be aware of the effects of
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** debug and optimized build differences when using result of the
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Counter Feature macros in expressions.
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** The Counter Feature is thread-safe and SMP safe.
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** /lth. 09-Jun-1998.
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "prtypes.h"
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)PR_BEGIN_EXTERN_C
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Opaque counter handle type.
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** ... don't even think of looking in here.
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef void *  PRCounterHandle;
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PRCOUNTER_NAME_MAX 31
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PRCOUNTER_DESC_MAX 255
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -----------------------------------------------------------------------
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_DEFINE_COUNTER() -- Define a PRCounterHandle
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: PR_DEFINE_COUNTER() is used to define a counter
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** handle.
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_DEFINE_COUNTER(name) PRCounterHandle name
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -----------------------------------------------------------------------
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_INIT_COUNTER_HANDLE() -- Set the value of a PRCounterHandle
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION:
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PR_INIT_COUNTER_HANDLE() sets the value of a PRCounterHandle
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** to value.
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_INIT_COUNTER_HANDLE(handle,value)\
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    (handle) = (PRCounterHandle)(value)
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_INIT_COUNTER_HANDLE(handle,value)
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -----------------------------------------------------------------------
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_CreateCounter() -- Create a counter
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: PR_CreateCounter() creates a counter object and
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** initializes it to zero.
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** The macro form takes as its first argument the name of the
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PRCounterHandle to receive the handle returned from
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PR_CreateCounter().
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** INPUTS:
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  qName: The QName for the counter object. The maximum length
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** of qName is defined by PRCOUNTER_NAME_MAX
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  rName: The RName for the counter object. The maximum length
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** of qName is defined by PRCOUNTER_NAME_MAX
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  descrioption: The description of the counter object. The
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** maximum length of description is defined by
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PRCOUNTER_DESC_MAX.
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** OUTPUTS:
1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURNS:
1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  PRCounterHandle.
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RESTRICTIONS:
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_CREATE_COUNTER(handle,qName,rName,description)\
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   (handle) = PR_CreateCounter((qName),(rName),(description))
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_CREATE_COUNTER(handle,qName,rName,description)
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRCounterHandle)
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PR_CreateCounter(
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)		const char *qName,
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    	const char *rName,
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        const char *description
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles));
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -----------------------------------------------------------------------
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_DestroyCounter() -- Destroy a counter object.
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: PR_DestroyCounter() removes a counter and
1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** unregisters its handle from the counter database.
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** INPUTS:
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  handle: the PRCounterHandle of the counter to be destroyed.
1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** OUTPUTS:
1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  The counter is destroyed.
1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURNS: void
2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RESTRICTIONS:
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_DESTROY_COUNTER(handle) PR_DestroyCounter((handle))
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_DESTROY_COUNTER(handle)
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(void)
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PR_DestroyCounter(
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)		PRCounterHandle handle
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles));
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -----------------------------------------------------------------------
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_GetCounterHandleFromName() -- Retreive a
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** counter's handle give its name.
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: PR_GetCounterHandleFromName() retreives a
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** counter's handle from the counter database, given the name
2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** the counter was originally created with.
2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** INPUTS:
2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  qName: Counter's original QName.
2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  rName: Counter's original RName.
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** OUTPUTS:
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURNS:
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  PRCounterHandle or PRCounterError.
2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RESTRICTIONS:
2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_GET_COUNTER_HANDLE_FROM_NAME(handle,qName,rName)\
2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    (handle) = PR_GetCounterHandleFromName((qName),(rName))
2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_GET_COUNTER_HANDLE_FROM_NAME(handle,qName,rName)
2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRCounterHandle)
2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PR_GetCounterHandleFromName(
2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    	const char *qName,
2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    	const char *rName
2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles));
2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -----------------------------------------------------------------------
2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_GetCounterNameFromHandle() -- Retreive a
2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** counter's name, given its handle.
2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: PR_GetCounterNameFromHandle() retreives a
2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** counter's name given its handle.
2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** INPUTS:
2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  qName: Where to store a pointer to qName.
2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  rName: Where to store a pointer to rName.
2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  description: Where to store a pointer to description.
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** OUTPUTS: Pointers to the Counter Feature's copies of the names
2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** used when the counters were created.
2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURNS: void
2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RESTRICTIONS:
2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_GET_COUNTER_NAME_FROM_HANDLE(handle,qName,rName,description)\
2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_GetCounterNameFromHandle((handle),(qName),(rName),(description))
2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_GET_COUNTER_NAME_FROM_HANDLE(handle,qName,rName,description )
2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(void)
2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PR_GetCounterNameFromHandle(
2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    	PRCounterHandle handle,
2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	    const char **qName,
2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	    const char **rName,
2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)		const char **description
2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles));
2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -----------------------------------------------------------------------
2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_IncrementCounter() -- Add one to the referenced
2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** counter.
2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: Add one to the referenced counter.
2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** INPUTS:
2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  handle: The PRCounterHandle of the counter to be incremented
2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** OUTPUTS: The counter is incrementd.
2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURNS: void
2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RESTRICTIONS:
2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_INCREMENT_COUNTER(handle) PR_IncrementCounter(handle)
3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_INCREMENT_COUNTER(handle)
3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(void)
3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PR_IncrementCounter(
3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)		PRCounterHandle handle
3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles));
3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -----------------------------------------------------------------------
3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_DecrementCounter() -- Subtract one from the
3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** referenced counter
3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: Subtract one from the referenced counter.
3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** INPUTS:
3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  handle: The PRCounterHandle of the coutner to be
3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** decremented.
3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** OUTPUTS: the counter is decremented.
3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURNS: void
3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RESTRICTIONS:
3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_DECREMENT_COUNTER(handle) PR_DecrementCounter(handle)
3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_DECREMENT_COUNTER(handle)
3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(void)
3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PR_DecrementCounter(
3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)		PRCounterHandle handle
3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles));
3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -----------------------------------------------------------------------
3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_AddToCounter() -- Add a value to a counter.
3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: Add value to the counter referenced by handle.
3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** INPUTS:
3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  handle: the PRCounterHandle of the counter to be added to.
3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  value: the value to be added to the counter.
3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** OUTPUTS: new value for counter.
3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURNS: void
3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RESTRICTIONS:
3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_ADD_TO_COUNTER(handle,value)\
3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_AddToCounter((handle),(value))
3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_ADD_TO_COUNTER(handle,value)
3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(void)
3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PR_AddToCounter(
3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    	PRCounterHandle handle,
3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	    PRUint32 value
3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles));
3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -----------------------------------------------------------------------
3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_SubtractFromCounter() -- A value is subtracted
3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** from a counter.
3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION:
3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Subtract a value from a counter.
3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** INPUTS:
3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  handle: the PRCounterHandle of the counter to be subtracted
3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** from.
3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  value: the value to be subtracted from the counter.
3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** OUTPUTS: new value for counter
3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURNS: void
3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RESTRICTIONS:
3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_SUBTRACT_FROM_COUNTER(handle,value)\
3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SubtractFromCounter((handle),(value))
3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_SUBTRACT_FROM_COUNTER(handle,value)
3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(void)
4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PR_SubtractFromCounter(
4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    	PRCounterHandle handle,
4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	    PRUint32 value
4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles));
4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -----------------------------------------------------------------------
4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_GetCounter() -- Retreive the value of a counter
4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION:
4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Retreive the value of a counter.
4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** INPUTS:
4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  handle: the PR_CounterHandle of the counter to be retreived
4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** OUTPUTS:
4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURNS: The value of the referenced counter
4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RESTRICTIONS:
4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_GET_COUNTER(counter,handle)\
4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    (counter) = PR_GetCounter((handle))
4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_GET_COUNTER(counter,handle) 0
4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRUint32)
4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PR_GetCounter(
4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)		PRCounterHandle handle
4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles));
4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -----------------------------------------------------------------------
4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_SetCounter() -- Replace the content of counter
4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** with value.
4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: The contents of the referenced counter are
4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** replaced by value.
4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** INPUTS:
4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  handle: the PRCounterHandle of the counter whose contents
4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** are to be replaced.
4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  value: the new value of the counter.
4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** OUTPUTS:
4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURNS: void
4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RESTRICTIONS:
4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
4545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
4555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_SET_COUNTER(handle,value) PR_SetCounter((handle),(value))
4565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
4575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_SET_COUNTER(handle,value)
4585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
4595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(void)
4615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PR_SetCounter(
4625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)		PRCounterHandle handle,
4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)		PRUint32 value
4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles));
4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -----------------------------------------------------------------------
4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_FindNextCounterQname() -- Retreive the next QName counter
4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** handle iterator
4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION:
4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PR_FindNextCounterQname() retreives the first or next Qname
4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** the counter data base, depending on the value of handle. When
4745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** handle is NULL, the function attempts to retreive the first
4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** QName handle in the database. When handle is a handle previosly
4765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** retreived QName handle, then the function attempts to retreive
4775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** the next QName handle.
4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** INPUTS:
4805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  handle: PRCounterHandle or NULL.
4815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** OUTPUTS: returned
4835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURNS: PRCounterHandle or NULL when no more QName counter
4855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** handles are present.
4865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RESTRICTIONS:
4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  A concurrent PR_CreateCounter() or PR_DestroyCounter() may
4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** cause unpredictable results.
4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** A PRCounterHandle returned from this function may only be used
4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** in another PR_FindNextCounterQname() function call; other
4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** operations may cause unpredictable results.
4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
4965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
4975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_FIND_NEXT_COUNTER_QNAME(next,handle)\
4985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    (next) = PR_FindNextCounterQname((handle))
4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_FIND_NEXT_COUNTER_QNAME(next,handle) NULL
5015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
5025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRCounterHandle)
5045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PR_FindNextCounterQname(
5055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRCounterHandle handle
5065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles));
5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -----------------------------------------------------------------------
5095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_FindNextCounterRname() -- Retreive the next RName counter
5105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** handle iterator
5115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION:
5135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PR_FindNextCounterRname() retreives the first or next RNname
5145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** handle from the counter data base, depending on the
5155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** value of handle. When handle is NULL, the function attempts to
5165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** retreive the first RName handle in the database. When handle is
5175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** a handle previosly retreived RName handle, then the function
5185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** attempts to retreive the next RName handle.
5195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
5205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** INPUTS:
5215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  handle: PRCounterHandle or NULL.
5225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  qhandle: PRCounterHandle of a previously aquired via
5235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PR_FIND_NEXT_QNAME_HANDLE()
5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
5255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** OUTPUTS: returned
5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURNS: PRCounterHandle or NULL when no more RName counter
5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** handles are present.
5295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
5305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RESTRICTIONS:
5315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**  A concurrent PR_CreateCounter() or PR_DestroyCounter() may
5325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** cause unpredictable results.
5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** A PRCounterHandle returned from this function may only be used
5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** in another PR_FindNextCounterRname() function call; other
5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** operations may cause unpredictable results.
5375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
5385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
5395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
5405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_FIND_NEXT_COUNTER_RNAME(next,rhandle,qhandle)\
5415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    (next) = PR_FindNextCounterRname((rhandle),(qhandle))
5425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
5435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_FIND_NEXT_COUNTER_RNAME(next,rhandle,qhandle)
5445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
5455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRCounterHandle)
5475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PR_FindNextCounterRname(
5485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRCounterHandle rhandle,
5495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRCounterHandle qhandle
5505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles));
5515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)PR_END_EXTERN_C
5535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* prcountr_h___ */
555