File tree Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,20 @@ extension OpaquePointer : CustomDebugStringConvertible {
162
162
}
163
163
}
164
164
165
+ extension Int {
166
+ @warn_unused_result
167
+ public init ( bitPattern pointer: OpaquePointer ? ) {
168
+ self . init ( bitPattern: UnsafePointer < Void > ( pointer) )
169
+ }
170
+ }
171
+
172
+ extension UInt {
173
+ @warn_unused_result
174
+ public init ( bitPattern pointer: OpaquePointer ? ) {
175
+ self . init ( bitPattern: UnsafePointer < Void > ( pointer) )
176
+ }
177
+ }
178
+
165
179
@warn_unused_result
166
180
public func == ( lhs: OpaquePointer , rhs: OpaquePointer ) -> Bool {
167
181
return Bool ( Builtin . cmp_eq_RawPointer ( lhs. _rawValue, rhs. _rawValue) )
Original file line number Diff line number Diff line change @@ -28,12 +28,11 @@ func _stdlib_atomicCompareExchangeStrongPtrImpl(
28
28
expected: UnsafeMutablePointer < OpaquePointer ? > ,
29
29
desired: OpaquePointer ? ) -> Bool {
30
30
31
- // Bit-cast directly from 'OpaquePointer?' to 'Builtin.Word' because
32
- // Builtin.RawPointer can't be nil.
31
+ // We use Builtin.Word here because Builtin.RawPointer can't be nil.
33
32
let ( oldValue, won) = Builtin . cmpxchg_seqcst_seqcst_Word (
34
33
target. _rawValue,
35
- unsafeBitCast ( expected . pointee , to : Builtin . Word . self ) ,
36
- unsafeBitCast ( desired , to : Builtin . Word . self ) )
34
+ UInt ( bitPattern : expected . pointee ) . _builtinWordValue ,
35
+ UInt ( bitPattern : desired ) . _builtinWordValue )
37
36
expected. pointee = OpaquePointer ( bitPattern: Int ( oldValue) )
38
37
return Bool ( won)
39
38
}
Original file line number Diff line number Diff line change @@ -151,7 +151,6 @@ ${SelfName}TestSuite.test("Hashable") {
151
151
}
152
152
}
153
153
154
- % if SelfName != 'OpaquePointer':
155
154
${SelfName}TestSuite.test("toInteger") {
156
155
do {
157
156
let word: Int = 0x12345678
@@ -172,7 +171,6 @@ ${SelfName}TestSuite.test("toInteger") {
172
171
expectEqual(UInt(0), UInt(bitPattern: ptr))
173
172
}
174
173
}
175
- % end
176
174
177
175
% end
178
176
You can’t perform that action at this time.
0 commit comments