1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 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/
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.
13 * The Original Code is the Netscape Portable Runtime (NSPR).
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
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
37 ** PR Atomic operations
49 ** FUNCTION: PR_AtomicIncrement
51 ** Atomically increment a 32 bit value.
53 ** val: a pointer to the value to increment
55 ** the returned value is the result of the increment
57 NSPR_API(PRInt32
) PR_AtomicIncrement(PRInt32
*val
);
60 ** FUNCTION: PR_AtomicDecrement
62 ** Atomically decrement a 32 bit value.
64 ** val: a pointer to the value to decrement
66 ** the returned value is the result of the decrement
68 NSPR_API(PRInt32
) PR_AtomicDecrement(PRInt32
*val
);
71 ** FUNCTION: PR_AtomicSet
73 ** Atomically set a 32 bit value.
75 ** val: A pointer to a 32 bit value to be set
76 ** newval: The newvalue to assign to val
78 ** Returns the prior value
80 NSPR_API(PRInt32
) PR_AtomicSet(PRInt32
*val
, PRInt32 newval
);
83 ** FUNCTION: PR_AtomicAdd
85 ** Atomically add a 32 bit value.
87 ** ptr: a pointer to the value to increment
88 ** val: value to be added
90 ** the returned value is the result of the addition
92 NSPR_API(PRInt32
) PR_AtomicAdd(PRInt32
*ptr
, PRInt32 val
);
95 ** LIFO linked-list (stack)
97 typedef struct PRStackElemStr PRStackElem
;
99 struct PRStackElemStr
{
100 PRStackElem
*prstk_elem_next
; /* next pointer MUST be at offset 0;
101 assembly language code relies on this */
104 typedef struct PRStackStr PRStack
;
107 ** FUNCTION: PR_CreateStack
109 ** Create a stack, a LIFO linked list
111 ** stack_name: a pointer to string containing the name of the stack
113 ** A pointer to the created stack, if successful, else NULL.
115 NSPR_API(PRStack
*) PR_CreateStack(const char *stack_name
);
118 ** FUNCTION: PR_StackPush
120 ** Push an element on the top of the stack
122 ** stack: pointer to the stack
123 ** stack_elem: pointer to the stack element
127 NSPR_API(void) PR_StackPush(PRStack
*stack
, PRStackElem
*stack_elem
);
130 ** FUNCTION: PR_StackPop
132 ** Remove the element on the top of the stack
134 ** stack: pointer to the stack
136 ** A pointer to the stack element removed from the top of the stack,
140 NSPR_API(PRStackElem
*) PR_StackPop(PRStack
*stack
);
143 ** FUNCTION: PR_DestroyStack
147 ** stack: pointer to the stack
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
154 NSPR_API(PRStatus
) PR_DestroyStack(PRStack
*stack
);
158 #endif /* pratom_h___ */