summaryrefslogtreecommitdiff
path: root/pr/src/misc/prcountr.c
diff options
context:
space:
mode:
Diffstat (limited to 'pr/src/misc/prcountr.c')
-rw-r--r--pr/src/misc/prcountr.c148
1 files changed, 74 insertions, 74 deletions
diff --git a/pr/src/misc/prcountr.c b/pr/src/misc/prcountr.c
index 0f126ad0..edd57122 100644
--- a/pr/src/misc/prcountr.c
+++ b/pr/src/misc/prcountr.c
@@ -10,16 +10,16 @@
**
** Design Notes:
**
-** The Counter Facility (CF) has a single anchor: qNameList.
+** The Counter Facility (CF) has a single anchor: qNameList.
** The anchor is a PRCList. qNameList is a list of links in QName
** structures. From qNameList any QName structure and its
-** associated RName structure can be located.
-**
+** associated RName structure can be located.
+**
** For each QName, a list of RName structures is anchored at
** rnLink in the QName structure.
-**
+**
** The counter itself is embedded in the RName structure.
-**
+**
** For manipulating the counter database, single lock is used to
** protect the entire list: counterLock.
**
@@ -29,7 +29,7 @@
** "overloaded" for traversing the QName structures; only the
** function PR_FindNextQnameHandle() uses this overloading.
**
-**
+**
** ToDo (lth): decide on how to lock or atomically update
** individual counters. Candidates are: the global lock; a lock
** per RName structure; Atomic operations (Note that there are
@@ -64,9 +64,9 @@ typedef struct RName
PRCList link;
QName *qName;
PRLock *lock;
- volatile PRUint32 counter;
- char name[PRCOUNTER_NAME_MAX+1];
- char desc[PRCOUNTER_DESC_MAX+1];
+ volatile PRUint32 counter;
+ char name[PRCOUNTER_NAME_MAX+1];
+ char desc[PRCOUNTER_DESC_MAX+1];
} RName;
@@ -87,7 +87,7 @@ static void _PR_CounterInitialize( void )
** This function should be called only once
*/
PR_ASSERT( counterLock == NULL );
-
+
counterLock = PR_NewLock();
PR_INIT_CLIST( &qNameList );
lm = PR_NewLogModule("counters");
@@ -111,12 +111,12 @@ static void _PR_CounterInitialize( void )
** Unlock
**
*/
-PR_IMPLEMENT(PRCounterHandle)
- PR_CreateCounter(
- const char *qName,
- const char *rName,
- const char *description
-)
+PR_IMPLEMENT(PRCounterHandle)
+ PR_CreateCounter(
+ const char *qName,
+ const char *rName,
+ const char *description
+)
{
QName *qnp;
RName *rnp;
@@ -157,10 +157,10 @@ PR_IMPLEMENT(PRCounterHandle)
{
qnp = PR_NEWZAP( QName );
PR_ASSERT( qnp != NULL );
- PR_INIT_CLIST( &qnp->link );
- PR_INIT_CLIST( &qnp->rNameList );
+ PR_INIT_CLIST( &qnp->link );
+ PR_INIT_CLIST( &qnp->rNameList );
strcpy( qnp->name, qName );
- PR_APPEND_LINK( &qnp->link, &qNameList );
+ PR_APPEND_LINK( &qnp->link, &qNameList );
}
/* Do we already have a matching RName? */
@@ -189,7 +189,7 @@ PR_IMPLEMENT(PRCounterHandle)
PR_ASSERT(0);
}
- PR_APPEND_LINK( &rnp->link, &qnp->rNameList ); /* add RName to QName's rnList */
+ PR_APPEND_LINK( &rnp->link, &qnp->rNameList ); /* add RName to QName's rnList */
rnp->qName = qnp; /* point the RName to the QName */
/* Unlock the Facility */
@@ -199,20 +199,20 @@ PR_IMPLEMENT(PRCounterHandle)
return((PRCounterHandle)rnp);
} /* end PR_CreateCounter() */
-
+
/*
**
*/
-PR_IMPLEMENT(void)
- PR_DestroyCounter(
- PRCounterHandle handle
+PR_IMPLEMENT(void)
+ PR_DestroyCounter(
+ PRCounterHandle handle
)
{
RName *rnp = (RName *)handle;
QName *qnp = rnp->qName;
- PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: Deleting: QName: %s, RName: %s",
+ PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: Deleting: QName: %s, RName: %s",
qnp->name, rnp->name));
/* Lock the Facility */
@@ -222,7 +222,7 @@ PR_IMPLEMENT(void)
** Remove RName from the list of RNames in QName
** and free RName
*/
- PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: Deleting RName: %s, %p",
+ PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: Deleting RName: %s, %p",
rnp->name, rnp));
PR_REMOVE_LINK( &rnp->link );
PR_Free( rnp->lock );
@@ -234,11 +234,11 @@ PR_IMPLEMENT(void)
*/
if ( PR_CLIST_IS_EMPTY( &qnp->rNameList ) )
{
- PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: Deleting unused QName: %s, %p",
+ PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: Deleting unused QName: %s, %p",
qnp->name, qnp));
PR_REMOVE_LINK( &qnp->link );
PR_DELETE( qnp );
- }
+ }
/* Unlock the Facility */
PR_Unlock( counterLock );
@@ -248,10 +248,10 @@ PR_IMPLEMENT(void)
/*
**
*/
-PR_IMPLEMENT(PRCounterHandle)
- PR_GetCounterHandleFromName(
- const char *qName,
- const char *rName
+PR_IMPLEMENT(PRCounterHandle)
+ PR_GetCounterHandleFromName(
+ const char *qName,
+ const char *rName
)
{
const char *qn, *rn, *desc;
@@ -287,12 +287,12 @@ foundIt:
/*
**
*/
-PR_IMPLEMENT(void)
- PR_GetCounterNameFromHandle(
- PRCounterHandle handle,
- const char **qName,
- const char **rName,
- const char **description
+PR_IMPLEMENT(void)
+ PR_GetCounterNameFromHandle(
+ PRCounterHandle handle,
+ const char **qName,
+ const char **rName,
+ const char **description
)
{
RName *rnp = (RName *)handle;
@@ -303,7 +303,7 @@ PR_IMPLEMENT(void)
*description = rnp->desc;
PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: GetConterNameFromHandle: "
- "QNp: %p, RNp: %p,\n\tQName: %s, RName: %s, Desc: %s",
+ "QNp: %p, RNp: %p,\n\tQName: %s, RName: %s, Desc: %s",
qnp, rnp, qnp->name, rnp->name, rnp->desc ));
return;
@@ -313,8 +313,8 @@ PR_IMPLEMENT(void)
/*
**
*/
-PR_IMPLEMENT(void)
- PR_IncrementCounter(
+PR_IMPLEMENT(void)
+ PR_IncrementCounter(
PRCounterHandle handle
)
{
@@ -322,7 +322,7 @@ PR_IMPLEMENT(void)
((RName *)handle)->counter++;
PR_Unlock(((RName *)handle)->lock);
- PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: Increment: %p, %ld",
+ PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: Increment: %p, %ld",
handle, ((RName *)handle)->counter ));
return;
@@ -333,8 +333,8 @@ PR_IMPLEMENT(void)
/*
**
*/
-PR_IMPLEMENT(void)
- PR_DecrementCounter(
+PR_IMPLEMENT(void)
+ PR_DecrementCounter(
PRCounterHandle handle
)
{
@@ -342,7 +342,7 @@ PR_IMPLEMENT(void)
((RName *)handle)->counter--;
PR_Unlock(((RName *)handle)->lock);
- PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: Decrement: %p, %ld",
+ PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: Decrement: %p, %ld",
handle, ((RName *)handle)->counter ));
return;
@@ -352,17 +352,17 @@ PR_IMPLEMENT(void)
/*
**
*/
-PR_IMPLEMENT(void)
- PR_AddToCounter(
- PRCounterHandle handle,
- PRUint32 value
+PR_IMPLEMENT(void)
+ PR_AddToCounter(
+ PRCounterHandle handle,
+ PRUint32 value
)
{
PR_Lock(((RName *)handle)->lock);
((RName *)handle)->counter += value;
PR_Unlock(((RName *)handle)->lock);
- PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: AddToCounter: %p, %ld",
+ PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: AddToCounter: %p, %ld",
handle, ((RName *)handle)->counter ));
return;
@@ -372,17 +372,17 @@ PR_IMPLEMENT(void)
/*
**
*/
-PR_IMPLEMENT(void)
- PR_SubtractFromCounter(
- PRCounterHandle handle,
- PRUint32 value
+PR_IMPLEMENT(void)
+ PR_SubtractFromCounter(
+ PRCounterHandle handle,
+ PRUint32 value
)
{
PR_Lock(((RName *)handle)->lock);
((RName *)handle)->counter -= value;
PR_Unlock(((RName *)handle)->lock);
-
- PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: SubtractFromCounter: %p, %ld",
+
+ PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: SubtractFromCounter: %p, %ld",
handle, ((RName *)handle)->counter ));
return;
@@ -391,12 +391,12 @@ PR_IMPLEMENT(void)
/*
**
*/
-PR_IMPLEMENT(PRUint32)
- PR_GetCounter(
- PRCounterHandle handle
+PR_IMPLEMENT(PRUint32)
+ PR_GetCounter(
+ PRCounterHandle handle
)
{
- PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: GetCounter: %p, %ld",
+ PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: GetCounter: %p, %ld",
handle, ((RName *)handle)->counter ));
return(((RName *)handle)->counter);
@@ -405,15 +405,15 @@ PR_IMPLEMENT(PRUint32)
/*
**
*/
-PR_IMPLEMENT(void)
- PR_SetCounter(
- PRCounterHandle handle,
- PRUint32 value
+PR_IMPLEMENT(void)
+ PR_SetCounter(
+ PRCounterHandle handle,
+ PRUint32 value
)
{
((RName *)handle)->counter = value;
- PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: SetCounter: %p, %ld",
+ PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: SetCounter: %p, %ld",
handle, ((RName *)handle)->counter ));
return;
@@ -422,8 +422,8 @@ PR_IMPLEMENT(void)
/*
**
*/
-PR_IMPLEMENT(PRCounterHandle)
- PR_FindNextCounterQname(
+PR_IMPLEMENT(PRCounterHandle)
+ PR_FindNextCounterQname(
PRCounterHandle handle
)
{
@@ -435,10 +435,10 @@ PR_IMPLEMENT(PRCounterHandle)
qnp = (QName *)PR_LIST_HEAD( &qNameList );
else if ( PR_NEXT_LINK( &qnp->link ) == &qNameList )
qnp = NULL;
- else
+ else
qnp = (QName *)PR_NEXT_LINK( &qnp->link );
- PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: FindNextQname: Handle: %p, Returns: %p",
+ PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: FindNextQname: Handle: %p, Returns: %p",
handle, qnp ));
return((PRCounterHandle)qnp);
@@ -448,10 +448,10 @@ PR_IMPLEMENT(PRCounterHandle)
/*
**
*/
-PR_IMPLEMENT(PRCounterHandle)
- PR_FindNextCounterRname(
- PRCounterHandle rhandle,
- PRCounterHandle qhandle
+PR_IMPLEMENT(PRCounterHandle)
+ PR_FindNextCounterRname(
+ PRCounterHandle rhandle,
+ PRCounterHandle qhandle
)
{
RName *rnp = (RName *)rhandle;
@@ -467,7 +467,7 @@ PR_IMPLEMENT(PRCounterHandle)
else
rnp = (RName *)PR_NEXT_LINK( &rnp->link );
- PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: FindNextRname: Rhandle: %p, QHandle: %p, Returns: %p",
+ PR_LOG( lm, PR_LOG_DEBUG, ("PR_Counter: FindNextRname: Rhandle: %p, QHandle: %p, Returns: %p",
rhandle, qhandle, rnp ));
return((PRCounterHandle)rnp);