Skip to content
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
23 changes: 23 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ fn test_apple(target: &str) {
"iconv.h",
"ifaddrs.h",
"langinfo.h",
"libgen.h",
"libproc.h",
"limits.h",
"locale.h",
Expand Down Expand Up @@ -417,6 +418,7 @@ fn test_openbsd(target: &str) {
"errno.h",
"execinfo.h",
"fcntl.h",
"libgen.h",
"limits.h",
"link.h",
"locale.h",
Expand Down Expand Up @@ -992,6 +994,7 @@ fn test_netbsd(target: &str) {
"elf.h",
"errno.h",
"fcntl.h",
"libgen.h",
"limits.h",
"link.h",
"locale.h",
Expand Down Expand Up @@ -1206,6 +1209,7 @@ fn test_dragonflybsd(target: &str) {
"ifaddrs.h",
"kvm.h",
"langinfo.h",
"libgen.h",
"limits.h",
"link.h",
"locale.h",
Expand Down Expand Up @@ -1505,6 +1509,7 @@ fn test_android(target: &str) {
"fcntl.h",
"grp.h",
"ifaddrs.h",
"libgen.h",
"limits.h",
"link.h",
"locale.h",
Expand Down Expand Up @@ -1866,6 +1871,7 @@ fn test_freebsd(target: &str) {
"iconv.h",
"ifaddrs.h",
"langinfo.h",
"libgen.h",
"libutil.h",
"limits.h",
"link.h",
Expand Down Expand Up @@ -2771,6 +2777,7 @@ fn test_linux(target: &str) {
"iconv.h",
"ifaddrs.h",
"langinfo.h",
"libgen.h",
"limits.h",
"link.h",
"locale.h",
Expand Down Expand Up @@ -3410,6 +3417,22 @@ fn test_linux(target: &str) {
// it can't be changed from struct.
"pthread_sigqueue" => true,

// There are two versions of basename(3) on Linux with glibc, see
//
// https://man7.org/linux/man-pages/man3/basename.3.html
//
// If libgen.h is included, then the POSIX version will be available;
// If _GNU_SOURCE is defined and string.h is included, then the GNU one
// will be used.
//
// libc exposes both of them, providing a prefix to differentiate between
// them.
//
// Because the name with prefix is not a valid symbol in C, we have to
// skip the tests.
"posix_basename" if gnu => true,
"gnu_basename" if gnu => true,

_ => false,
}
});
Expand Down
2 changes: 2 additions & 0 deletions libc-test/semver/android.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3548,3 +3548,5 @@ winsize
wmemchr
write
writev
dirname
basename
2 changes: 2 additions & 0 deletions libc-test/semver/apple.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2227,3 +2227,5 @@ wait4
waitid
xsw_usage
xucred
dirname
basename
2 changes: 2 additions & 0 deletions libc-test/semver/dragonfly.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1546,3 +1546,5 @@ wait4
waitid
xucred
eaccess
dirname
basename
4 changes: 3 additions & 1 deletion libc-test/semver/freebsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1925,4 +1925,6 @@ wait4
waitid
xallocx
xucred
eaccess
eaccess
dirname
basename
5 changes: 4 additions & 1 deletion libc-test/semver/linux-gnu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -657,4 +657,7 @@ eaccess
asctime_r
ctime_r
strftime
strptime
strptime
dirname
posix_basename
gnu_basename
4 changes: 3 additions & 1 deletion libc-test/semver/linux-musl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ euidaccess
eaccess
asctime_r
strftime
strptime
strptime
dirname
basename
2 changes: 2 additions & 0 deletions libc-test/semver/netbsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1533,3 +1533,5 @@ uucred
vm_size_t
wait4
waitid
dirname
basename
2 changes: 2 additions & 0 deletions libc-test/semver/openbsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1231,3 +1231,5 @@ utmp
utrace
wait4
xucred
dirname
basename
3 changes: 3 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5870,6 +5870,9 @@ extern "C" {

pub fn malloc_size(ptr: *const ::c_void) -> ::size_t;
pub fn malloc_good_size(size: ::size_t) -> ::size_t;

pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
}

pub unsafe fn mach_task_self() -> ::mach_port_t {
Expand Down
3 changes: 3 additions & 0 deletions src/unix/bsd/freebsdlike/dragonfly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,9 @@ extern "C" {

pub fn umtx_sleep(ptr: *const ::c_int, value: ::c_int, timeout: ::c_int) -> ::c_int;
pub fn umtx_wakeup(ptr: *const ::c_int, count: ::c_int) -> ::c_int;

pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
}

#[link(name = "rt")]
Expand Down
3 changes: 3 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,9 @@ extern "C" {
) -> ::c_int;

pub fn fdatasync(fd: ::c_int) -> ::c_int;

pub fn dirname(path: *const ::c_char) -> *mut ::c_char;
pub fn basename(path: *const ::c_char) -> *mut ::c_char;
}

cfg_if! {
Expand Down
3 changes: 3 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,9 @@ extern "C" {
pub fn setproctitle_fast(fmt: *const ::c_char, ...);
pub fn timingsafe_bcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;

pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
}

cfg_if! {
Expand Down
3 changes: 3 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,9 @@ extern "C" {
len: ::size_t,
flags: ::c_uint,
) -> ::ssize_t;

pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
}

#[link(name = "kvm")]
Expand Down
3 changes: 3 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,9 @@ extern "C" {
len: ::size_t,
flags: ::c_uint,
) -> ::ssize_t;

pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
}

#[link(name = "kvm")]
Expand Down
3 changes: 3 additions & 0 deletions src/unix/bsd/netbsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,9 @@ extern "C" {
pub fn gethostid() -> ::c_long;
pub fn sethostid(hostid: ::c_long) -> ::c_int;
pub fn ftok(path: *const ::c_char, id: ::c_int) -> ::key_t;

pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
}

cfg_if! {
Expand Down
3 changes: 3 additions & 0 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,9 @@ extern "C" {
pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void;

pub fn pthread_getcpuclockid(thread: ::pthread_t, clk_id: *mut ::clockid_t) -> ::c_int;

pub fn dirname(path: *const ::c_char) -> *mut ::c_char;
pub fn basename(path: *const ::c_char) -> *mut ::c_char;
}

cfg_if! {
Expand Down
8 changes: 8 additions & 0 deletions src/unix/linux_like/linux/gnu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,14 @@ extern "C" {
tm: *const ::tm,
) -> ::size_t;
pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char;

pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
/// POSIX version of `basename(3)`, defined in `libgen.h`.
#[link_name = "__xpg_basename"]
pub fn posix_basename(path: *mut ::c_char) -> *mut ::c_char;
/// GNU version of `basename(3)`, defined in `string.h`.
#[link_name = "basename"]
pub fn gnu_basename(path: *const ::c_char) -> *mut ::c_char;
}

extern "C" {
Expand Down
3 changes: 3 additions & 0 deletions src/unix/linux_like/linux/musl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,9 @@ extern "C" {
tm: *const ::tm,
) -> ::size_t;
pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char;

pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
}

cfg_if! {
Expand Down