File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -291,10 +291,14 @@ extension ProtobufEncoder {
291291 }
292292
293293 func binaryPlistData< T> ( for value: T ) throws -> Data where T: Encodable {
294+ #if os(WASI)
295+ fatalError ( " PropertyListEncoder is not avaiable on WASI " )
296+ #else
294297 let encoder = PropertyListEncoder ( )
295298 encoder. outputFormat = . binary
296299 encoder. userInfo = userInfo
297300 return try encoder. encode ( [ value] )
301+ #endif
298302 }
299303
300304 @inline ( __always)
@@ -467,6 +471,7 @@ extension ProtobufEncoder {
467471 encodeVarintZZ ( Int ( value) )
468472 }
469473
474+ #if compiler(>=6.0)
470475 @inline ( __always)
471476 private mutating func encodeBitwiseCopyable< T> ( _ value: T ) where T: BitwiseCopyable {
472477 let oldSize = size
@@ -478,6 +483,19 @@ extension ProtobufEncoder {
478483 buffer. advanced ( by: oldSize) . storeBytes ( of: value, as: T . self)
479484 }
480485 }
486+ #else // FIXME: Remove this after we drop WASI 5.10 support
487+ @inline ( __always)
488+ private mutating func encodeBitwiseCopyable< T> ( _ value: T ) {
489+ let oldSize = size
490+ let newSize = oldSize + MemoryLayout< T> . size
491+ if capacity < newSize {
492+ growBufferSlow ( to: newSize) . storeBytes ( of: value, as: T . self)
493+ } else {
494+ size = newSize
495+ buffer. advanced ( by: oldSize) . storeBytes ( of: value, as: T . self)
496+ }
497+ }
498+ #endif
481499
482500 package mutating func encodeBool( _ value: Bool ) {
483501 encodeBitwiseCopyable ( value)
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ extension UnsafePointer {
1515
1616 @_transparent
1717 package static var null : UnsafePointer < Pointee > {
18- UnsafePointer ( bitPattern: Int ( bitPattern: 0xffff_ffff_ffff_ff00 ) | ( - MemoryLayout < Pointee > . alignment) ) !
18+ UnsafePointer ( bitPattern: Int ( bitPattern: UInt . max - 0xff ) | ( - MemoryLayout < Pointee > . alignment) ) !
1919 }
2020}
2121
@@ -29,7 +29,7 @@ extension UnsafeMutablePointer {
2929
3030 @_transparent
3131 package static var null : UnsafeMutablePointer < Pointee > {
32- UnsafeMutablePointer ( bitPattern: Int ( bitPattern: 0xffff_ffff_ffff_ff00 ) | ( - MemoryLayout < Pointee > . alignment) ) !
32+ UnsafeMutablePointer ( bitPattern: Int ( bitPattern: UInt . max - 0xff ) | ( - MemoryLayout < Pointee > . alignment) ) !
3333 }
3434}
3535
You can’t perform that action at this time.
0 commit comments