OLD | NEW |
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* ***** BEGIN LICENSE BLOCK ***** | 2 /* ***** BEGIN LICENSE BLOCK ***** |
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
4 * | 4 * |
5 * The contents of this file are subject to the Mozilla Public License Version | 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 | 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 | 7 * the License. You may obtain a copy of the License at |
8 * http://www.mozilla.org/MPL/ | 8 * http://www.mozilla.org/MPL/ |
9 * | 9 * |
10 * Software distributed under the License is distributed on an "AS IS" basis, | 10 * Software distributed under the License is distributed on an "AS IS" basis, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 long __cdecl _InterlockedDecrement(long volatile *Addend); | 119 long __cdecl _InterlockedDecrement(long volatile *Addend); |
120 #pragma intrinsic(_InterlockedDecrement) | 120 #pragma intrinsic(_InterlockedDecrement) |
121 | 121 |
122 long __cdecl _InterlockedExchange(long volatile *Target, long Value); | 122 long __cdecl _InterlockedExchange(long volatile *Target, long Value); |
123 #pragma intrinsic(_InterlockedExchange) | 123 #pragma intrinsic(_InterlockedExchange) |
124 | 124 |
125 long __cdecl _InterlockedExchangeAdd(long volatile *Addend, long Value); | 125 long __cdecl _InterlockedExchangeAdd(long volatile *Addend, long Value); |
126 #pragma intrinsic(_InterlockedExchangeAdd) | 126 #pragma intrinsic(_InterlockedExchangeAdd) |
127 | 127 |
128 #define PR_ATOMIC_INCREMENT(val) _InterlockedIncrement(val) | 128 #define PR_ATOMIC_INCREMENT(val) _InterlockedIncrement((long volatile *)(val)) |
129 #define PR_ATOMIC_DECREMENT(val) _InterlockedDecrement(val) | 129 #define PR_ATOMIC_DECREMENT(val) _InterlockedDecrement((long volatile *)(val)) |
130 #define PR_ATOMIC_SET(val, newval) _InterlockedExchange(val, newval) | 130 #define PR_ATOMIC_SET(val, newval) \ |
131 #define PR_ATOMIC_ADD(ptr, val) (_InterlockedExchangeAdd(ptr, val) + (val)) | 131 _InterlockedExchange((long volatile *)(val), (long)(newval)) |
| 132 #define PR_ATOMIC_ADD(ptr, val) \ |
| 133 (_InterlockedExchangeAdd((long volatile *)(ptr), (long)(val)) + (val)) |
132 | 134 |
133 #elif ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && \ | 135 #elif ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && \ |
134 ((defined(DARWIN) && \ | 136 ((defined(DARWIN) && \ |
135 (defined(__ppc__) || defined(__i386__))) || \ | 137 (defined(__ppc__) || defined(__i386__) || defined(__x86_64__))) || \ |
136 (defined(LINUX) && \ | 138 (defined(LINUX) && \ |
137 (defined(__i386__) || defined(__ia64__) || defined(__x86_64__) || \ | 139 ((defined(__i386__) && \ |
| 140 defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \ |
| 141 defined(__ia64__) || defined(__x86_64__) || \ |
138 (defined(__powerpc__) && !defined(__powerpc64__)) || \ | 142 (defined(__powerpc__) && !defined(__powerpc64__)) || \ |
139 defined(__alpha)))) | 143 defined(__alpha)))) |
140 | 144 |
141 /* | 145 /* |
142 * Because the GCC manual warns that some processors may support | 146 * Because the GCC manual warns that some processors may support |
143 * reduced functionality of __sync_lock_test_and_set, we test for the | 147 * reduced functionality of __sync_lock_test_and_set, we test for the |
144 * processors that we believe support a full atomic exchange operation. | 148 * processors that we believe support a full atomic exchange operation. |
145 */ | 149 */ |
146 | 150 |
147 #define PR_ATOMIC_INCREMENT(val) __sync_add_and_fetch(val, 1) | 151 #define PR_ATOMIC_INCREMENT(val) __sync_add_and_fetch(val, 1) |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 ** PR_SUCCESS - if successfully deleted | 220 ** PR_SUCCESS - if successfully deleted |
217 ** PR_FAILURE - if the stack is not empty | 221 ** PR_FAILURE - if the stack is not empty |
218 ** PR_GetError will return | 222 ** PR_GetError will return |
219 ** PR_INVALID_STATE_ERROR - stack i
s not empty | 223 ** PR_INVALID_STATE_ERROR - stack i
s not empty |
220 */ | 224 */ |
221 NSPR_API(PRStatus) PR_DestroyStack(PRStack *stack); | 225 NSPR_API(PRStatus) PR_DestroyStack(PRStack *stack); |
222 | 226 |
223 PR_END_EXTERN_C | 227 PR_END_EXTERN_C |
224 | 228 |
225 #endif /* pratom_h___ */ | 229 #endif /* pratom_h___ */ |
OLD | NEW |