Skip to content

Commit 4ebb514

Browse files
authored
Merge pull request #9185 from lcheylus/openbsd-fix_stdbuf
stdbuf: add support for OpenBSD
2 parents ff14ca9 + 3347de4 commit 4ebb514

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

src/uu/stdbuf/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::process::Command;
1414
target_os = "android",
1515
target_os = "freebsd",
1616
target_os = "netbsd",
17+
target_os = "openbsd",
1718
target_os = "dragonfly"
1819
))]
1920
mod platform {

src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ pub unsafe extern "C" fn __stdbuf_get_stdin() -> *mut FILE {
2727
unsafe { __stdinp() }
2828
}
2929

30-
#[cfg(not(any(target_os = "macos", target_os = "freebsd")))]
30+
#[cfg(target_os = "openbsd")]
31+
{
32+
unsafe extern "C" {
33+
static mut __stdin: *mut FILE;
34+
}
35+
unsafe { __stdin }
36+
}
37+
38+
#[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd")))]
3139
{
3240
unsafe extern "C" {
3341
static mut stdin: *mut FILE;
@@ -48,7 +56,15 @@ pub unsafe extern "C" fn __stdbuf_get_stdout() -> *mut FILE {
4856
unsafe { __stdoutp() }
4957
}
5058

51-
#[cfg(not(any(target_os = "macos", target_os = "freebsd")))]
59+
#[cfg(target_os = "openbsd")]
60+
{
61+
unsafe extern "C" {
62+
static mut __stdout: *mut FILE;
63+
}
64+
unsafe { __stdout }
65+
}
66+
67+
#[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd")))]
5268
{
5369
unsafe extern "C" {
5470
static mut stdout: *mut FILE;
@@ -69,7 +85,15 @@ pub unsafe extern "C" fn __stdbuf_get_stderr() -> *mut FILE {
6985
unsafe { __stderrp() }
7086
}
7187

72-
#[cfg(not(any(target_os = "macos", target_os = "freebsd")))]
88+
#[cfg(target_os = "openbsd")]
89+
{
90+
unsafe extern "C" {
91+
static mut __stderr: *mut FILE;
92+
}
93+
unsafe { __stderr }
94+
}
95+
96+
#[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd")))]
7397
{
7498
unsafe extern "C" {
7599
static mut stderr: *mut FILE;

src/uu/stdbuf/src/stdbuf.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ mod options {
3535
target_os = "android",
3636
target_os = "freebsd",
3737
target_os = "netbsd",
38+
target_os = "openbsd",
3839
target_os = "dragonfly"
3940
)
4041
))]
@@ -82,6 +83,7 @@ enum ProgramOptionsError {
8283
target_os = "android",
8384
target_os = "freebsd",
8485
target_os = "netbsd",
86+
target_os = "openbsd",
8587
target_os = "dragonfly"
8688
))]
8789
fn preload_strings() -> UResult<(&'static str, &'static str)> {
@@ -98,6 +100,7 @@ fn preload_strings() -> UResult<(&'static str, &'static str)> {
98100
target_os = "android",
99101
target_os = "freebsd",
100102
target_os = "netbsd",
103+
target_os = "openbsd",
101104
target_os = "dragonfly",
102105
target_vendor = "apple"
103106
)))]

0 commit comments

Comments
 (0)