@@ -16,11 +16,11 @@ class Missile {
1616UnsafeMutableRawPointerExtraTestSuite . test ( " initializeMemory " ) {
1717 Missile . missilesLaunched = 0
1818 do {
19- let sizeInBytes = 3 * strideof ( Missile . self )
19+ let sizeInBytes = 3 * MemoryLayout < Missile> . stride
2020 var p1 = UnsafeMutableRawPointer . allocate (
21- bytes: sizeInBytes, alignedTo: alignof ( Missile . self ) )
21+ bytes: sizeInBytes, alignedTo: MemoryLayout < Missile> . alignment )
2222 defer {
23- p1. deallocate ( bytes: sizeInBytes, alignedTo: alignof ( Missile . self ) )
23+ p1. deallocate ( bytes: sizeInBytes, alignedTo: MemoryLayout < Missile> . alignment )
2424 }
2525 var ptrM = p1. initializeMemory ( as: Missile . self, to: Missile ( 1 ) )
2626 p1. initializeMemory ( as: Missile . self, at: 1 , count: 2 , to: Missile ( 2 ) )
@@ -29,9 +29,9 @@ UnsafeMutableRawPointerExtraTestSuite.test("initializeMemory") {
2929 expectEqual ( 2 , ptrM [ 2 ] . number)
3030
3131 var p2 = UnsafeMutableRawPointer . allocate (
32- bytes: sizeInBytes, alignedTo: alignof ( Missile . self ) )
32+ bytes: sizeInBytes, alignedTo: MemoryLayout < Missile> . alignment )
3333 defer {
34- p2. deallocate ( bytes: sizeInBytes, alignedTo: alignof ( Missile . self ) )
34+ p2. deallocate ( bytes: sizeInBytes, alignedTo: MemoryLayout < Missile> . alignment )
3535 }
3636 let ptrM2 = p2. moveInitializeMemory ( as: Missile . self, from: ptrM, count: 3 )
3737 defer {
@@ -55,11 +55,11 @@ UnsafeMutableRawPointerExtraTestSuite.test("initializeMemory") {
5555}
5656
5757UnsafeMutableRawPointerExtraTestSuite . test ( " bindMemory " ) {
58- let sizeInBytes = 3 * strideof ( Int . self )
58+ let sizeInBytes = 3 * MemoryLayout < Int> . stride
5959 var p1 = UnsafeMutableRawPointer . allocate (
60- bytes: sizeInBytes, alignedTo: alignof ( Int . self ) )
60+ bytes: sizeInBytes, alignedTo: MemoryLayout < Int> . alignment )
6161 defer {
62- p1. deallocate ( bytes: sizeInBytes, alignedTo: alignof ( Int . self ) )
62+ p1. deallocate ( bytes: sizeInBytes, alignedTo: MemoryLayout < Int> . alignment )
6363 }
6464 let ptrI = p1. bindMemory ( to: Int . self, capacity: 3 )
6565 ptrI. initialize ( from: 1 ... 3 )
@@ -72,33 +72,33 @@ UnsafeMutableRawPointerExtraTestSuite.test("bindMemory") {
7272}
7373
7474UnsafeMutableRawPointerExtraTestSuite . test ( " load/store " ) {
75- let sizeInBytes = 3 * strideof ( Int . self )
75+ let sizeInBytes = 3 * MemoryLayout < Int> . stride
7676 var p1 = UnsafeMutableRawPointer . allocate (
77- bytes: sizeInBytes, alignedTo: alignof ( Int . self ) )
77+ bytes: sizeInBytes, alignedTo: MemoryLayout < Int> . alignment )
7878 defer {
79- p1. deallocate ( bytes: sizeInBytes, alignedTo: alignof ( Int . self ) )
79+ p1. deallocate ( bytes: sizeInBytes, alignedTo: MemoryLayout < Int> . alignment )
8080 }
8181 let ptrI = p1. initializeMemory ( as: Int . self, from: 1 ... 3 )
8282 defer {
8383 ptrI. deinitialize ( count: 3 )
8484 }
8585 expectEqual ( 1 , p1. load ( as: Int . self) )
86- expectEqual ( 2 , p1. load ( fromByteOffset: strideof ( Int . self ) , as: Int . self) )
87- expectEqual ( 3 , p1. load ( fromByteOffset: 2 * strideof ( Int . self ) , as: Int . self) )
86+ expectEqual ( 2 , p1. load ( fromByteOffset: MemoryLayout < Int> . stride , as: Int . self) )
87+ expectEqual ( 3 , p1. load ( fromByteOffset: 2 * MemoryLayout < Int> . stride , as: Int . self) )
8888 p1. storeBytes ( of: 4 , as: Int . self)
89- p1. storeBytes ( of: 5 , toByteOffset: strideof ( Int . self ) , as: Int . self)
90- p1. storeBytes ( of: 6 , toByteOffset: 2 * strideof ( Int . self ) , as: Int . self)
89+ p1. storeBytes ( of: 5 , toByteOffset: MemoryLayout < Int> . stride , as: Int . self)
90+ p1. storeBytes ( of: 6 , toByteOffset: 2 * MemoryLayout < Int> . stride , as: Int . self)
9191 expectEqual ( 4 , p1. load ( as: Int . self) )
92- expectEqual ( 5 , p1. load ( fromByteOffset: strideof ( Int . self ) , as: Int . self) )
93- expectEqual ( 6 , p1. load ( fromByteOffset: 2 * strideof ( Int . self ) , as: Int . self) )
92+ expectEqual ( 5 , p1. load ( fromByteOffset: MemoryLayout < Int> . stride , as: Int . self) )
93+ expectEqual ( 6 , p1. load ( fromByteOffset: 2 * MemoryLayout < Int> . stride , as: Int . self) )
9494}
9595
9696UnsafeMutableRawPointerExtraTestSuite . test ( " copyBytes " ) {
97- let sizeInBytes = 4 * strideof ( Int . self )
97+ let sizeInBytes = 4 * MemoryLayout < Int> . stride
9898 var rawPtr = UnsafeMutableRawPointer . allocate (
99- bytes: sizeInBytes, alignedTo: alignof ( Int . self ) )
99+ bytes: sizeInBytes, alignedTo: MemoryLayout < Int> . alignment )
100100 defer {
101- rawPtr. deallocate ( bytes: sizeInBytes, alignedTo: alignof ( Int . self ) )
101+ rawPtr. deallocate ( bytes: sizeInBytes, alignedTo: MemoryLayout < Int> . alignment )
102102 }
103103 let ptrI = rawPtr. initializeMemory ( as: Int . self, count: 4 , to: 42 )
104104 defer {
@@ -108,32 +108,32 @@ UnsafeMutableRawPointerExtraTestSuite.test("copyBytes") {
108108 // Right overlap
109109 ptrI [ 0 ] = 1
110110 ptrI [ 1 ] = 2
111- ( rawPtr + strideof ( Int . self ) ) . copyBytes (
112- from: roPtr, count: 2 * strideof ( Int . self ) )
111+ ( rawPtr + MemoryLayout < Int > . stride ) . copyBytes (
112+ from: roPtr, count: 2 * MemoryLayout < Int> . stride )
113113 expectEqual ( 1 , ptrI [ 1 ] )
114114 expectEqual ( 2 , ptrI [ 2 ] )
115115
116116 // Left overlap
117117 ptrI [ 1 ] = 2
118118 ptrI [ 2 ] = 3
119119 rawPtr. copyBytes (
120- from: roPtr + strideof ( Int . self ) , count: 2 * strideof ( Int . self ) )
120+ from: roPtr + MemoryLayout < Int> . stride , count: 2 * MemoryLayout < Int> . stride )
121121 expectEqual ( 2 , ptrI [ 0 ] )
122122 expectEqual ( 3 , ptrI [ 1 ] )
123123
124124 // Disjoint:
125125 ptrI [ 2 ] = 2
126126 ptrI [ 3 ] = 3
127127 rawPtr. copyBytes (
128- from: roPtr + 2 * strideof ( Int . self ) , count: 2 * strideof ( Int . self ) )
128+ from: roPtr + 2 * MemoryLayout < Int> . stride , count: 2 * MemoryLayout < Int> . stride )
129129 expectEqual ( 2 , ptrI [ 0 ] )
130130 expectEqual ( 3 , ptrI [ 1 ] )
131131
132132 // Backwards
133133 ptrI [ 0 ] = 0
134134 ptrI [ 1 ] = 1
135- ( rawPtr + 2 * strideof ( Int . self ) ) . copyBytes (
136- from: roPtr, count: 2 * strideof ( Int . self ) )
135+ ( rawPtr + 2 * MemoryLayout < Int > . stride ) . copyBytes (
136+ from: roPtr, count: 2 * MemoryLayout < Int> . stride )
137137 expectEqual ( 0 , ptrI [ 2 ] )
138138 expectEqual ( 1 , ptrI [ 3 ] )
139139}
0 commit comments