Skip to content

Commit 8e121e4

Browse files
authored
[android] fix 32 bit android build (#656)
This fixes the following errors: ``` S:/SourceCache/swift-testing/Sources/Testing/Support/FileHandle.swift:423:70: error: cannot convert value of type 'UInt32' to expected argument type 'mode_t' (aka 'UInt16') 421 | } 422 | var statStruct = stat() 423 | return (0 == fstat(fd, &statStruct) && swt_S_ISFIFO(statStruct.st_mode)) | `- error: cannot convert value of type 'UInt32' to expected argument type 'mode_t' (aka 'UInt16') 424 | } 425 | #elseif os(Windows) S:/SourceCache/swift-testing/Sources/Testing/Support/GetSymbol.swift:34:73: error: integer literal '4294967295' overflows when stored into 'Int' 32 | private nonisolated(unsafe) let RTLD_DEFAULT = ImageAddress(bitPattern: -2) 33 | #elseif os(Android) && _pointerBitWidth(_32) 34 | private nonisolated(unsafe) let RTLD_DEFAULT = ImageAddress(bitPattern: 0xFFFFFFFF) | `- error: integer literal '4294967295' overflows when stored into 'Int' ``` ### Motivation: Fix 32 bit android build. ### Modifications: Add explicit types to to cast correctly and to pick correct overload. ### Result: Android swift-testing will build for armv7k and i686. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent f2c8ee1 commit 8e121e4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Sources/Testing/Support/FileHandle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ extension FileHandle {
420420
return false
421421
}
422422
var statStruct = stat()
423-
return (0 == fstat(fd, &statStruct) && swt_S_ISFIFO(statStruct.st_mode))
423+
return (0 == fstat(fd, &statStruct) && swt_S_ISFIFO(mode_t(statStruct.st_mode)))
424424
}
425425
#elseif os(Windows)
426426
return withUnsafeWindowsHANDLE { handle in

Sources/Testing/Support/GetSymbol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ typealias ImageAddress = Never
3131
#if SWT_TARGET_OS_APPLE
3232
private nonisolated(unsafe) let RTLD_DEFAULT = ImageAddress(bitPattern: -2)
3333
#elseif os(Android) && _pointerBitWidth(_32)
34-
private nonisolated(unsafe) let RTLD_DEFAULT = ImageAddress(bitPattern: 0xFFFFFFFF)
34+
private nonisolated(unsafe) let RTLD_DEFAULT = ImageAddress(bitPattern: UInt(0xFFFFFFFF))
3535
#elseif os(Linux) || os(Android)
3636
private nonisolated(unsafe) let RTLD_DEFAULT = ImageAddress(bitPattern: 0)
3737
#endif

0 commit comments

Comments
 (0)