Annotation of sbbs/include/mozilla/nspr/pratom.h, revision 1.1.1.1

1.1       root        1: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
                      2: /* 
                      3:  * The contents of this file are subject to the Mozilla Public
                      4:  * License Version 1.1 (the "License"); you may not use this file
                      5:  * except in compliance with the License. You may obtain a copy of
                      6:  * the License at http://www.mozilla.org/MPL/
                      7:  * 
                      8:  * Software distributed under the License is distributed on an "AS
                      9:  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
                     10:  * implied. See the License for the specific language governing
                     11:  * rights and limitations under the License.
                     12:  * 
                     13:  * The Original Code is the Netscape Portable Runtime (NSPR).
                     14:  * 
                     15:  * The Initial Developer of the Original Code is Netscape
                     16:  * Communications Corporation.  Portions created by Netscape are 
                     17:  * Copyright (C) 1998-2000 Netscape Communications Corporation.  All
                     18:  * Rights Reserved.
                     19:  * 
                     20:  * Contributor(s):
                     21:  * 
                     22:  * Alternatively, the contents of this file may be used under the
                     23:  * terms of the GNU General Public License Version 2 or later (the
                     24:  * "GPL"), in which case the provisions of the GPL are applicable 
                     25:  * instead of those above.  If you wish to allow use of your 
                     26:  * version of this file only under the terms of the GPL and not to
                     27:  * allow others to use your version of this file under the MPL,
                     28:  * indicate your decision by deleting the provisions above and
                     29:  * replace them with the notice and other provisions required by
                     30:  * the GPL.  If you do not delete the provisions above, a recipient
                     31:  * may use your version of this file under either the MPL or the
                     32:  * GPL.
                     33:  */
                     34: 
                     35: /* GLOBAL FUNCTIONS:
                     36: ** DESCRIPTION:
                     37: **     PR Atomic operations
                     38: */
                     39: 
                     40: #ifndef pratom_h___
                     41: #define pratom_h___
                     42: 
                     43: #include "prtypes.h"
                     44: #include "prlock.h"
                     45: 
                     46: PR_BEGIN_EXTERN_C
                     47: 
                     48: /*
                     49: ** FUNCTION: PR_AtomicIncrement
                     50: ** DESCRIPTION:
                     51: **    Atomically increment a 32 bit value.
                     52: ** INPUTS:
                     53: **    val:  a pointer to the value to increment
                     54: ** RETURN:
                     55: **    the returned value is the result of the increment
                     56: */
                     57: NSPR_API(PRInt32)  PR_AtomicIncrement(PRInt32 *val);
                     58: 
                     59: /*
                     60: ** FUNCTION: PR_AtomicDecrement
                     61: ** DESCRIPTION:
                     62: **    Atomically decrement a 32 bit value.
                     63: ** INPUTS:
                     64: **    val:  a pointer to the value to decrement
                     65: ** RETURN:
                     66: **    the returned value is the result of the decrement
                     67: */
                     68: NSPR_API(PRInt32)  PR_AtomicDecrement(PRInt32 *val);
                     69: 
                     70: /*
                     71: ** FUNCTION: PR_AtomicSet
                     72: ** DESCRIPTION:
                     73: **    Atomically set a 32 bit value.
                     74: ** INPUTS:
                     75: **    val: A pointer to a 32 bit value to be set
                     76: **    newval: The newvalue to assign to val
                     77: ** RETURN:
                     78: **    Returns the prior value
                     79: */
                     80: NSPR_API(PRInt32) PR_AtomicSet(PRInt32 *val, PRInt32 newval);
                     81: 
                     82: /*
                     83: ** FUNCTION: PR_AtomicAdd
                     84: ** DESCRIPTION:
                     85: **    Atomically add a 32 bit value.
                     86: ** INPUTS:
                     87: **    ptr:  a pointer to the value to increment
                     88: **   val:  value to be added
                     89: ** RETURN:
                     90: **    the returned value is the result of the addition
                     91: */
                     92: NSPR_API(PRInt32)  PR_AtomicAdd(PRInt32 *ptr, PRInt32 val);
                     93: 
                     94: /*
                     95: ** LIFO linked-list (stack)
                     96: */
                     97: typedef struct PRStackElemStr PRStackElem;
                     98: 
                     99: struct PRStackElemStr {
                    100:     PRStackElem    *prstk_elem_next;   /* next pointer MUST be at offset 0;
                    101:                                      assembly language code relies on this */
                    102: };
                    103: 
                    104: typedef struct PRStackStr PRStack;
                    105: 
                    106: /*
                    107: ** FUNCTION: PR_CreateStack
                    108: ** DESCRIPTION:
                    109: **    Create a stack, a LIFO linked list
                    110: ** INPUTS:
                    111: **    stack_name:  a pointer to string containing the name of the stack
                    112: ** RETURN:
                    113: **    A pointer to the created stack, if successful, else NULL.
                    114: */
                    115: NSPR_API(PRStack *)    PR_CreateStack(const char *stack_name);
                    116: 
                    117: /*
                    118: ** FUNCTION: PR_StackPush
                    119: ** DESCRIPTION:
                    120: **    Push an element on the top of the stack
                    121: ** INPUTS:
                    122: **    stack:       pointer to the stack
                    123: **    stack_elem:  pointer to the stack element
                    124: ** RETURN:
                    125: **    None
                    126: */
                    127: NSPR_API(void)         PR_StackPush(PRStack *stack, PRStackElem *stack_elem);
                    128: 
                    129: /*
                    130: ** FUNCTION: PR_StackPop
                    131: ** DESCRIPTION:
                    132: **    Remove the element on the top of the stack
                    133: ** INPUTS:
                    134: **    stack:       pointer to the stack
                    135: ** RETURN:
                    136: **    A pointer to the stack element removed from the top of the stack,
                    137: **   if non-empty,
                    138: **    else NULL
                    139: */
                    140: NSPR_API(PRStackElem *)    PR_StackPop(PRStack *stack);
                    141: 
                    142: /*
                    143: ** FUNCTION: PR_DestroyStack
                    144: ** DESCRIPTION:
                    145: **    Destroy the stack
                    146: ** INPUTS:
                    147: **    stack:       pointer to the stack
                    148: ** RETURN:
                    149: **    PR_SUCCESS - if successfully deleted
                    150: **   PR_FAILURE - if the stack is not empty
                    151: **                 PR_GetError will return
                    152: **                     PR_INVALID_STATE_ERROR - stack is not empty
                    153: */
                    154: NSPR_API(PRStatus)     PR_DestroyStack(PRStack *stack);
                    155: 
                    156: PR_END_EXTERN_C
                    157: 
                    158: #endif /* pratom_h___ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.