Skip to content

Commit 6898d35

Browse files
0323pinsylvestre
authored andcommitted
Fix stdbuf on NetBSD
closes #11410
1 parent c794796 commit 6898d35

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ pub unsafe extern "C" fn __stdbuf_get_stdin() -> *mut FILE {
3535
unsafe { __stdin }
3636
}
3737

38+
#[cfg(target_os = "netbsd")]
39+
{
40+
unsafe { libc::fdopen(0, c"r".as_ptr()) }
41+
}
42+
3843
#[cfg(target_os = "cygwin")]
3944
{
4045
// _getreent()->_std{in,out,err}
@@ -61,6 +66,7 @@ pub unsafe extern "C" fn __stdbuf_get_stdin() -> *mut FILE {
6166
#[cfg(not(any(
6267
target_os = "macos",
6368
target_os = "freebsd",
69+
target_os = "netbsd",
6470
target_os = "openbsd",
6571
target_os = "cygwin"
6672
)))]
@@ -92,6 +98,11 @@ pub unsafe extern "C" fn __stdbuf_get_stdout() -> *mut FILE {
9298
unsafe { __stdout }
9399
}
94100

101+
#[cfg(target_os = "netbsd")]
102+
{
103+
unsafe { libc::fdopen(1, c"w".as_ptr()) }
104+
}
105+
95106
#[cfg(target_os = "cygwin")]
96107
{
97108
// _getreent()->_std{in,out,err}
@@ -118,6 +129,7 @@ pub unsafe extern "C" fn __stdbuf_get_stdout() -> *mut FILE {
118129
#[cfg(not(any(
119130
target_os = "macos",
120131
target_os = "freebsd",
132+
target_os = "netbsd",
121133
target_os = "openbsd",
122134
target_os = "cygwin"
123135
)))]
@@ -149,6 +161,11 @@ pub unsafe extern "C" fn __stdbuf_get_stderr() -> *mut FILE {
149161
unsafe { __stderr }
150162
}
151163

164+
#[cfg(target_os = "netbsd")]
165+
{
166+
unsafe { libc::fdopen(2, c"w".as_ptr()) }
167+
}
168+
152169
#[cfg(target_os = "cygwin")]
153170
{
154171
// _getreent()->_std{in,out,err}
@@ -175,6 +192,7 @@ pub unsafe extern "C" fn __stdbuf_get_stderr() -> *mut FILE {
175192
#[cfg(not(any(
176193
target_os = "macos",
177194
target_os = "freebsd",
195+
target_os = "netbsd",
178196
target_os = "openbsd",
179197
target_os = "cygwin"
180198
)))]

0 commit comments

Comments
 (0)