@@ -303,6 +303,8 @@ public struct UnsafePointer<Pointee>: _Pointer {
303
303
/// - Returns: The return value, if any, of the `body` closure parameter.
304
304
@inlinable
305
305
@_alwaysEmitIntoClient
306
+ // This custom silgen name is chosen to not interfere with the old ABI
307
+ @_silgen_name ( " _swift_se0333_UnsafePointer_withMemoryRebound " )
306
308
public func withMemoryRebound< T, Result> (
307
309
to type: T . Type , capacity count: Int ,
308
310
_ body: ( _ pointer: UnsafePointer < T > ) throws -> Result
@@ -318,6 +320,21 @@ public struct UnsafePointer<Pointee>: _Pointer {
318
320
return try body ( . init( _rawValue) )
319
321
}
320
322
323
+ // This unavailable implementation uses the expected mangled name
324
+ // of `withMemoryRebound`, and provides an entry point for any
325
+ // binary compiled against the stlib binary for Swift 5.6 and older.
326
+ @available ( * , unavailable)
327
+ @_silgen_name ( " $sSP17withMemoryRebound2to8capacity_qd_0_qd__m_Siqd_0_SPyqd__GKXEtKr0_lF " )
328
+ public func _legacy_se0333_withMemoryRebound< T, Result> ( to type: T . Type , capacity count: Int ,
329
+ _ body: ( UnsafePointer < T > ) throws -> Result
330
+ ) rethrows -> Result {
331
+ Builtin . bindMemory ( _rawValue, count. _builtinWordValue, T . self)
332
+ defer {
333
+ Builtin . bindMemory ( _rawValue, count. _builtinWordValue, Pointee . self)
334
+ }
335
+ return try body ( . init( _rawValue) )
336
+ }
337
+
321
338
/// Accesses the pointee at the specified offset from this pointer.
322
339
///
323
340
///
@@ -970,6 +987,8 @@ public struct UnsafeMutablePointer<Pointee>: _Pointer {
970
987
/// - Returns: The return value, if any, of the `body` closure parameter.
971
988
@inlinable
972
989
@_alwaysEmitIntoClient
990
+ // This custom silgen name is chosen to not interfere with the old ABI
991
+ @_silgen_name ( " $_swift_se0333_UnsafeMutablePointer_withMemoryRebound " )
973
992
public func withMemoryRebound< T, Result> (
974
993
to type: T . Type , capacity count: Int ,
975
994
_ body: ( _ pointer: UnsafeMutablePointer < T > ) throws -> Result
@@ -985,6 +1004,21 @@ public struct UnsafeMutablePointer<Pointee>: _Pointer {
985
1004
return try body ( . init( _rawValue) )
986
1005
}
987
1006
1007
+ // This unavailable implementation uses the expected mangled name
1008
+ // of `withMemoryRebound`, and provides an entry point for any
1009
+ // binary compiled against the stlib binary for Swift 5.6 and older.
1010
+ @available ( * , unavailable)
1011
+ @_silgen_name ( " $sSp17withMemoryRebound2to8capacity_qd_0_qd__m_Siqd_0_Spyqd__GKXEtKr0_lF " )
1012
+ public func _legacy_se0333_withMemoryRebound< T, Result> ( to type: T . Type , capacity count: Int ,
1013
+ _ body: ( UnsafeMutablePointer < T > ) throws -> Result
1014
+ ) rethrows -> Result {
1015
+ Builtin . bindMemory ( _rawValue, count. _builtinWordValue, T . self)
1016
+ defer {
1017
+ Builtin . bindMemory ( _rawValue, count. _builtinWordValue, Pointee . self)
1018
+ }
1019
+ return try body ( . init( _rawValue) )
1020
+ }
1021
+
988
1022
/// Accesses the pointee at the specified offset from this pointer.
989
1023
///
990
1024
/// For a pointer `p`, the memory at `p + i` must be initialized when reading
0 commit comments