| 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 /* This Source Code Form is subject to the terms of the Mozilla Public | 2 /* This Source Code Form is subject to the terms of the Mozilla Public |
| 3 * License, v. 2.0. If a copy of the MPL was not distributed with this | 3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 5 | 5 |
| 6 /* GLOBAL FUNCTIONS: | 6 /* GLOBAL FUNCTIONS: |
| 7 ** DESCRIPTION: | 7 ** DESCRIPTION: |
| 8 ** PR Atomic operations | 8 ** PR Atomic operations |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 ** IMPORTANT NOTE TO NSPR MAINTAINERS: | 74 ** IMPORTANT NOTE TO NSPR MAINTAINERS: |
| 75 ** Implement these macros with compiler intrinsics only on platforms | 75 ** Implement these macros with compiler intrinsics only on platforms |
| 76 ** where the PR_AtomicXXX functions are truly atomic (i.e., where the | 76 ** where the PR_AtomicXXX functions are truly atomic (i.e., where the |
| 77 ** configuration macro _PR_HAVE_ATOMIC_OPS is defined). Otherwise, | 77 ** configuration macro _PR_HAVE_ATOMIC_OPS is defined). Otherwise, |
| 78 ** the macros and functions won't be compatible and can't be used | 78 ** the macros and functions won't be compatible and can't be used |
| 79 ** interchangeably. | 79 ** interchangeably. |
| 80 */ | 80 */ |
| 81 #if defined(_WIN32) && !defined(_WIN32_WCE) && \ | 81 #if defined(_WIN32) && !defined(_WIN32_WCE) && \ |
| 82 (!defined(_MSC_VER) || (_MSC_VER >= 1310)) | 82 (!defined(_MSC_VER) || (_MSC_VER >= 1310)) |
| 83 | 83 |
| 84 long __cdecl _InterlockedIncrement(long volatile *Addend); | 84 #include <intrin.h> |
| 85 long __cdecl _InterlockedDecrement(long volatile *Addend); | |
| 86 long __cdecl _InterlockedExchange(long volatile *Target, long Value); | |
| 87 long __cdecl _InterlockedExchangeAdd(long volatile *Addend, long Value); | |
| 88 | 85 |
| 89 #ifdef _MSC_VER | 86 #ifdef _MSC_VER |
| 90 #pragma intrinsic(_InterlockedIncrement) | 87 #pragma intrinsic(_InterlockedIncrement) |
| 91 #pragma intrinsic(_InterlockedDecrement) | 88 #pragma intrinsic(_InterlockedDecrement) |
| 92 #pragma intrinsic(_InterlockedExchange) | 89 #pragma intrinsic(_InterlockedExchange) |
| 93 #pragma intrinsic(_InterlockedExchangeAdd) | 90 #pragma intrinsic(_InterlockedExchangeAdd) |
| 94 #endif | 91 #endif |
| 95 | 92 |
| 96 #define PR_ATOMIC_INCREMENT(val) _InterlockedIncrement((long volatile *)(val)) | 93 #define PR_ATOMIC_INCREMENT(val) _InterlockedIncrement((long volatile *)(val)) |
| 97 #define PR_ATOMIC_DECREMENT(val) _InterlockedDecrement((long volatile *)(val)) | 94 #define PR_ATOMIC_DECREMENT(val) _InterlockedDecrement((long volatile *)(val)) |
| 98 #define PR_ATOMIC_SET(val, newval) \ | 95 #define PR_ATOMIC_SET(val, newval) \ |
| 99 _InterlockedExchange((long volatile *)(val), (long)(newval)) | 96 _InterlockedExchange((long volatile *)(val), (long)(newval)) |
| 100 #define PR_ATOMIC_ADD(ptr, val) \ | 97 #define PR_ATOMIC_ADD(ptr, val) \ |
| 101 (_InterlockedExchangeAdd((long volatile *)(ptr), (long)(val)) + (val)) | 98 (_InterlockedExchangeAdd((long volatile *)(ptr), (long)(val)) + (val)) |
| 102 | 99 |
| 103 #elif ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && \ | 100 #elif ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && \ |
| 104 ((defined(__APPLE__) && \ | 101 ((defined(__APPLE__) && \ |
| 105 (defined(__ppc__) || defined(__i386__) || defined(__x86_64__))) || \ | 102 (defined(__ppc__) || defined(__i386__) || defined(__x86_64__))) || \ |
| 106 (defined(__linux__) && \ | 103 (defined(__linux__) && \ |
| 107 ((defined(__i386__) && \ | 104 ((defined(__i386__) && \ |
| 108 defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \ | 105 defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \ |
| 109 defined(__ia64__) || defined(__x86_64__) || \ | 106 defined(__ia64__) || defined(__x86_64__) || \ |
| 110 (defined(__powerpc__) && !defined(__powerpc64__)) || \ | 107 defined(__powerpc__) || \ |
| 111 (defined(__arm__) && \ | 108 (defined(__arm__) && \ |
| 112 defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \ | 109 defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \ |
| 113 defined(__aarch64__) || defined(__alpha)))) | 110 defined(__aarch64__) || defined(__alpha)))) |
| 114 | 111 |
| 115 /* | 112 /* |
| 116 * Because the GCC manual warns that some processors may support | 113 * Because the GCC manual warns that some processors may support |
| 117 * reduced functionality of __sync_lock_test_and_set, we test for the | 114 * reduced functionality of __sync_lock_test_and_set, we test for the |
| 118 * processors that we believe support a full atomic exchange operation. | 115 * processors that we believe support a full atomic exchange operation. |
| 119 */ | 116 */ |
| 120 | 117 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 ** PR_SUCCESS - if successfully deleted | 187 ** PR_SUCCESS - if successfully deleted |
| 191 ** PR_FAILURE - if the stack is not empty | 188 ** PR_FAILURE - if the stack is not empty |
| 192 ** PR_GetError will return | 189 ** PR_GetError will return |
| 193 ** PR_INVALID_STATE_ERROR - stack i
s not empty | 190 ** PR_INVALID_STATE_ERROR - stack i
s not empty |
| 194 */ | 191 */ |
| 195 NSPR_API(PRStatus) PR_DestroyStack(PRStack *stack); | 192 NSPR_API(PRStatus) PR_DestroyStack(PRStack *stack); |
| 196 | 193 |
| 197 PR_END_EXTERN_C | 194 PR_END_EXTERN_C |
| 198 | 195 |
| 199 #endif /* pratom_h___ */ | 196 #endif /* pratom_h___ */ |
| OLD | NEW |