Skip to content

Commit

Permalink
[Android] Use the new overlay and Bionic module from Swift 6
Browse files Browse the repository at this point in the history
The new overlay was merged into Swift 6 in swiftlang/swift#74758.
  • Loading branch information
finagolfin committed Aug 6, 2024
1 parent 8740e15 commit 031e9ed
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ private import Darwin
private import Glibc
#elseif canImport(Musl)
private import Musl
#elseif canImport(Android)
private import Android
#endif
#else
import SwiftSyntaxMacros
Expand Down Expand Up @@ -137,7 +139,7 @@ private func _loadLibrary(_ path: String) throws -> UnsafeMutableRawPointer {
#else
private func _loadLibrary(_ path: String) throws -> UnsafeMutableRawPointer {
guard let dlHandle = dlopen(path, RTLD_LAZY | RTLD_LOCAL) else {
throw LibraryPluginError(message: "loader error: \(String(cString: dlerror()))")
throw LibraryPluginError(message: "loader error: \(String(cString: dlerror()!))")
}
return dlHandle
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftSyntax/SyntaxText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
private import Darwin
#elseif canImport(Glibc)
private import Glibc
#elseif canImport(Bionic)
private import Bionic
#elseif canImport(Musl)
private import Musl
#endif
Expand Down Expand Up @@ -281,6 +283,8 @@ private func compareMemory(
return Darwin.memcmp(s1, s2, count) == 0
#elseif canImport(Glibc)
return Glibc.memcmp(s1, s2, count) == 0
#elseif canImport(Bionic)
return Bionic.memcmp(s1, s2, count) == 0
#else
return UnsafeBufferPointer(start: s1, count: count)
.elementsEqual(UnsafeBufferPointer(start: s2, count: count))
Expand Down
2 changes: 2 additions & 0 deletions SwiftParserCLI/Sources/swift-parser-cli/TerminalUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import Glibc
#elseif canImport(Musl)
import Musl
#elseif canImport(Android)
import Android
#elseif os(Windows)
import CRT
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SigIntListener {
/// Registers a `SIGINT` signal handler that forwards `SIGINT` to all
/// subprocesses that are registered in `runningSubprocesses`
static func registerSigIntSubprocessTerminationHandler() {
#if canImport(Darwin) || canImport(Glibc)
#if canImport(Darwin) || canImport(Glibc) || canImport(Bionic)
signal(SIGINT) { _ in
SigIntListener.hasReceivedSigInt = true
for process in SigIntListener.runningSubprocesses {
Expand Down

0 comments on commit 031e9ed

Please sign in to comment.