VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/include/pratom.h@ 4634

Last change on this file since 4634 was 1, checked in by vboxsync, 55 years ago

import

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette