| //===--- Atomic.h - Utilities for atomic operations. ------------*- C++ -*-===// |
| // |
| // This source file is part of the Swift.org open source project |
| // |
| // Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors |
| // Licensed under Apache License v2.0 with Runtime Library Exception |
| // |
| // See https://swift.org/LICENSE.txt for license information |
| // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| // |
| //===----------------------------------------------------------------------===// |
| // |
| // Utilities for atomic operations, to use with std::atomic. |
| // |
| //===----------------------------------------------------------------------===// |
| |
| #ifndef SWIFT_RUNTIME_ATOMIC_H |
| #define SWIFT_RUNTIME_ATOMIC_H |
| |
| // FIXME: Workaround for rdar://problem/18889711. 'Consume' does not require |
| // a barrier on ARM64, but LLVM doesn't know that. Although 'relaxed' |
| // is formally UB by C++11 language rules, we should be OK because neither |
| // the processor model nor the optimizer can realistically reorder our uses |
| // of 'consume'. |
| #if defined(__arm__) || defined(_M_ARM) || defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64) |
| # define SWIFT_MEMORY_ORDER_CONSUME (std::memory_order_relaxed) |
| #else |
| # define SWIFT_MEMORY_ORDER_CONSUME (std::memory_order_consume) |
| #endif |
| |
| #endif |