Skip to content

Commit

Permalink
stdlib & Runtime: Replace atomicStore/Load stubs with builtins.
Browse files Browse the repository at this point in the history
Swift SVN r32953
  • Loading branch information
jckarter committed Oct 28, 2015
1 parent 0bf0528 commit 527221f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 31 deletions.
24 changes: 18 additions & 6 deletions stdlib/public/core/Runtime.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,14 @@ func _stdlib_atomicCompareExchangeStrongInt${bits}(
desired: UInt${bits}(bitPattern: desired))
}

@asmname("swift_stdlib_atomicStoreUInt${bits}")
@transparent
public // @testable
func _swift_stdlib_atomicStoreUInt${bits}(
object target: UnsafeMutablePointer<UInt${bits}>,
desired: UInt${bits})
desired: UInt${bits}) {

Builtin.atomicstore_seqcst_Int${bits}(target._rawValue, desired._value)
}

func _swift_stdlib_atomicStoreInt${bits}(
object target: UnsafeMutablePointer<Int${bits}>,
Expand All @@ -136,9 +140,13 @@ func _swift_stdlib_atomicStoreInt${bits}(
}

@warn_unused_result
@asmname("swift_stdlib_atomicLoadUInt${bits}")
public // @testable
func _swift_stdlib_atomicLoadUInt${bits}(
object target: UnsafeMutablePointer<UInt${bits}>) -> UInt${bits}
object target: UnsafeMutablePointer<UInt${bits}>) -> UInt${bits} {

let value = Builtin.atomicload_seqcst_Int${bits}(target._rawValue)
return UInt${bits}(value)
}

@warn_unused_result
func _swift_stdlib_atomicLoadInt${bits}(
Expand Down Expand Up @@ -217,10 +225,14 @@ public func _swift_stdlib_atomicLoadInt(
}

@warn_unused_result
@asmname("swift_stdlib_atomicLoadPtr")
@transparent
public // @testable
func _swift_stdlib_atomicLoadPtrImpl(
object target: UnsafeMutablePointer<COpaquePointer>
) -> COpaquePointer
) -> COpaquePointer {
let value = Builtin.atomicload_seqcst_RawPointer(target._rawValue)
return COpaquePointer(value)
}

@transparent
@warn_unused_result
Expand Down
25 changes: 0 additions & 25 deletions stdlib/public/runtime/Stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,31 +265,6 @@ typedef enum {
memory_order_seq_cst = 5
} memory_order;

extern "C" void swift_stdlib_atomicStoreUInt32(
_Atomic(uint32_t) * object, uint32_t desired) {
return __c11_atomic_store(object, desired, memory_order_seq_cst);
}

extern "C" void swift_stdlib_atomicStoreUInt64(
_Atomic(uint64_t) * object, uint64_t desired) {
return __c11_atomic_store(object, desired, memory_order_seq_cst);
}

extern "C" uint32_t swift_stdlib_atomicLoadUInt32(
_Atomic(uint32_t) * object) {
return __c11_atomic_load(object, memory_order_seq_cst);
}

extern "C" uint64_t swift_stdlib_atomicLoadUInt64(
_Atomic(uint64_t) * object) {
return __c11_atomic_load(object, memory_order_seq_cst);
}

extern "C" uintptr_t swift_stdlib_atomicLoadPtr(
_Atomic(uintptr_t) * object) {
return __c11_atomic_load(object, memory_order_seq_cst);
}

// fetch_add

extern "C" uint32_t swift_stdlib_atomicFetchAddUInt32(
Expand Down

0 comments on commit 527221f

Please sign in to comment.