mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Added swift_retainCount to EmbeddedRuntime.swift
Fixes test/embedded/concurrency-actors.swift
This commit is contained in:
@@ -204,6 +204,14 @@ FUNCTION(CopyPOD, swift_copyPOD, C_CC, AlwaysAvailable,
|
|||||||
EFFECT(NoEffect),
|
EFFECT(NoEffect),
|
||||||
UNKNOWN_MEMEFFECTS)
|
UNKNOWN_MEMEFFECTS)
|
||||||
|
|
||||||
|
// size_t swift_retainCount(void *ptr);
|
||||||
|
FUNCTION(NativeRetainCount, swift_retainCount, C_CC, AlwaysAvailable,
|
||||||
|
RETURNS(SizeTy),
|
||||||
|
ARGS(RefCountedPtrTy),
|
||||||
|
ATTRS(NoUnwind, WillReturn),
|
||||||
|
EFFECT(RefCounting),
|
||||||
|
UNKNOWN_MEMEFFECTS)
|
||||||
|
|
||||||
// void *swift_retain(void *ptr);
|
// void *swift_retain(void *ptr);
|
||||||
FUNCTION(NativeStrongRetain, swift_retain, C_CC, AlwaysAvailable,
|
FUNCTION(NativeStrongRetain, swift_retain, C_CC, AlwaysAvailable,
|
||||||
RETURNS(RefCountedPtrTy),
|
RETURNS(RefCountedPtrTy),
|
||||||
|
|||||||
@@ -309,7 +309,13 @@ public func swift_bridgeObjectRelease_n(object: Builtin.RawPointer, n: UInt32) {
|
|||||||
swift_release_n(object: untaggedObject, n: n)
|
swift_release_n(object: untaggedObject, n: n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@_cdecl("swift_retainCount")
|
||||||
|
public func swift_retainCount(object: Builtin.RawPointer) -> Int {
|
||||||
|
if !isValidPointerForNativeRetain(object: object) { return 0 }
|
||||||
|
let o = UnsafeMutablePointer<HeapObject>(object)
|
||||||
|
let refcount = refcountPointer(for: o)
|
||||||
|
return loadAcquire(refcount) & HeapObject.refcountMask
|
||||||
|
}
|
||||||
|
|
||||||
/// Refcount helpers
|
/// Refcount helpers
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user