From d8a1fa899e54d084c91de2875355f12dc50aadc7 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Tue, 28 May 2024 12:26:52 -0700 Subject: [PATCH] wip --- Sources/Perception/Internal/ThreadLocal.swift | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Sources/Perception/Internal/ThreadLocal.swift b/Sources/Perception/Internal/ThreadLocal.swift index b6ac346..059184b 100644 --- a/Sources/Perception/Internal/ThreadLocal.swift +++ b/Sources/Perception/Internal/ThreadLocal.swift @@ -11,19 +11,14 @@ import Foundation -@_silgen_name("_swift_observation_tls_get") -func _tlsGet() -> UnsafeMutableRawPointer? - -@_silgen_name("_swift_observation_tls_set") -func _tlsSet(_ value: UnsafeMutableRawPointer?) - struct _ThreadLocal { - static var value: UnsafeMutableRawPointer? { - get { - _tlsGet() - } - set { - _tlsSet(newValue) + #if os(WASI) + static var value: UnsafeMutableRawPointer? + #else + static var value: UnsafeMutableRawPointer? { + get { Thread.current.threadDictionary[Key()] as! UnsafeMutableRawPointer? } + set { Thread.current.threadDictionary[Key()] = newValue } } - } + private struct Key: Hashable {} + #endif }