12
12
13
13
import SynchronizationShims
14
14
15
- @_alwaysEmitIntoClient
16
- @_extern ( c, " gettid " )
17
- func _gettid( ) -> UInt32
18
-
19
15
extension Atomic where Value == UInt32 {
20
16
borrowing func wait( ) {
21
17
_swift_stdlib_wait ( . init( rawAddress) )
@@ -33,8 +29,8 @@ extension Atomic where Value == UInt32 {
33
29
internal struct _MutexHandle : ~ Copyable {
34
30
// There are only 3 different values that storage can hold at a single time.
35
31
// 0: unlocked
36
- // _gettid : locked, current thread's id (uncontended)
37
- // (_gettid | SWIFT_FUTEX_WAITERS): locked, current thread's id (contended)
32
+ // TID : locked, current thread's id (uncontended)
33
+ // (TID | SWIFT_FUTEX_WAITERS): locked, current thread's id (contended)
38
34
@usableFromInline
39
35
let storage : Atomic < UInt32 >
40
36
@@ -49,7 +45,7 @@ internal struct _MutexHandle: ~Copyable {
49
45
@usableFromInline
50
46
borrowing func lock( ) {
51
47
// TODO: Is it worth caching this value in TLS?
52
- let selfId = _gettid ( )
48
+ let selfId = _swift_stdlib_gettid ( )
53
49
54
50
// Note: We could probably merge this cas into a do/while style loop, but we
55
51
// really want to perform the strong variant before attempting to do weak
@@ -97,7 +93,7 @@ internal struct _MutexHandle: ~Copyable {
97
93
borrowing func tryLock( ) -> Bool {
98
94
storage. compareExchange (
99
95
expected: 0 ,
100
- desired: _gettid ( ) ,
96
+ desired: _swift_stdlib_gettid ( ) ,
101
97
successOrdering: . acquiring,
102
98
failureOrdering: . relaxed
103
99
) . exchanged
@@ -107,7 +103,7 @@ internal struct _MutexHandle: ~Copyable {
107
103
@usableFromInline
108
104
borrowing func unlock( ) {
109
105
// TODO: Is it worth caching this value in TLS?
110
- let selfId = _gettid ( )
106
+ let selfId = _swift_stdlib_gettid ( )
111
107
112
108
// Attempt to release the lock. We can only atomically release the lock in
113
109
// user-space when there are no other waiters. If there are waiters, the
0 commit comments