Skip to content
Draft
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
98 changes: 21 additions & 77 deletions libc-test/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ fn test_apple(t: &Target) {
// FIXME(macos): bumped up on macOS/iOS/... 27, from 16 to 32
"AIO_LISTIO_MAX" => apple.unwrap() < (27, 0),

// In C, these are function pointers, but in Rust they are `size_t`.
"SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true,

_ => false,
}
});
Expand Down Expand Up @@ -353,9 +356,6 @@ fn test_apple(t: &Target) {
.then_some(ty.to_string())
});

// OSX calls this something else
cfg.rename_type(|ty| (ty == "sighandler_t").then_some("sig_t".to_string()));

cfg.rename_struct_ty(|ty| ty.ends_with("_t").then_some(ty.to_string()));
cfg.rename_union_ty(|ty| ty.ends_with("_t").then_some(ty.to_string()));

Expand Down Expand Up @@ -477,12 +477,6 @@ fn test_openbsd(t: &Target) {
"paths.h",
);

cfg.rename_type(|ty| match ty {
// FIXME(openbsd): https://github.com/rust-lang/libc/issues/1273
"sighandler_t" => Some("sig_t".to_string()),
_ => None,
});

cfg.rename_struct_ty(move |ty| {
match ty {
// Just pass all these through, no need for a "struct" prefix
Expand Down Expand Up @@ -651,9 +645,6 @@ fn test_cygwin(t: &Target) {
cfg.skip_signededness(move |c| match c {
n if n.starts_with("pthread") => true,

// For consistency with other platforms. Actually a function ptr.
"sighandler_t" => true,

_ => false,
});

Expand Down Expand Up @@ -1019,11 +1010,6 @@ fn test_solarish(t: &Target) {
headers!(cfg, "sys/lgrp_user_impl.h",);
}

cfg.skip_alias(move |ty| match ty.ident() {
"sighandler_t" => true,
_ => false,
});

cfg.rename_union_ty(|ty| match ty {
t if t.ends_with("_t") => Some(t.to_string()),
_ => None,
Expand Down Expand Up @@ -1052,7 +1038,7 @@ fn test_solarish(t: &Target) {
"DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK" | "DT_SOCK"
| "USRQUOTA" | "GRPQUOTA" | "PRIO_MIN" | "PRIO_MAX" => true,

// skip sighandler_t assignments
// In C, these are function pointers, but in Rust they are `size_t`.
"SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true,

"DT_UNKNOWN" => true,
Expand Down Expand Up @@ -1152,9 +1138,6 @@ fn test_solarish(t: &Target) {
// FIXME(solarish): unskip these for next major release
"setpriority" | "personality" => true,

// signal is defined in terms of sighandler_t, so ignore
"signal" => true,

// Currently missing
"cfmakeraw" | "cfsetspeed" => true,

Expand Down Expand Up @@ -1310,15 +1293,6 @@ fn test_netbsd(t: &Target) {
"paths.h",
);

cfg.rename_type(move |ty| {
match ty {
// OSX calls this something else
"sighandler_t" => Some("sig_t".to_string()),

_ => None,
}
});

cfg.rename_struct_ty(|ty| match ty {
// Just pass all these through, no need for a "struct" prefix
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" | "Elf64_Phdr" | "Elf32_Shdr"
Expand All @@ -1343,8 +1317,6 @@ fn test_netbsd(t: &Target) {

cfg.skip_alias(move |ty| {
match ty.ident() {
// FIXME(netbsd): sighandler_t is crazy across platforms
"sighandler_t" => true,
// Incomplete type in C
"cpuset_t" => true,
"eventfd_t" if netbsd9 => true,
Expand Down Expand Up @@ -1383,7 +1355,8 @@ fn test_netbsd(t: &Target) {

cfg.skip_const(move |constant| {
match constant.ident() {
"SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness
// In C, these are function pointers, but in Rust they are `size_t`.
"SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true,

// deprecated, obsolete upstream
"PT_LWPINFO" | "PL_EVENT_NONE" | "PL_EVENT_SIGNAL" | "PL_EVENT_SUSPENDED" => true,
Expand Down Expand Up @@ -1626,16 +1599,12 @@ fn test_dragonflybsd(t: &Target) {
}
});

cfg.rename_type(|ty| {
match ty {
// FIXME(dragonflybsd): OSX calls this something else
"sighandler_t" => Some("sig_t".to_string()),
"lwpstat" => Some("enum lwpstat".to_string()),
"procstat" => Some("enum procstat".to_string()),
"vm_map_t" => Some("struct vm_map *".to_string()),
"vm_map_entry_t" => Some("struct vm_map_entry *".to_string()),
_ => None,
}
cfg.rename_type(|ty| match ty {
"lwpstat" => Some("enum lwpstat".to_string()),
"procstat" => Some("enum procstat".to_string()),
"vm_map_t" => Some("struct vm_map *".to_string()),
"vm_map_entry_t" => Some("struct vm_map_entry *".to_string()),
_ => None,
});

cfg.rename_struct_field(move |struct_, field| {
Expand All @@ -1652,14 +1621,6 @@ fn test_dragonflybsd(t: &Target) {
}
});

cfg.skip_alias(move |ty| {
match ty.ident() {
// sighandler_t is crazy across platforms
"sighandler_t" => true,
_ => false,
}
});

cfg.skip_struct(move |struct_| {
match struct_.ident() {
// FIXME(dragonflybsd): These are tested as part of the linux_fcntl tests since
Expand Down Expand Up @@ -1694,7 +1655,8 @@ fn test_dragonflybsd(t: &Target) {

cfg.skip_const(move |constant| {
match constant.ident() {
"SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness
// In C, these are function pointers, but in Rust they are `size_t`.
"SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true,

// Kernel-only symbols in DragonFly headers.
"DTYPE_VNODE" | "DTYPE_SOCKET" | "DTYPE_PIPE" | "DTYPE_FIFO" | "DTYPE_KQUEUE"
Expand Down Expand Up @@ -1774,8 +1736,6 @@ fn test_dragonflybsd(t: &Target) {

cfg.skip_alias(move |ty| {
match ty.ident() {
// sighandler_t is crazy across platforms
"sighandler_t" => true,
// Same as FreeBSD: `kvm_t` is an opaque handle used through
// pointers, and libc does not bind the private `struct __kvm`.
"kvm_t" => true,
Expand Down Expand Up @@ -2646,12 +2606,6 @@ fn test_freebsd(t: &Target) {
"wchar.h",
);

cfg.rename_type(|ty| match ty {
// FIXME(freebsd): https://github.com/rust-lang/libc/issues/1273
"sighandler_t" => Some("sig_t".to_string()),
_ => None,
});

cfg.rename_struct_ty(|ty| {
match ty {
// Just pass all these through, no need for a "struct" prefix
Expand Down Expand Up @@ -2697,6 +2651,9 @@ fn test_freebsd(t: &Target) {

cfg.skip_const(move |constant| {
match constant.ident() {
// In C, these are function pointers, but in Rust they are `size_t`.
"SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true,

// These constants were introduced in FreeBSD 13:
"F_ADD_SEALS" | "F_GET_SEALS" | "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW"
| "F_SEAL_WRITE"
Expand Down Expand Up @@ -3609,10 +3566,6 @@ fn test_neutrino(t: &Target) {

cfg.skip_alias(move |ty| {
match ty.ident() {
// FIXME(sighandler): `sighandler_t` type is incorrect, see:
// https://github.com/rust-lang/libc/issues/1359
"sighandler_t" => true,

// Does not exist in Neutrino
"locale_t" => true,

Expand Down Expand Up @@ -3658,9 +3611,6 @@ fn test_neutrino(t: &Target) {
cfg.skip_fn(move |func| {
// skip those that are manually verified
match func.ident() {
// wrong signature
"signal" => true,

// wrong signature of callback ptr
"__cxa_atexit" => true,

Expand Down Expand Up @@ -5510,7 +5460,6 @@ fn test_haiku(t: &Target) {
// FIXME(haiku): locale_t does not exist on Haiku
"locale_t" => true,
// These cause errors, to be reviewed in the future
"sighandler_t" => true,
"pthread_t" => true,
"pthread_condattr_t" => true,
"pthread_mutexattr_t" => true,
Expand Down Expand Up @@ -5761,9 +5710,6 @@ fn test_aix(t: &Target) {
);

cfg.skip_alias(move |ty| match ty.ident() {
// AIX does not define type 'sighandler_t'.
"sighandler_t" => true,

// The alignment of 'double' does not agree between C and Rust for AIX.
// We are working on a resolution.
"c_double" => true,
Expand All @@ -5778,7 +5724,7 @@ fn test_aix(t: &Target) {
});

cfg.skip_const(move |constant| match constant.ident() {
// Skip 'sighandler_t' assignments.
// In C, these are function pointers, but in Rust they are `size_t`.
"SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true,

// _ALL_SOURCE defines ENOTEMPTY as an alias of EEXIST, but POSIX
Expand Down Expand Up @@ -5875,9 +5821,6 @@ fn test_aix(t: &Target) {

cfg.skip_fn(move |func| {
match func.ident() {
// 'sighandler_t' is not defined on AIX.
"signal" => true,

// The function is only available under macro _USE_IRS in 'netdb.h'.
"hstrerror" => true,

Expand Down Expand Up @@ -5993,8 +5936,9 @@ fn test_qurt(t: &Target) {
| "suseconds_t" | "useconds_t" | "timer_t" | "dev_t" | "ino_t" | "mode_t"
| "nlink_t" | "off_t" | "blkcnt_t" | "blksize_t" | "uid_t" | "gid_t" | "socklen_t"
| "sa_family_t" | "in_addr_t" | "in_port_t" | "fpos_t" | "clock_t" | "nfds_t"
| "va_list" | "c_schar" | "wchar_t" | "errno_t" | "rlim_t" | "speed_t" | "tcflag_t"
| "sighandler_t" => true,
| "va_list" | "c_schar" | "wchar_t" | "errno_t" | "rlim_t" | "speed_t" | "tcflag_t" => {
true
}
// fd_set is defined in mqueue.h as a struct, but libc has it as c_ulong
"fd_set" => true,
// sem_t is a struct in QuRT but an alias in libc
Expand Down
1 change: 0 additions & 1 deletion libc-test/semver/aix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2467,7 +2467,6 @@ sigdelset
sigemptyset
sigevent
sigfillset
sighandler_t
siginfo_t
sigismember
signal
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 @@ -4522,6 +4522,7 @@ shmget
shmid_ds
sigaltstack
sigevent
sighandler_t
siginfo_t
signalfd
signalfd_siginfo
Expand Down
1 change: 0 additions & 1 deletion libc-test/semver/nto.txt
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,6 @@ sigaddset
sigdelset
sigemptyset
sigfillset
sighandler_t
sigismember
signal
sigpending
Expand Down
1 change: 0 additions & 1 deletion libc-test/semver/qnx.txt
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,6 @@ sigaddset
sigdelset
sigemptyset
sigfillset
sighandler_t
sigismember
signal
sigpending
Expand Down
1 change: 0 additions & 1 deletion libc-test/semver/unix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,6 @@ sigaddset
sigdelset
sigemptyset
sigfillset
sighandler_t
sigismember
signal
sigpending
Expand Down
7 changes: 6 additions & 1 deletion src/unix/aix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ s! {
}

pub struct sigaction {
pub sa_sigaction: crate::sighandler_t, // FIXME(union): this field is actually a union
pub sa_sigaction: size_t, // FIXME(union): this field is actually a union
pub sa_mask: sigset_t,
pub sa_flags: c_int,
}
Expand Down Expand Up @@ -2863,6 +2863,11 @@ extern "C" {
}

extern "C" {
pub fn signal(
signum: c_int,
handler: Option<unsafe extern "C" fn(c_int)>,
) -> Option<unsafe extern "C" fn(c_int)>;

pub fn acct(filename: *mut c_char) -> c_int;
#[link_name = "_posix_aio_cancel"]
pub fn aio_cancel(fildes: c_int, aiocbp: *mut crate::aiocb) -> c_int;
Expand Down
1 change: 1 addition & 0 deletions src/unix/bsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ extern "C" {
pub fn devname(dev: crate::dev_t, mode_t: crate::mode_t) -> *mut c_char;

pub fn issetugid() -> c_int;
pub fn signal(signum: c_int, handler: sig_t) -> sig_t;
}

cfg_if! {
Expand Down
7 changes: 6 additions & 1 deletion src/unix/cygwin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ s! {
}

pub struct sigaction {
pub sa_sigaction: sighandler_t,
pub sa_sigaction: size_t,
pub sa_mask: sigset_t,
pub sa_flags: c_int,
}
Expand Down Expand Up @@ -1840,6 +1840,11 @@ const fn CMSG_ALIGN(len: usize) -> usize {
}

extern "C" {
pub fn signal(
signum: c_int,
handler: Option<unsafe extern "C" fn(c_int)>,
) -> Option<unsafe extern "C" fn(c_int)>;

pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int;
pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int;

Expand Down
7 changes: 6 additions & 1 deletion src/unix/haiku/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ s! {
}

pub struct sigaction {
pub sa_sigaction: crate::sighandler_t, //actually a union with sa_handler
pub sa_sigaction: size_t, //actually a union with sa_handler
pub sa_mask: crate::sigset_t,
pub sa_flags: c_int,
sa_userdata: *mut c_void,
Expand Down Expand Up @@ -1489,6 +1489,11 @@ f! {
}

extern "C" {
pub fn signal(
signum: c_int,
handler: Option<unsafe extern "C" fn(c_int)>,
) -> Option<unsafe extern "C" fn(c_int)>;

pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int;
pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int;
pub fn getpriority(which: c_int, who: id_t) -> c_int;
Expand Down
5 changes: 4 additions & 1 deletion src/unix/hurd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pub type wchar_t = c_int;
pub type wint_t = c_uint;
pub type gid_t = __gid_t;
pub type uid_t = __uid_t;
pub type sighandler_t = size_t;

cfg_if! {
if #[cfg(any(target_pointer_width = "64", gnu_file_offset_bits64))] {
Expand Down Expand Up @@ -451,7 +452,7 @@ s! {
}

pub struct sigaction {
pub sa_sigaction: crate::sighandler_t,
pub sa_sigaction: sighandler_t,
pub sa_mask: __sigset_t,
pub sa_flags: c_int,
}
Expand Down Expand Up @@ -3733,6 +3734,8 @@ extern "C" {

pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;

pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t;

pub fn __libc_current_sigrtmin() -> c_int;

pub fn __libc_current_sigrtmax() -> c_int;
Expand Down
Loading
Loading