-
Notifications
You must be signed in to change notification settings - Fork 189
[Android] Use the Bionic module in more places #842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ internal import DarwinPrivate.sys.content_protection | |
|
||
#if canImport(Darwin) | ||
import Darwin | ||
#elseif os(Android) | ||
#elseif canImport(Android) | ||
import Android | ||
import posix_filesystem | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
#elseif canImport(Glibc) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
|
||
#if canImport(Darwin) | ||
import Darwin | ||
#elseif os(Android) | ||
#elseif canImport(Android) | ||
import Android | ||
import unistd | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
#elseif canImport(Glibc) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,7 +109,7 @@ struct _Win32DirectoryContentsSequence: Sequence { | |
|
||
#if canImport(Darwin) | ||
import Darwin | ||
#elseif os(Android) | ||
#elseif canImport(Android) | ||
import Android | ||
import posix_filesystem.dirent | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
#elseif canImport(Glibc) | ||
|
@@ -328,7 +328,7 @@ extension Sequence<_FTSSequence.Element> { | |
struct _POSIXDirectoryContentsSequence: Sequence { | ||
#if canImport(Darwin) | ||
typealias DirectoryEntryPtr = UnsafeMutablePointer<DIR> | ||
#elseif os(Android) || canImport(Glibc) || canImport(Musl) || os(WASI) | ||
#elseif canImport(Android) || canImport(Glibc) || canImport(Musl) || os(WASI) | ||
typealias DirectoryEntryPtr = OpaquePointer | ||
#endif | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ fileprivate let _pageSize: Int = { | |
#elseif os(WASI) | ||
// WebAssembly defines a fixed page size | ||
fileprivate let _pageSize: Int = 65_536 | ||
#elseif os(Android) | ||
#elseif canImport(Android) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it intentional that we check I agree with you that using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, as
Yes, they are interchangeable, as they are both defined in the same module map. However,
No need to, as they are interchangeable and one is simply chosen to match the non-interchangeable |
||
import Bionic | ||
import unistd | ||
fileprivate let _pageSize: Int = Int(getpagesize()) | ||
|
@@ -175,7 +175,7 @@ extension Platform { | |
// FIXME: bionic implements this as `return 0;` and does not expose the | ||
// function via headers. We should be able to shim this and use the call | ||
// if it is available. | ||
#if !os(Android) && !os(WASI) | ||
#if !canImport(Android) && !os(WASI) | ||
guard issetugid() == 0 else { return nil } | ||
#endif | ||
if let value = getenv(name) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ internal import _FoundationCShims | |
|
||
#if canImport(Darwin) | ||
import Darwin | ||
#elseif os(Android) | ||
#elseif canImport(Android) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same explanation as above |
||
import Bionic | ||
import unistd | ||
#elseif canImport(Glibc) | ||
|
@@ -165,7 +165,7 @@ final class _ProcessInfo: Sendable { | |
} | ||
|
||
var userName: String { | ||
#if canImport(Darwin) || os(Android) || canImport(Glibc) || canImport(Musl) | ||
#if canImport(Darwin) || canImport(Android) || canImport(Glibc) || canImport(Musl) | ||
// Darwin and Linux | ||
let (euid, _) = Platform.getUGIDs() | ||
if let upwd = getpwuid(euid), | ||
|
@@ -200,10 +200,10 @@ final class _ProcessInfo: Sendable { | |
} | ||
|
||
var fullUserName: String { | ||
#if os(Android) && (arch(i386) || arch(arm)) | ||
#if canImport(Android) && (arch(i386) || arch(arm)) | ||
// On LP32 Android, pw_gecos doesn't exist and is presumed to be NULL. | ||
return "" | ||
#elseif canImport(Darwin) || os(Android) || canImport(Glibc) || canImport(Musl) | ||
#elseif canImport(Darwin) || canImport(Android) || canImport(Glibc) || canImport(Musl) | ||
let (euid, _) = Platform.getUGIDs() | ||
if let upwd = getpwuid(euid), | ||
let fullname = upwd.pointee.pw_gecos { | ||
|
@@ -368,7 +368,7 @@ extension _ProcessInfo { | |
} | ||
|
||
var operatingSystemVersion: (major: Int, minor: Int, patch: Int) { | ||
#if canImport(Darwin) || os(Linux) || os(FreeBSD) || os(OpenBSD) || os(Android) | ||
#if canImport(Darwin) || os(Linux) || os(FreeBSD) || os(OpenBSD) || canImport(Android) | ||
var uts: utsname = utsname() | ||
guard uname(&uts) == 0 else { | ||
return (major: -1, minor: 0, patch: 0) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this redundant since the prior Android overlay includes it?