Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef prcountr_h___ |
michael@0 | 7 | #define prcountr_h___ |
michael@0 | 8 | |
michael@0 | 9 | /*---------------------------------------------------------------------------- |
michael@0 | 10 | ** prcountr.h -- NSPR Instrumentation counters |
michael@0 | 11 | ** |
michael@0 | 12 | ** The NSPR Counter Feature provides a means to "count |
michael@0 | 13 | ** something." Counters can be dynamically defined, incremented, |
michael@0 | 14 | ** decremented, set, and deleted under application program |
michael@0 | 15 | ** control. |
michael@0 | 16 | ** |
michael@0 | 17 | ** The Counter Feature is intended to be used as instrumentation, |
michael@0 | 18 | ** not as operational data. If you need a counter for operational |
michael@0 | 19 | ** data, use native integral types. |
michael@0 | 20 | ** |
michael@0 | 21 | ** Counters are 32bit unsigned intergers. On overflow, a counter |
michael@0 | 22 | ** will wrap. No exception is recognized or reported. |
michael@0 | 23 | ** |
michael@0 | 24 | ** A counter can be dynamically created using a two level naming |
michael@0 | 25 | ** convention. A "handle" is returned when the counter is |
michael@0 | 26 | ** created. The counter can subsequently be addressed by its |
michael@0 | 27 | ** handle. An API is provided to get an existing counter's handle |
michael@0 | 28 | ** given the names with which it was originally created. |
michael@0 | 29 | ** Similarly, a counter's name can be retrieved given its handle. |
michael@0 | 30 | ** |
michael@0 | 31 | ** The counter naming convention is a two-level hierarchy. The |
michael@0 | 32 | ** QName is the higher level of the hierarchy; RName is the |
michael@0 | 33 | ** lower level. RNames can be thought of as existing within a |
michael@0 | 34 | ** QName. The same RName can exist within multiple QNames. QNames |
michael@0 | 35 | ** are unique. The NSPR Counter is not a near-zero overhead |
michael@0 | 36 | ** feature. Application designers should be aware of |
michael@0 | 37 | ** serialization issues when using the Counter API. Creating a |
michael@0 | 38 | ** counter locks a large asset, potentially causing a stall. This |
michael@0 | 39 | ** suggest that applications should create counters at component |
michael@0 | 40 | ** initialization, for example, and not create and destroy them |
michael@0 | 41 | ** willy-nilly. ... You have been warned. |
michael@0 | 42 | ** |
michael@0 | 43 | ** Incrementing and Adding to counters uses atomic operations. |
michael@0 | 44 | ** The performance of these operations will vary from platform |
michael@0 | 45 | ** to platform. On platforms where atomic operations are not |
michael@0 | 46 | ** supported the overhead may be substantial. |
michael@0 | 47 | ** |
michael@0 | 48 | ** When traversing the counter database with FindNext functions, |
michael@0 | 49 | ** the instantaneous values of any given counter is that at the |
michael@0 | 50 | ** moment of extraction. The state of the entire counter database |
michael@0 | 51 | ** may not be viewed as atomic. |
michael@0 | 52 | ** |
michael@0 | 53 | ** The counter interface may be disabled (No-Op'd) at compile |
michael@0 | 54 | ** time. When DEBUG is defined at compile time, the Counter |
michael@0 | 55 | ** Feature is compiled into NSPR and applications invoking it. |
michael@0 | 56 | ** When DEBUG is not defined, the counter macros compile to |
michael@0 | 57 | ** nothing. To force the Counter Feature to be compiled into an |
michael@0 | 58 | ** optimized build, define FORCE_NSPR_COUNTERS at compile time |
michael@0 | 59 | ** for both NSPR and the application intending to use it. |
michael@0 | 60 | ** |
michael@0 | 61 | ** Application designers should use the macro form of the Counter |
michael@0 | 62 | ** Feature methods to minimize performance impact in optimized |
michael@0 | 63 | ** builds. The macros normally compile to nothing on optimized |
michael@0 | 64 | ** builds. |
michael@0 | 65 | ** |
michael@0 | 66 | ** Application designers should be aware of the effects of |
michael@0 | 67 | ** debug and optimized build differences when using result of the |
michael@0 | 68 | ** Counter Feature macros in expressions. |
michael@0 | 69 | ** |
michael@0 | 70 | ** The Counter Feature is thread-safe and SMP safe. |
michael@0 | 71 | ** |
michael@0 | 72 | ** /lth. 09-Jun-1998. |
michael@0 | 73 | */ |
michael@0 | 74 | |
michael@0 | 75 | #include "prtypes.h" |
michael@0 | 76 | |
michael@0 | 77 | PR_BEGIN_EXTERN_C |
michael@0 | 78 | |
michael@0 | 79 | /* |
michael@0 | 80 | ** Opaque counter handle type. |
michael@0 | 81 | ** ... don't even think of looking in here. |
michael@0 | 82 | ** |
michael@0 | 83 | */ |
michael@0 | 84 | typedef void * PRCounterHandle; |
michael@0 | 85 | |
michael@0 | 86 | #define PRCOUNTER_NAME_MAX 31 |
michael@0 | 87 | #define PRCOUNTER_DESC_MAX 255 |
michael@0 | 88 | |
michael@0 | 89 | |
michael@0 | 90 | |
michael@0 | 91 | /* ----------------------------------------------------------------------- |
michael@0 | 92 | ** FUNCTION: PR_DEFINE_COUNTER() -- Define a PRCounterHandle |
michael@0 | 93 | ** |
michael@0 | 94 | ** DESCRIPTION: PR_DEFINE_COUNTER() is used to define a counter |
michael@0 | 95 | ** handle. |
michael@0 | 96 | ** |
michael@0 | 97 | */ |
michael@0 | 98 | #define PR_DEFINE_COUNTER(name) PRCounterHandle name |
michael@0 | 99 | |
michael@0 | 100 | /* ----------------------------------------------------------------------- |
michael@0 | 101 | ** FUNCTION: PR_INIT_COUNTER_HANDLE() -- Set the value of a PRCounterHandle |
michael@0 | 102 | ** |
michael@0 | 103 | ** DESCRIPTION: |
michael@0 | 104 | ** PR_INIT_COUNTER_HANDLE() sets the value of a PRCounterHandle |
michael@0 | 105 | ** to value. |
michael@0 | 106 | ** |
michael@0 | 107 | */ |
michael@0 | 108 | #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) |
michael@0 | 109 | #define PR_INIT_COUNTER_HANDLE(handle,value)\ |
michael@0 | 110 | (handle) = (PRCounterHandle)(value) |
michael@0 | 111 | #else |
michael@0 | 112 | #define PR_INIT_COUNTER_HANDLE(handle,value) |
michael@0 | 113 | #endif |
michael@0 | 114 | |
michael@0 | 115 | /* ----------------------------------------------------------------------- |
michael@0 | 116 | ** FUNCTION: PR_CreateCounter() -- Create a counter |
michael@0 | 117 | ** |
michael@0 | 118 | ** DESCRIPTION: PR_CreateCounter() creates a counter object and |
michael@0 | 119 | ** initializes it to zero. |
michael@0 | 120 | ** |
michael@0 | 121 | ** The macro form takes as its first argument the name of the |
michael@0 | 122 | ** PRCounterHandle to receive the handle returned from |
michael@0 | 123 | ** PR_CreateCounter(). |
michael@0 | 124 | ** |
michael@0 | 125 | ** INPUTS: |
michael@0 | 126 | ** qName: The QName for the counter object. The maximum length |
michael@0 | 127 | ** of qName is defined by PRCOUNTER_NAME_MAX |
michael@0 | 128 | ** |
michael@0 | 129 | ** rName: The RName for the counter object. The maximum length |
michael@0 | 130 | ** of qName is defined by PRCOUNTER_NAME_MAX |
michael@0 | 131 | ** |
michael@0 | 132 | ** descrioption: The description of the counter object. The |
michael@0 | 133 | ** maximum length of description is defined by |
michael@0 | 134 | ** PRCOUNTER_DESC_MAX. |
michael@0 | 135 | ** |
michael@0 | 136 | ** OUTPUTS: |
michael@0 | 137 | ** |
michael@0 | 138 | ** RETURNS: |
michael@0 | 139 | ** PRCounterHandle. |
michael@0 | 140 | ** |
michael@0 | 141 | ** RESTRICTIONS: |
michael@0 | 142 | ** |
michael@0 | 143 | */ |
michael@0 | 144 | #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) |
michael@0 | 145 | #define PR_CREATE_COUNTER(handle,qName,rName,description)\ |
michael@0 | 146 | (handle) = PR_CreateCounter((qName),(rName),(description)) |
michael@0 | 147 | #else |
michael@0 | 148 | #define PR_CREATE_COUNTER(handle,qName,rName,description) |
michael@0 | 149 | #endif |
michael@0 | 150 | |
michael@0 | 151 | NSPR_API(PRCounterHandle) |
michael@0 | 152 | PR_CreateCounter( |
michael@0 | 153 | const char *qName, |
michael@0 | 154 | const char *rName, |
michael@0 | 155 | const char *description |
michael@0 | 156 | ); |
michael@0 | 157 | |
michael@0 | 158 | /* ----------------------------------------------------------------------- |
michael@0 | 159 | ** FUNCTION: PR_DestroyCounter() -- Destroy a counter object. |
michael@0 | 160 | ** |
michael@0 | 161 | ** DESCRIPTION: PR_DestroyCounter() removes a counter and |
michael@0 | 162 | ** unregisters its handle from the counter database. |
michael@0 | 163 | ** |
michael@0 | 164 | ** INPUTS: |
michael@0 | 165 | ** handle: the PRCounterHandle of the counter to be destroyed. |
michael@0 | 166 | ** |
michael@0 | 167 | ** OUTPUTS: |
michael@0 | 168 | ** The counter is destroyed. |
michael@0 | 169 | ** |
michael@0 | 170 | ** RETURNS: void |
michael@0 | 171 | ** |
michael@0 | 172 | ** RESTRICTIONS: |
michael@0 | 173 | ** |
michael@0 | 174 | */ |
michael@0 | 175 | #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) |
michael@0 | 176 | #define PR_DESTROY_COUNTER(handle) PR_DestroyCounter((handle)) |
michael@0 | 177 | #else |
michael@0 | 178 | #define PR_DESTROY_COUNTER(handle) |
michael@0 | 179 | #endif |
michael@0 | 180 | |
michael@0 | 181 | NSPR_API(void) |
michael@0 | 182 | PR_DestroyCounter( |
michael@0 | 183 | PRCounterHandle handle |
michael@0 | 184 | ); |
michael@0 | 185 | |
michael@0 | 186 | |
michael@0 | 187 | /* ----------------------------------------------------------------------- |
michael@0 | 188 | ** FUNCTION: PR_GetCounterHandleFromName() -- Retreive a |
michael@0 | 189 | ** counter's handle give its name. |
michael@0 | 190 | ** |
michael@0 | 191 | ** DESCRIPTION: PR_GetCounterHandleFromName() retreives a |
michael@0 | 192 | ** counter's handle from the counter database, given the name |
michael@0 | 193 | ** the counter was originally created with. |
michael@0 | 194 | ** |
michael@0 | 195 | ** INPUTS: |
michael@0 | 196 | ** qName: Counter's original QName. |
michael@0 | 197 | ** rName: Counter's original RName. |
michael@0 | 198 | ** |
michael@0 | 199 | ** OUTPUTS: |
michael@0 | 200 | ** |
michael@0 | 201 | ** RETURNS: |
michael@0 | 202 | ** PRCounterHandle or PRCounterError. |
michael@0 | 203 | ** |
michael@0 | 204 | ** RESTRICTIONS: |
michael@0 | 205 | ** |
michael@0 | 206 | */ |
michael@0 | 207 | #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) |
michael@0 | 208 | #define PR_GET_COUNTER_HANDLE_FROM_NAME(handle,qName,rName)\ |
michael@0 | 209 | (handle) = PR_GetCounterHandleFromName((qName),(rName)) |
michael@0 | 210 | #else |
michael@0 | 211 | #define PR_GET_COUNTER_HANDLE_FROM_NAME(handle,qName,rName) |
michael@0 | 212 | #endif |
michael@0 | 213 | |
michael@0 | 214 | NSPR_API(PRCounterHandle) |
michael@0 | 215 | PR_GetCounterHandleFromName( |
michael@0 | 216 | const char *qName, |
michael@0 | 217 | const char *rName |
michael@0 | 218 | ); |
michael@0 | 219 | |
michael@0 | 220 | /* ----------------------------------------------------------------------- |
michael@0 | 221 | ** FUNCTION: PR_GetCounterNameFromHandle() -- Retreive a |
michael@0 | 222 | ** counter's name, given its handle. |
michael@0 | 223 | ** |
michael@0 | 224 | ** DESCRIPTION: PR_GetCounterNameFromHandle() retreives a |
michael@0 | 225 | ** counter's name given its handle. |
michael@0 | 226 | ** |
michael@0 | 227 | ** INPUTS: |
michael@0 | 228 | ** qName: Where to store a pointer to qName. |
michael@0 | 229 | ** rName: Where to store a pointer to rName. |
michael@0 | 230 | ** description: Where to store a pointer to description. |
michael@0 | 231 | ** |
michael@0 | 232 | ** OUTPUTS: Pointers to the Counter Feature's copies of the names |
michael@0 | 233 | ** used when the counters were created. |
michael@0 | 234 | ** |
michael@0 | 235 | ** RETURNS: void |
michael@0 | 236 | ** |
michael@0 | 237 | ** RESTRICTIONS: |
michael@0 | 238 | ** |
michael@0 | 239 | */ |
michael@0 | 240 | #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) |
michael@0 | 241 | #define PR_GET_COUNTER_NAME_FROM_HANDLE(handle,qName,rName,description)\ |
michael@0 | 242 | PR_GetCounterNameFromHandle((handle),(qName),(rName),(description)) |
michael@0 | 243 | #else |
michael@0 | 244 | #define PR_GET_COUNTER_NAME_FROM_HANDLE(handle,qName,rName,description ) |
michael@0 | 245 | #endif |
michael@0 | 246 | |
michael@0 | 247 | NSPR_API(void) |
michael@0 | 248 | PR_GetCounterNameFromHandle( |
michael@0 | 249 | PRCounterHandle handle, |
michael@0 | 250 | const char **qName, |
michael@0 | 251 | const char **rName, |
michael@0 | 252 | const char **description |
michael@0 | 253 | ); |
michael@0 | 254 | |
michael@0 | 255 | |
michael@0 | 256 | /* ----------------------------------------------------------------------- |
michael@0 | 257 | ** FUNCTION: PR_IncrementCounter() -- Add one to the referenced |
michael@0 | 258 | ** counter. |
michael@0 | 259 | ** |
michael@0 | 260 | ** DESCRIPTION: Add one to the referenced counter. |
michael@0 | 261 | ** |
michael@0 | 262 | ** INPUTS: |
michael@0 | 263 | ** handle: The PRCounterHandle of the counter to be incremented |
michael@0 | 264 | ** |
michael@0 | 265 | ** OUTPUTS: The counter is incrementd. |
michael@0 | 266 | ** |
michael@0 | 267 | ** RETURNS: void |
michael@0 | 268 | ** |
michael@0 | 269 | ** RESTRICTIONS: |
michael@0 | 270 | ** |
michael@0 | 271 | */ |
michael@0 | 272 | #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) |
michael@0 | 273 | #define PR_INCREMENT_COUNTER(handle) PR_IncrementCounter(handle) |
michael@0 | 274 | #else |
michael@0 | 275 | #define PR_INCREMENT_COUNTER(handle) |
michael@0 | 276 | #endif |
michael@0 | 277 | |
michael@0 | 278 | NSPR_API(void) |
michael@0 | 279 | PR_IncrementCounter( |
michael@0 | 280 | PRCounterHandle handle |
michael@0 | 281 | ); |
michael@0 | 282 | |
michael@0 | 283 | |
michael@0 | 284 | /* ----------------------------------------------------------------------- |
michael@0 | 285 | ** FUNCTION: PR_DecrementCounter() -- Subtract one from the |
michael@0 | 286 | ** referenced counter |
michael@0 | 287 | ** |
michael@0 | 288 | ** DESCRIPTION: Subtract one from the referenced counter. |
michael@0 | 289 | ** |
michael@0 | 290 | ** INPUTS: |
michael@0 | 291 | ** handle: The PRCounterHandle of the coutner to be |
michael@0 | 292 | ** decremented. |
michael@0 | 293 | ** |
michael@0 | 294 | ** OUTPUTS: the counter is decremented. |
michael@0 | 295 | ** |
michael@0 | 296 | ** RETURNS: void |
michael@0 | 297 | ** |
michael@0 | 298 | ** RESTRICTIONS: |
michael@0 | 299 | ** |
michael@0 | 300 | */ |
michael@0 | 301 | #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) |
michael@0 | 302 | #define PR_DECREMENT_COUNTER(handle) PR_DecrementCounter(handle) |
michael@0 | 303 | #else |
michael@0 | 304 | #define PR_DECREMENT_COUNTER(handle) |
michael@0 | 305 | #endif |
michael@0 | 306 | |
michael@0 | 307 | NSPR_API(void) |
michael@0 | 308 | PR_DecrementCounter( |
michael@0 | 309 | PRCounterHandle handle |
michael@0 | 310 | ); |
michael@0 | 311 | |
michael@0 | 312 | /* ----------------------------------------------------------------------- |
michael@0 | 313 | ** FUNCTION: PR_AddToCounter() -- Add a value to a counter. |
michael@0 | 314 | ** |
michael@0 | 315 | ** DESCRIPTION: Add value to the counter referenced by handle. |
michael@0 | 316 | ** |
michael@0 | 317 | ** INPUTS: |
michael@0 | 318 | ** handle: the PRCounterHandle of the counter to be added to. |
michael@0 | 319 | ** |
michael@0 | 320 | ** value: the value to be added to the counter. |
michael@0 | 321 | ** |
michael@0 | 322 | ** OUTPUTS: new value for counter. |
michael@0 | 323 | ** |
michael@0 | 324 | ** RETURNS: void |
michael@0 | 325 | ** |
michael@0 | 326 | ** RESTRICTIONS: |
michael@0 | 327 | ** |
michael@0 | 328 | */ |
michael@0 | 329 | #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) |
michael@0 | 330 | #define PR_ADD_TO_COUNTER(handle,value)\ |
michael@0 | 331 | PR_AddToCounter((handle),(value)) |
michael@0 | 332 | #else |
michael@0 | 333 | #define PR_ADD_TO_COUNTER(handle,value) |
michael@0 | 334 | #endif |
michael@0 | 335 | |
michael@0 | 336 | NSPR_API(void) |
michael@0 | 337 | PR_AddToCounter( |
michael@0 | 338 | PRCounterHandle handle, |
michael@0 | 339 | PRUint32 value |
michael@0 | 340 | ); |
michael@0 | 341 | |
michael@0 | 342 | |
michael@0 | 343 | /* ----------------------------------------------------------------------- |
michael@0 | 344 | ** FUNCTION: PR_SubtractFromCounter() -- A value is subtracted |
michael@0 | 345 | ** from a counter. |
michael@0 | 346 | ** |
michael@0 | 347 | ** DESCRIPTION: |
michael@0 | 348 | ** Subtract a value from a counter. |
michael@0 | 349 | ** |
michael@0 | 350 | ** INPUTS: |
michael@0 | 351 | ** handle: the PRCounterHandle of the counter to be subtracted |
michael@0 | 352 | ** from. |
michael@0 | 353 | ** |
michael@0 | 354 | ** value: the value to be subtracted from the counter. |
michael@0 | 355 | ** |
michael@0 | 356 | ** OUTPUTS: new value for counter |
michael@0 | 357 | ** |
michael@0 | 358 | ** RETURNS: void |
michael@0 | 359 | ** |
michael@0 | 360 | ** RESTRICTIONS: |
michael@0 | 361 | ** |
michael@0 | 362 | */ |
michael@0 | 363 | #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) |
michael@0 | 364 | #define PR_SUBTRACT_FROM_COUNTER(handle,value)\ |
michael@0 | 365 | PR_SubtractFromCounter((handle),(value)) |
michael@0 | 366 | #else |
michael@0 | 367 | #define PR_SUBTRACT_FROM_COUNTER(handle,value) |
michael@0 | 368 | #endif |
michael@0 | 369 | |
michael@0 | 370 | NSPR_API(void) |
michael@0 | 371 | PR_SubtractFromCounter( |
michael@0 | 372 | PRCounterHandle handle, |
michael@0 | 373 | PRUint32 value |
michael@0 | 374 | ); |
michael@0 | 375 | |
michael@0 | 376 | |
michael@0 | 377 | /* ----------------------------------------------------------------------- |
michael@0 | 378 | ** FUNCTION: PR_GetCounter() -- Retreive the value of a counter |
michael@0 | 379 | ** |
michael@0 | 380 | ** DESCRIPTION: |
michael@0 | 381 | ** Retreive the value of a counter. |
michael@0 | 382 | ** |
michael@0 | 383 | ** INPUTS: |
michael@0 | 384 | ** handle: the PR_CounterHandle of the counter to be retreived |
michael@0 | 385 | ** |
michael@0 | 386 | ** OUTPUTS: |
michael@0 | 387 | ** |
michael@0 | 388 | ** RETURNS: The value of the referenced counter |
michael@0 | 389 | ** |
michael@0 | 390 | ** RESTRICTIONS: |
michael@0 | 391 | ** |
michael@0 | 392 | */ |
michael@0 | 393 | #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) |
michael@0 | 394 | #define PR_GET_COUNTER(counter,handle)\ |
michael@0 | 395 | (counter) = PR_GetCounter((handle)) |
michael@0 | 396 | #else |
michael@0 | 397 | #define PR_GET_COUNTER(counter,handle) 0 |
michael@0 | 398 | #endif |
michael@0 | 399 | |
michael@0 | 400 | NSPR_API(PRUint32) |
michael@0 | 401 | PR_GetCounter( |
michael@0 | 402 | PRCounterHandle handle |
michael@0 | 403 | ); |
michael@0 | 404 | |
michael@0 | 405 | /* ----------------------------------------------------------------------- |
michael@0 | 406 | ** FUNCTION: PR_SetCounter() -- Replace the content of counter |
michael@0 | 407 | ** with value. |
michael@0 | 408 | ** |
michael@0 | 409 | ** DESCRIPTION: The contents of the referenced counter are |
michael@0 | 410 | ** replaced by value. |
michael@0 | 411 | ** |
michael@0 | 412 | ** INPUTS: |
michael@0 | 413 | ** handle: the PRCounterHandle of the counter whose contents |
michael@0 | 414 | ** are to be replaced. |
michael@0 | 415 | ** |
michael@0 | 416 | ** value: the new value of the counter. |
michael@0 | 417 | ** |
michael@0 | 418 | ** OUTPUTS: |
michael@0 | 419 | ** |
michael@0 | 420 | ** RETURNS: void |
michael@0 | 421 | ** |
michael@0 | 422 | ** RESTRICTIONS: |
michael@0 | 423 | ** |
michael@0 | 424 | */ |
michael@0 | 425 | #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) |
michael@0 | 426 | #define PR_SET_COUNTER(handle,value) PR_SetCounter((handle),(value)) |
michael@0 | 427 | #else |
michael@0 | 428 | #define PR_SET_COUNTER(handle,value) |
michael@0 | 429 | #endif |
michael@0 | 430 | |
michael@0 | 431 | NSPR_API(void) |
michael@0 | 432 | PR_SetCounter( |
michael@0 | 433 | PRCounterHandle handle, |
michael@0 | 434 | PRUint32 value |
michael@0 | 435 | ); |
michael@0 | 436 | |
michael@0 | 437 | |
michael@0 | 438 | /* ----------------------------------------------------------------------- |
michael@0 | 439 | ** FUNCTION: PR_FindNextCounterQname() -- Retreive the next QName counter |
michael@0 | 440 | ** handle iterator |
michael@0 | 441 | ** |
michael@0 | 442 | ** DESCRIPTION: |
michael@0 | 443 | ** PR_FindNextCounterQname() retreives the first or next Qname |
michael@0 | 444 | ** the counter data base, depending on the value of handle. When |
michael@0 | 445 | ** handle is NULL, the function attempts to retreive the first |
michael@0 | 446 | ** QName handle in the database. When handle is a handle previosly |
michael@0 | 447 | ** retreived QName handle, then the function attempts to retreive |
michael@0 | 448 | ** the next QName handle. |
michael@0 | 449 | ** |
michael@0 | 450 | ** INPUTS: |
michael@0 | 451 | ** handle: PRCounterHandle or NULL. |
michael@0 | 452 | ** |
michael@0 | 453 | ** OUTPUTS: returned |
michael@0 | 454 | ** |
michael@0 | 455 | ** RETURNS: PRCounterHandle or NULL when no more QName counter |
michael@0 | 456 | ** handles are present. |
michael@0 | 457 | ** |
michael@0 | 458 | ** RESTRICTIONS: |
michael@0 | 459 | ** A concurrent PR_CreateCounter() or PR_DestroyCounter() may |
michael@0 | 460 | ** cause unpredictable results. |
michael@0 | 461 | ** |
michael@0 | 462 | ** A PRCounterHandle returned from this function may only be used |
michael@0 | 463 | ** in another PR_FindNextCounterQname() function call; other |
michael@0 | 464 | ** operations may cause unpredictable results. |
michael@0 | 465 | ** |
michael@0 | 466 | */ |
michael@0 | 467 | #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) |
michael@0 | 468 | #define PR_FIND_NEXT_COUNTER_QNAME(next,handle)\ |
michael@0 | 469 | (next) = PR_FindNextCounterQname((handle)) |
michael@0 | 470 | #else |
michael@0 | 471 | #define PR_FIND_NEXT_COUNTER_QNAME(next,handle) NULL |
michael@0 | 472 | #endif |
michael@0 | 473 | |
michael@0 | 474 | NSPR_API(PRCounterHandle) |
michael@0 | 475 | PR_FindNextCounterQname( |
michael@0 | 476 | PRCounterHandle handle |
michael@0 | 477 | ); |
michael@0 | 478 | |
michael@0 | 479 | /* ----------------------------------------------------------------------- |
michael@0 | 480 | ** FUNCTION: PR_FindNextCounterRname() -- Retreive the next RName counter |
michael@0 | 481 | ** handle iterator |
michael@0 | 482 | ** |
michael@0 | 483 | ** DESCRIPTION: |
michael@0 | 484 | ** PR_FindNextCounterRname() retreives the first or next RNname |
michael@0 | 485 | ** handle from the counter data base, depending on the |
michael@0 | 486 | ** value of handle. When handle is NULL, the function attempts to |
michael@0 | 487 | ** retreive the first RName handle in the database. When handle is |
michael@0 | 488 | ** a handle previosly retreived RName handle, then the function |
michael@0 | 489 | ** attempts to retreive the next RName handle. |
michael@0 | 490 | ** |
michael@0 | 491 | ** INPUTS: |
michael@0 | 492 | ** handle: PRCounterHandle or NULL. |
michael@0 | 493 | ** qhandle: PRCounterHandle of a previously aquired via |
michael@0 | 494 | ** PR_FIND_NEXT_QNAME_HANDLE() |
michael@0 | 495 | ** |
michael@0 | 496 | ** OUTPUTS: returned |
michael@0 | 497 | ** |
michael@0 | 498 | ** RETURNS: PRCounterHandle or NULL when no more RName counter |
michael@0 | 499 | ** handles are present. |
michael@0 | 500 | ** |
michael@0 | 501 | ** RESTRICTIONS: |
michael@0 | 502 | ** A concurrent PR_CreateCounter() or PR_DestroyCounter() may |
michael@0 | 503 | ** cause unpredictable results. |
michael@0 | 504 | ** |
michael@0 | 505 | ** A PRCounterHandle returned from this function may only be used |
michael@0 | 506 | ** in another PR_FindNextCounterRname() function call; other |
michael@0 | 507 | ** operations may cause unpredictable results. |
michael@0 | 508 | ** |
michael@0 | 509 | */ |
michael@0 | 510 | #if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) |
michael@0 | 511 | #define PR_FIND_NEXT_COUNTER_RNAME(next,rhandle,qhandle)\ |
michael@0 | 512 | (next) = PR_FindNextCounterRname((rhandle),(qhandle)) |
michael@0 | 513 | #else |
michael@0 | 514 | #define PR_FIND_NEXT_COUNTER_RNAME(next,rhandle,qhandle) |
michael@0 | 515 | #endif |
michael@0 | 516 | |
michael@0 | 517 | NSPR_API(PRCounterHandle) |
michael@0 | 518 | PR_FindNextCounterRname( |
michael@0 | 519 | PRCounterHandle rhandle, |
michael@0 | 520 | PRCounterHandle qhandle |
michael@0 | 521 | ); |
michael@0 | 522 | |
michael@0 | 523 | PR_END_EXTERN_C |
michael@0 | 524 | |
michael@0 | 525 | #endif /* prcountr_h___ */ |