Skip to content

Commit

Permalink
Auto merge of #3021 - devnexen:getopt_long, r=JohnTitor
Browse files Browse the repository at this point in the history
adding getopt_long for unixes.
  • Loading branch information
bors committed Nov 30, 2022
2 parents d6fe782 + 8b77cda commit cbbc225
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ fn test_apple(target: &str) {
"errno.h",
"execinfo.h",
"fcntl.h",
"getopt.h",
"glob.h",
"grp.h",
"iconv.h",
Expand Down Expand Up @@ -421,6 +422,7 @@ fn test_openbsd(target: &str) {
"errno.h",
"execinfo.h",
"fcntl.h",
"getopt.h",
"libgen.h",
"limits.h",
"link.h",
Expand Down Expand Up @@ -769,6 +771,7 @@ fn test_solarish(target: &str) {
"errno.h",
"execinfo.h",
"fcntl.h",
"getopt.h",
"glob.h",
"grp.h",
"ifaddrs.h",
Expand Down Expand Up @@ -997,6 +1000,7 @@ fn test_netbsd(target: &str) {
"elf.h",
"errno.h",
"fcntl.h",
"getopt.h",
"libgen.h",
"limits.h",
"link.h",
Expand Down Expand Up @@ -1208,6 +1212,7 @@ fn test_dragonflybsd(target: &str) {
"errno.h",
"execinfo.h",
"fcntl.h",
"getopt.h",
"glob.h",
"grp.h",
"ifaddrs.h",
Expand Down Expand Up @@ -1884,6 +1889,7 @@ fn test_freebsd(target: &str) {
"errno.h",
"execinfo.h",
"fcntl.h",
"getopt.h",
"glob.h",
"grp.h",
"iconv.h",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/unix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ getgroups
gethostname
getlogin
getopt
getopt_long
getpeername
getpgid
getpgrp
Expand Down
14 changes: 14 additions & 0 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit cbbc225

Please sign in to comment.