Skip to content

[breaking change] gettimeofday 2nd argument incorrect in some targets #1354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,6 @@ fn test_openbsd(target: &str) {
match name {
"execv" | "execve" | "execvp" | "execvpe" => true,

// typed 2nd arg
"gettimeofday" => true,

// Removed in OpenBSD 6.5
// https://marc.info/?l=openbsd-cvs&m=154723400730318
"mincore" => true,
Expand Down Expand Up @@ -1113,9 +1110,8 @@ fn test_dragonflybsd(target: &str) {

"getrlimit" | "getrlimit64" | // non-int in 1st arg
"setrlimit" | "setrlimit64" | // non-int in 1st arg
"prlimit" | "prlimit64" | // non-int in 2nd arg
// typed 2nd arg on linux
"gettimeofday" => true,
"prlimit" | "prlimit64" // non-int in 2nd arg
=> true,

_ => false,
}
Expand Down Expand Up @@ -1461,10 +1457,6 @@ fn test_android(target: &str) {
"execvpe" |
"fexecve" => true,

// typed 2nd arg on android
// FIXME: still necessary?
"gettimeofday" => true,

// not declared in newer android toolchains
// FIXME: still necessary?
"getdtablesize" => true,
Expand Down Expand Up @@ -1815,9 +1807,6 @@ fn test_freebsd(target: &str) {
"execvpe" |
"fexecve" => true,

// FIXME: for some reason, our signature is wrong
"gettimeofday" => true,

// The `uname` function in freebsd is now an inline wrapper that
// delegates to another, but the symbol still exists, so don't check
// the symbol.
Expand Down Expand Up @@ -2701,10 +2690,6 @@ fn test_linux(target: &str) {
// FIXME: is this necessary?
"sendmmsg" | "recvmmsg" if musl => true,

// typed 2nd arg on linux
// FIXME: is this necessary?
"gettimeofday" => true,

// FIXME: is this necessary?
"dladdr" if musl => true, // const-ness only added recently

Expand Down
2 changes: 2 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3045,6 +3045,8 @@ extern {

pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;

pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::c_void) -> ::c_int;
pub fn getutxent() -> *mut utmpx;
pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
Expand Down
3 changes: 2 additions & 1 deletion src/unix/bsd/freebsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,8 @@ extern {
-> ::c_int;

pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;

pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::timezone) -> ::c_int;
pub fn accept4(s: ::c_int, addr: *mut ::sockaddr,
addrlen: *mut ::socklen_t, flags: ::c_int) -> ::c_int;
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
Expand Down
3 changes: 3 additions & 0 deletions src/unix/bsd/netbsdlike/netbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,9 @@ extern {

#[link_name = "__lutimes50"]
pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
#[link_name = "__gettimeofday50"]
pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::c_void) -> ::c_int;
pub fn getnameinfo(sa: *const ::sockaddr,
salen: ::socklen_t,
host: *mut ::c_char,
Expand Down
2 changes: 2 additions & 0 deletions src/unix/bsd/netbsdlike/openbsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,8 @@ f! {
}

extern {
pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::timezone) -> ::c_int;
pub fn chflags(path: *const ::c_char, flags: ::c_uint) -> ::c_int;
pub fn fchflags(fd: ::c_int, flags: ::c_uint) -> ::c_int;
pub fn chflagsat(fd: ::c_int, path: *const ::c_char, flags: ::c_uint,
Expand Down
3 changes: 2 additions & 1 deletion src/unix/haiku/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,8 @@ extern {
errno: ::c_int) -> ::c_int>,
pglob: *mut ::glob_t) -> ::c_int;
pub fn globfree(pglob: *mut ::glob_t);

pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::c_void) -> ::c_int;
pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
-> ::c_int;

Expand Down
2 changes: 2 additions & 0 deletions src/unix/hermit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,8 @@ extern {

pub fn clock_gettime(clock_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;

pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::c_void) -> ::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;

Expand Down
11 changes: 0 additions & 11 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,17 +849,6 @@ extern {

pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;

#[cfg_attr(target_os = "netbsd", link_name = "__gettimeofday50")]
#[deprecated(
since="0.2.54",
note=
"The signature of this function is incorrect. \
If you are using it, please report that in the following issue \
so that we can evaluate the impact of fixing it: \
https://github.com/rust-lang/libc/issues/1338"
)]
pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::c_void) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__times13")]
pub fn times(buf: *mut ::tms) -> ::clock_t;

Expand Down
2 changes: 2 additions & 0 deletions src/unix/newlib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@ extern {
pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char,
envp: *const *const ::c_char)
-> ::c_int;
pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::c_void) -> ::c_int;
#[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")]
pub fn getgrgid_r(gid: ::gid_t,
grp: *mut ::group,
Expand Down
2 changes: 2 additions & 0 deletions src/unix/notbsd/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1924,6 +1924,8 @@ extern {
}

extern {
pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::timezone) -> ::c_int;
pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int)
-> ::c_int;
pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
Expand Down
3 changes: 3 additions & 0 deletions src/unix/notbsd/emscripten/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,9 @@ extern {
pub fn rand() -> ::c_int;
pub fn srand(seed: ::c_uint);

pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::c_void) -> ::c_int;

pub fn setpwent();
pub fn endpwent();
pub fn getpwent() -> *mut passwd;
Expand Down
2 changes: 2 additions & 0 deletions src/unix/notbsd/linux/musl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ pub const SO_PEEK_OFF: ::c_int = 42;
pub const SO_BUSY_POLL: ::c_int = 46;

extern {
pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::c_void) -> ::c_int;
pub fn ptrace(request: ::c_int, ...) -> ::c_long;
pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int;
pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int;
Expand Down
2 changes: 2 additions & 0 deletions src/unix/notbsd/linux/other/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,8 @@ extern {
pub fn endutxent();
pub fn getpt() -> ::c_int;
pub fn mallopt(param: ::c_int, value: ::c_int) -> ::c_int;
pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::timezone) -> ::c_int;
}

#[link(name = "util")]
Expand Down
1 change: 0 additions & 1 deletion src/unix/notbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,6 @@ extern {
pshared: ::c_int,
value: ::c_uint)
-> ::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
2 changes: 2 additions & 0 deletions src/unix/redox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,5 +584,7 @@ extern {
iovcnt: ::c_int) -> ::ssize_t;

// time.h
pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::timezone) -> ::c_int;
pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
}
2 changes: 2 additions & 0 deletions src/unix/solarish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1800,6 +1800,8 @@ extern {
pub fn rand() -> ::c_int;
pub fn srand(seed: ::c_uint);

pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::c_void) -> ::c_int;
pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
pub fn freeifaddrs(ifa: *mut ::ifaddrs);

Expand Down
2 changes: 2 additions & 0 deletions src/unix/uclibc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,8 @@ extern {
pub fn srand(seed: ::c_uint);

pub fn fdatasync(fd: ::c_int) -> ::c_int;
pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::timezone) -> ::c_int;
pub fn mincore(addr: *mut ::c_void, len: ::size_t,
vec: *mut ::c_uchar) -> ::c_int;
pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
Expand Down