mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
32 lines
1.2 KiB
C++
32 lines
1.2 KiB
C++
//===--- 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 __arm64__ || __arm__
|
|
# define SWIFT_MEMORY_ORDER_CONSUME (std::memory_order_relaxed)
|
|
#else
|
|
# define SWIFT_MEMORY_ORDER_CONSUME (std::memory_order_consume)
|
|
#endif
|
|
|
|
#endif
|