Added swift_retainCount to EmbeddedRuntime.swift

Fixes test/embedded/concurrency-actors.swift
This commit is contained in:
Mykola Pokhylets
2024-08-19 23:41:33 +02:00
parent 50b1313175
commit 0412597731
2 changed files with 15 additions and 1 deletions

View File

@@ -309,7 +309,13 @@ public func swift_bridgeObjectRelease_n(object: Builtin.RawPointer, n: UInt32) {
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