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 Dec 3, 2022
2 parents 15d2795 + 27cc898 commit 2eea873
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 4 deletions.
8 changes: 8 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 @@ -1511,6 +1516,7 @@ fn test_android(target: &str) {
"elf.h",
"errno.h",
"fcntl.h",
"getopt.h",
"grp.h",
"ifaddrs.h",
"libgen.h",
Expand Down Expand Up @@ -1884,6 +1890,7 @@ fn test_freebsd(target: &str) {
"errno.h",
"execinfo.h",
"fcntl.h",
"getopt.h",
"glob.h",
"grp.h",
"iconv.h",
Expand Down Expand Up @@ -2804,6 +2811,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
3 changes: 2 additions & 1 deletion libc-test/semver/android.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3026,6 +3026,7 @@ getline
getlogin
getnameinfo
getopt
getopt_long
getpeername
getpgid
getpgrp
Expand Down Expand Up @@ -3594,4 +3595,4 @@ wmemchr
write
writev
dirname
basename
basename
3 changes: 2 additions & 1 deletion libc-test/semver/apple.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1895,6 +1895,7 @@ getline
getloadavg
getmntinfo
getnameinfo
getopt_long
getpeereid
getpriority
getprogname
Expand Down Expand Up @@ -2228,4 +2229,4 @@ waitid
xsw_usage
xucred
dirname
basename
basename
1 change: 1 addition & 0 deletions libc-test/semver/dragonfly.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,7 @@ getlastlogx
getline
getloadavg
getnameinfo
getopt_long
getpeereid
getpriority
getprogname
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/freebsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,7 @@ getline
getloadavg
getlocalbase
getnameinfo
getopt_long
getpagesize
getpagesizes
getpeereid
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2967,6 +2967,7 @@ getifaddrs
getline
getmntent
getnameinfo
getopt_long
getpriority
getpwent
getresgid
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/netbsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,7 @@ getlastlogx
getline
getloadavg
getnameinfo
getopt_long
getpeereid
getpriority
getprogname
Expand Down
3 changes: 2 additions & 1 deletion libc-test/semver/openbsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,7 @@ getline
getloadavg
getmntinfo
getnameinfo
getopt_long
getpeereid
getpriority
getprogname
Expand Down Expand Up @@ -1232,4 +1233,4 @@ utrace
wait4
xucred
dirname
basename
basename
14 changes: 14 additions & 0 deletions src/unix/bsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ s! {
pub rm_so: regoff_t,
pub rm_eo: regoff_t,
}

pub struct option {
pub name: *const ::c_char,
pub has_arg: ::c_int,
pub flag: *mut ::c_int,
pub val: ::c_int,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -885,6 +892,13 @@ extern "C" {
pub fn srand48(seed: ::c_long);
pub fn seed48(xseed: *mut ::c_ushort) -> *mut ::c_ushort;
pub fn lcong48(p: *mut ::c_ushort);
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;
}

cfg_if! {
Expand Down
15 changes: 14 additions & 1 deletion src/unix/haiku/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,13 @@ s! {
pub key: *mut ::c_char,
pub data: *mut ::c_void,
}

pub struct option {
pub name: *const ::c_char,
pub has_arg: ::c_int,
pub flag: *mut ::c_int,
pub val: ::c_int,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -1971,7 +1978,13 @@ extern "C" {
attr: *mut posix_spawnattr_t,
sigmask: *const ::sigset_t,
) -> ::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;
}

#[link(name = "bsd")]
Expand Down
14 changes: 14 additions & 0 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,13 @@ s! {
pub code: ::__u16,
pub absinfo: input_absinfo,
}

pub struct option {
pub name: *const ::c_char,
pub has_arg: ::c_int,
pub flag: *mut ::c_int,
pub val: ::c_int,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -3471,6 +3478,13 @@ extern "C" {

pub fn dirname(path: *const ::c_char) -> *mut ::c_char;
pub fn basename(path: *const ::c_char) -> *mut ::c_char;
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;
}

cfg_if! {
Expand Down
14 changes: 14 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,13 @@ s! {
pub ifr6_prefixlen: u32,
pub ifr6_ifindex: ::c_int,
}

pub struct option {
pub name: *const ::c_char,
pub has_arg: ::c_int,
pub flag: *mut ::c_int,
pub val: ::c_int,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -4441,6 +4448,13 @@ extern "C" {

pub fn pthread_getname_np(thread: ::pthread_t, name: *mut ::c_char, len: ::size_t) -> ::c_int;
pub fn pthread_setname_np(thread: ::pthread_t, name: *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;
}

cfg_if! {
Expand Down
15 changes: 15 additions & 0 deletions src/unix/solarish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,13 @@ s! {
pub pi_fputypes: [::c_char; PI_FPUTYPE as usize],
pub pi_clock: ::c_int,
}

pub struct option {
pub name: *const ::c_char,
pub has_arg: ::c_int,
pub flag: *mut ::c_int,
pub val: ::c_int,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -3182,6 +3189,14 @@ extern "C" {
pub fn backtrace(buffer: *mut *mut ::c_void, size: ::c_int) -> ::c_int;
pub fn backtrace_symbols(buffer: *const *mut ::c_void, size: ::c_int) -> *mut *mut ::c_char;
pub fn backtrace_symbols_fd(buffer: *const *mut ::c_void, size: ::c_int, fd: ::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;
}

#[link(name = "sendfile")]
Expand Down

0 comments on commit 2eea873

Please sign in to comment.