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:
795795% end
796796}
797797
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+
798807extension Unsafe${ Mutable} BufferPointer {
799808% if not Mutable:
800809 /// 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 {
469469 }
470470}
471471
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+ }
472479
473480/// A pointer for accessing and manipulating data of a
474481/// specific type.
@@ -1382,3 +1389,11 @@ extension UnsafeMutablePointer where Pointee: ~Copyable {
13821389 ) . _unsafelyUnwrappedUnchecked
13831390 }
13841391}
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