diff --git a/libc-test/build.rs b/libc-test/build.rs index a0e0380e61a96..8ec239ddf89d3 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -199,6 +199,7 @@ fn test_apple(target: &str) { "errno.h", "execinfo.h", "fcntl.h", + "getopt.h", "glob.h", "grp.h", "iconv.h", @@ -421,6 +422,7 @@ fn test_openbsd(target: &str) { "errno.h", "execinfo.h", "fcntl.h", + "getopt.h", "libgen.h", "limits.h", "link.h", @@ -769,6 +771,7 @@ fn test_solarish(target: &str) { "errno.h", "execinfo.h", "fcntl.h", + "getopt.h", "glob.h", "grp.h", "ifaddrs.h", @@ -997,6 +1000,7 @@ fn test_netbsd(target: &str) { "elf.h", "errno.h", "fcntl.h", + "getopt.h", "libgen.h", "limits.h", "link.h", @@ -1208,6 +1212,7 @@ fn test_dragonflybsd(target: &str) { "errno.h", "execinfo.h", "fcntl.h", + "getopt.h", "glob.h", "grp.h", "ifaddrs.h", @@ -1884,6 +1889,7 @@ fn test_freebsd(target: &str) { "errno.h", "execinfo.h", "fcntl.h", + "getopt.h", "glob.h", "grp.h", "iconv.h", @@ -2803,6 +2809,7 @@ fn test_linux(target: &str) { "dlfcn.h", "elf.h", "fcntl.h", + "getopt.h", "glob.h", [gnu]: "gnu/libc-version.h", "grp.h", diff --git a/libc-test/semver/unix.txt b/libc-test/semver/unix.txt index 269c0ff0e5846..c7357b941ebee 100644 --- a/libc-test/semver/unix.txt +++ b/libc-test/semver/unix.txt @@ -559,6 +559,7 @@ getgroups gethostname getlogin getopt +getopt_long getpeername getpgid getpgrp diff --git a/src/unix/mod.rs b/src/unix/mod.rs index fb9ebf792e53d..006e59c21ec8a 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -201,6 +201,13 @@ s! { pub p_aliases: *mut *mut ::c_char, pub p_proto: ::c_int, } + + pub struct option { + pub name: *const ::c_char, + pub has_arg: ::c_int, + pub flag: *mut ::c_int, + pub val: ::c_int, + } } pub const INT_MIN: c_int = -2147483648; @@ -881,6 +888,13 @@ extern "C" { link_name = "getopt$UNIX2003" )] pub fn getopt(argc: ::c_int, argv: *const *mut c_char, optstr: *const c_char) -> ::c_int; + pub fn getopt_long( + argc: ::c_int, + argv: *const *mut c_char, + optstring: *const c_char, + longopts: *const option, + longindex: *mut ::c_int, + ) -> ::c_int; pub fn getpgid(pid: pid_t) -> pid_t; pub fn getpgrp() -> pid_t; pub fn getpid() -> pid_t;