Skip to content

Commit b936799

Browse files
authored
OpenBSD support. (#291)
On this platform, the TIOCGWINSZ ioctl identifier is a complex macro. Since we don't have a C bridging header obviously available to get the flattened value, supply is the flattened value obtained elsewhere. This is of course brittle but this is the simplest way around this for now. Additionally, ensure we support the platform architecture name, where the x86_64 architecture is called amd64 instead.
1 parent 0fccec7 commit b936799

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Sources/ArgumentParser/Usage/HelpGenerator.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,13 @@ func _terminalSize() -> (width: Int, height: Int) {
325325
height: Int(csbi.srWindow.Bottom - csbi.srWindow.Top) + 1)
326326
#else
327327
var w = winsize()
328+
#if os(OpenBSD)
329+
// TIOCGWINSZ is a complex macro, so we need the flattened value.
330+
let tiocgwinsz = Int32(0x40087468)
331+
let err = ioctl(STDOUT_FILENO, tiocgwinsz, &w)
332+
#else
328333
let err = ioctl(STDOUT_FILENO, TIOCGWINSZ, &w)
334+
#endif
329335
let width = Int(w.ws_col)
330336
let height = Int(w.ws_row)
331337
guard err == 0 else { return (80, 25) }

cmake/modules/SwiftSupport.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ function(get_swift_host_arch result_var_name)
2727
set("${result_var_name}" "armv7" PARENT_SCOPE)
2828
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7l")
2929
set("${result_var_name}" "armv7" PARENT_SCOPE)
30+
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "amd64")
31+
set("${result_var_name}" "amd64" PARENT_SCOPE)
3032
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64")
3133
set("${result_var_name}" "x86_64" PARENT_SCOPE)
3234
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "IA64")

0 commit comments

Comments
 (0)