Skip to content

Commit 750c1bb

Browse files
committed
unix: Add openpty(3) and forkpty(3)
1 parent c2a9e1b commit 750c1bb

File tree

6 files changed

+55
-10
lines changed

6 files changed

+55
-10
lines changed

libc-test/build.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ fn main() {
128128

129129
if bsdlike {
130130
cfg.header("sys/event.h");
131+
132+
if freebsd {
133+
cfg.header("libutil.h");
134+
} else {
135+
cfg.header("util.h");
136+
}
131137
}
132138

133139
if linux {
@@ -136,6 +142,7 @@ fn main() {
136142
cfg.header("sys/xattr.h");
137143
cfg.header("sys/ipc.h");
138144
cfg.header("sys/shm.h");
145+
cfg.header("pty.h");
139146
}
140147

141148
if linux || android {
@@ -149,7 +156,6 @@ fn main() {
149156
cfg.header("sys/sendfile.h");
150157
cfg.header("sys/vfs.h");
151158
cfg.header("sys/syscall.h");
152-
cfg.header("pty.h");
153159
if !musl {
154160
cfg.header("linux/netlink.h");
155161
cfg.header("linux/magic.h");

src/unix/bsd/apple/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,15 @@ extern {
927927
len: *mut ::off_t,
928928
hdtr: *mut ::sf_hdtr,
929929
flags: ::c_int) -> ::c_int;
930+
pub fn openpty(amaster: *mut ::c_int,
931+
aslave: *mut ::c_int,
932+
name: *mut ::c_char,
933+
termp: *mut termios,
934+
winp: *mut ::winsize) -> ::c_int;
935+
pub fn forkpty(amaster: *mut ::c_int,
936+
name: *mut ::c_char,
937+
termp: *mut termios,
938+
winp: *mut ::winsize) -> ::pid_t;
930939
}
931940

932941
cfg_if! {

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,19 @@ extern {
590590
flags: ::c_int) -> ::c_int;
591591
}
592592

593+
#[link(name = "util")]
594+
extern "C" {
595+
pub fn openpty(amaster: *mut ::c_int,
596+
aslave: *mut ::c_int,
597+
name: *mut ::c_char,
598+
termp: *mut termios,
599+
winp: *mut ::winsize) -> ::c_int;
600+
pub fn forkpty(amaster: *mut ::c_int,
601+
name: *mut ::c_char,
602+
termp: *mut termios,
603+
winp: *mut ::winsize) -> ::pid_t;
604+
}
605+
593606
cfg_if! {
594607
if #[cfg(target_os = "freebsd")] {
595608
mod freebsd;

src/unix/bsd/openbsdlike/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,19 @@ extern {
393393
pub fn mkostemps(template: *mut ::c_char, suffixlen: ::c_int, flags: ::c_int) -> ::c_int;
394394
}
395395

396+
#[link(name = "util")]
397+
extern "C" {
398+
pub fn openpty(amaster: *mut ::c_int,
399+
aslave: *mut ::c_int,
400+
name: *mut ::c_char,
401+
termp: *mut termios,
402+
winp: *mut ::winsize) -> ::c_int;
403+
pub fn forkpty(amaster: *mut ::c_int,
404+
name: *mut ::c_char,
405+
termp: *mut termios,
406+
winp: *mut ::winsize) -> ::pid_t;
407+
}
408+
396409
cfg_if! {
397410
if #[cfg(target_os = "bitrig")] {
398411
mod bitrig;

src/unix/notbsd/linux/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,19 @@ extern {
544544
pub fn mkostemps(template: *mut ::c_char, suffixlen: ::c_int, flags: ::c_int) -> ::c_int;
545545
}
546546

547+
#[link(name = "util")]
548+
extern "C" {
549+
pub fn openpty(amaster: *mut ::c_int,
550+
aslave: *mut ::c_int,
551+
name: *mut ::c_char,
552+
termp: *const termios,
553+
winp: *const ::winsize) -> ::c_int;
554+
pub fn forkpty(amaster: *mut ::c_int,
555+
name: *mut ::c_char,
556+
termp: *const termios,
557+
winp: *const ::winsize) -> ::pid_t;
558+
}
559+
547560
cfg_if! {
548561
if #[cfg(any(target_env = "musl",
549562
target_os = "emscripten"))] {

src/unix/notbsd/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -655,15 +655,6 @@ extern {
655655

656656
pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t,
657657
advise: ::c_int) -> ::c_int;
658-
pub fn openpty(amaster: *mut ::c_int,
659-
aslave: *mut ::c_int,
660-
name: *mut ::c_char,
661-
termp: *const termios,
662-
winp: *const ::winsize) -> ::c_int;
663-
pub fn forkpty(amaster: *mut ::c_int,
664-
name: *mut ::c_char,
665-
termp: *const termios,
666-
winp: *const ::winsize) -> ::pid_t;
667658
}
668659

669660
cfg_if! {

0 commit comments

Comments
 (0)