Skip to content

Commit 7b0f469

Browse files
authored
Add support for Musl libc (#574)
* Add support for Musl libc Since Musl is sufficiently different from Glibc (see https://wiki.musl-libc.org/functional-differences-from-glibc.html), it requires a different import, which now should be applied to files that have `import Glibc` in them. * Platform.swift: fix macOS build issue Glibc and Darwin can share the same `ioctl` code.
1 parent 1ed0ac0 commit 7b0f469

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Sources/ArgumentParser/Utilities/Platform.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#if canImport(Glibc)
1313
import Glibc
14+
#elseif canImport(Musl)
15+
import Musl
1416
#elseif canImport(Darwin)
1517
import Darwin
1618
#elseif canImport(CRT)
@@ -78,6 +80,8 @@ extension Platform {
7880
static func exit(_ code: Int32) -> Never {
7981
#if canImport(Glibc)
8082
Glibc.exit(code)
83+
#elseif canImport(Musl)
84+
Musl.exit(code)
8185
#elseif canImport(Darwin)
8286
Darwin.exit(code)
8387
#elseif canImport(CRT)
@@ -135,6 +139,8 @@ extension Platform {
135139
// TIOCGWINSZ is a complex macro, so we need the flattened value.
136140
let tiocgwinsz = Int32(0x40087468)
137141
let err = ioctl(STDOUT_FILENO, tiocgwinsz, &w)
142+
#elseif canImport(Musl)
143+
let err = ioctl(STDOUT_FILENO, UInt(TIOCGWINSZ), &w)
138144
#else
139145
let err = ioctl(STDOUT_FILENO, TIOCGWINSZ, &w)
140146
#endif

0 commit comments

Comments
 (0)