File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -795,6 +795,15 @@ extension Unsafe${Mutable}BufferPointer:
795
795
% end
796
796
}
797
797
798
+ extension Unsafe${ Mutable} BufferPointer where Element: ~ Copyable {
799
+ @safe
800
+ @_alwaysEmitIntoClient
801
+ public func _isWellAligned( ) -> Bool {
802
+ guard let p = baseAddress else { return true }
803
+ return p. _isWellAligned ( )
804
+ }
805
+ }
806
+
798
807
extension Unsafe${ Mutable} BufferPointer {
799
808
% if not Mutable:
800
809
/// Creates a buffer over the same memory as the given buffer slice.
Original file line number Diff line number Diff line change @@ -469,6 +469,13 @@ extension UnsafePointer where Pointee: ~Copyable {
469
469
}
470
470
}
471
471
472
+ extension UnsafePointer where Pointee: ~ Copyable {
473
+ @safe
474
+ @_alwaysEmitIntoClient
475
+ public func _isWellAligned( ) -> Bool {
476
+ ( Int ( bitPattern: self ) & ( MemoryLayout < Pointee > . alignment &- 1 ) ) == 0
477
+ }
478
+ }
472
479
473
480
/// A pointer for accessing and manipulating data of a
474
481
/// specific type.
@@ -1382,3 +1389,11 @@ extension UnsafeMutablePointer where Pointee: ~Copyable {
1382
1389
) . _unsafelyUnwrappedUnchecked
1383
1390
}
1384
1391
}
1392
+
1393
+ extension UnsafeMutablePointer where Pointee: ~ Copyable {
1394
+ @safe
1395
+ @_alwaysEmitIntoClient
1396
+ public func _isWellAligned( ) -> Bool {
1397
+ ( Int ( bitPattern: self ) & ( MemoryLayout < Pointee > . alignment &- 1 ) ) == 0
1398
+ }
1399
+ }
You can’t perform that action at this time.
0 commit comments