Skip to content

Commit

Permalink
Auto merge of rust-lang#724 - JayH5:more-pgs, r=alexcrichton
Browse files Browse the repository at this point in the history
pwd/grp: Add reentrant getgr functions and consolidate getpw functions

Commit messages sum it up.
  • Loading branch information
bors committed Aug 11, 2017
2 parents 6846305 + 48311b0 commit 56700d5
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 51 deletions.
13 changes: 1 addition & 12 deletions src/unix/bsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,21 +371,10 @@ extern {
pub fn kqueue() -> ::c_int;
pub fn unmount(target: *const ::c_char, arg: ::c_int) -> ::c_int;
pub fn syscall(num: ::c_int, ...) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
pub fn getpwnam_r(name: *const ::c_char,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
pub fn getpwuid_r(uid: ::uid_t,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwent50")]
pub fn getpwent() -> *mut passwd;
pub fn setpwent();
pub fn endpwent();
pub fn getprogname() -> *const ::c_char;
pub fn setprogname(name: *const ::c_char);
pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
Expand Down
5 changes: 0 additions & 5 deletions src/unix/haiku/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,11 +791,6 @@ extern {
pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
pub fn setgroups(ngroups: ::size_t,
ptr: *const ::gid_t) -> ::c_int;
pub fn getpwuid_r(uid: ::uid_t,
pwd: *mut passwd,
buffer: *mut ::c_char,
bufferSize: ::size_t,
result: *mut *mut passwd) -> ::c_int;
pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
-> ::c_int;
Expand Down
27 changes: 26 additions & 1 deletion src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,37 @@ cfg_if! {
extern {
pub fn getgrnam(name: *const ::c_char) -> *mut group;
pub fn getgrgid(gid: ::gid_t) -> *mut group;
#[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")]
pub fn getgrnam_r(name: *const ::c_char,
grp: *mut group,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut group) -> ::c_int;
#[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")]
pub fn getgrgid_r(uid: ::uid_t,
grp: *mut group,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut group) -> ::c_int;

pub fn endpwent();
#[cfg_attr(target_os = "netbsd", link_name = "__getpwnam50")]
pub fn getpwnam(name: *const ::c_char) -> *mut passwd;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwuid50")]
pub fn getpwuid(uid: ::uid_t) -> *mut passwd;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
#[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")]
pub fn getpwnam_r(name: *const ::c_char,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
#[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")]
pub fn getpwuid_r(uid: ::uid_t,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;

pub fn fprintf(stream: *mut ::FILE,
format: *const ::c_char, ...) -> ::c_int;
Expand Down
1 change: 1 addition & 0 deletions src/unix/notbsd/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,7 @@ extern {
pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;

pub fn setpwent();
pub fn endpwent();
pub fn getpwent() -> *mut passwd;
pub fn setspent();
pub fn endspent();
Expand Down
10 changes: 0 additions & 10 deletions src/unix/notbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -856,16 +856,6 @@ f! {
}

extern {
pub fn getpwnam_r(name: *const ::c_char,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
pub fn getpwuid_r(uid: ::uid_t,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
pub fn fdatasync(fd: ::c_int) -> ::c_int;
pub fn mincore(addr: *mut ::c_void, len: ::size_t,
vec: *mut ::c_uchar) -> ::c_int;
Expand Down
14 changes: 1 addition & 13 deletions src/unix/solaris/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1187,20 +1187,8 @@ extern {
serv: *mut ::c_char,
sevlen: ::socklen_t,
flags: ::c_int) -> ::c_int;
#[link_name = "__posix_getpwnam_r"]
pub fn getpwnam_r(name: *const ::c_char,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;

#[link_name = "__posix_getpwuid_r"]
pub fn getpwuid_r(uid: ::uid_t,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
pub fn setpwent();
pub fn endpwent();
pub fn getpwent() -> *mut passwd;
pub fn fdatasync(fd: ::c_int) -> ::c_int;
pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
Expand Down
11 changes: 1 addition & 10 deletions src/unix/uclibc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1422,16 +1422,6 @@ f! {
}

extern {
pub fn getpwnam_r(name: *const ::c_char,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
pub fn getpwuid_r(uid: ::uid_t,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
pub fn fdatasync(fd: ::c_int) -> ::c_int;
pub fn mincore(addr: *mut ::c_void, len: ::size_t,
vec: *mut ::c_uchar) -> ::c_int;
Expand Down Expand Up @@ -1598,6 +1588,7 @@ extern {
pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;

pub fn setpwent();
pub fn endpwent();
pub fn getpwent() -> *mut passwd;
pub fn setspent();
pub fn endspent();
Expand Down

0 comments on commit 56700d5

Please sign in to comment.