diff --git a/build.rs b/build.rs index 070354f1e756..163735ac4cad 100644 --- a/build.rs +++ b/build.rs @@ -112,28 +112,37 @@ fn main() { && target_arch != "riscv32" && target_arch != "x86_64" { - match env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS") { - Ok(val) if val == "64" => { - set_cfg("gnu_file_offset_bits64"); - set_cfg("linux_time_bits64"); - set_cfg("gnu_time_bits64"); - } - Ok(val) if val != "32" => { - panic!("RUST_LIBC_UNSTABLE_GNU_TIME_BITS may only be set to '32' or '64'") - } - _ => { - match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") { - Ok(val) if val == "64" => { - set_cfg("gnu_file_offset_bits64"); - } - Ok(val) if val != "32" => { - panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'") - } - _ => {} - } - } + let defaultbits = "32".to_string(); + let (timebits, filebits) = match ( + env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS"), + env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), + ) { + (Ok(_), Ok(_)) => panic!("Do not set both RUST_LIBC_UNSTABLE_GNU_TIME_BITS and RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), + (Err(_), Err(_)) => (defaultbits.clone(), defaultbits.clone()), + (Ok(tb), Err(_)) if tb == "64" => (tb.clone(), tb.clone()), + (Ok(tb), Err(_)) if tb == "32" => (tb, defaultbits.clone()), + (Ok(_), Err(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_TIME_BITS, must be 32 or 64"), + (Err(_), Ok(fb)) if fb == "32" || fb == "64" => (defaultbits.clone(), fb), + (Err(_), Ok(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS, must be 32 or 64"), + }; + let valid_bits = ["32", "64"]; + assert!( + valid_bits.contains(&filebits.as_str()) && valid_bits.contains(&timebits.as_str()), + "Invalid value for RUST_LIBC_UNSTABLE_GNU_TIME_BITS or RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS, must be 32, 64 or unset" + ); + assert!( + !(filebits == "32" && timebits == "64"), + "RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS must be 64 or unset if RUST_LIBC_UNSTABLE_GNU_TIME_BITS is 64" + ); + if timebits == "64" { + set_cfg("linux_time_bits64"); + set_cfg("gnu_time_bits64"); + } + if filebits == "64" { + set_cfg("gnu_file_offset_bits64"); } } + // On CI: deny all warnings if libc_ci { set_cfg("libc_deny_warnings"); diff --git a/libc-test/build.rs b/libc-test/build.rs index 883023e26932..cb4e1fbe1d25 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -706,7 +706,7 @@ fn test_openbsd(target: &str) { fn test_cygwin(target: &str) { assert!(target.contains("cygwin")); - let mut cfg = ctest_old_cfg(); + let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); headers! { cfg: @@ -761,29 +761,27 @@ fn test_cygwin(target: &str) { "wchar.h", } - cfg.type_name(move |ty, is_struct, is_union| { + cfg.rename_type(|ty| match ty { + "Ioctl" => Some("int".to_string()), + _ => None, + }); + + cfg.rename_struct_ty(move |ty| { match ty { // Just pass all these through, no need for a "struct" prefix - "FILE" | "DIR" | "Dl_info" | "fd_set" => ty.to_string(), - - "Ioctl" => "int".to_string(), - - t if is_union => format!("union {t}"), - - t if t.ends_with("_t") => t.to_string(), + "FILE" | "DIR" | "Dl_info" | "fd_set" => Some(ty.to_string()), // sigval is a struct in Rust, but a union in C: - "sigval" => "union sigval".to_string(), + "sigval" => Some("union sigval".to_string()), - // put `struct` in front of all structs:. - t if is_struct => format!("struct {t}"), + t if t.ends_with("_t") => Some(t.to_string()), - t => t.to_string(), + _ => None, } }); - cfg.skip_const(move |name| { - match name { + cfg.skip_const(move |constant| { + match constant.ident() { // FIXME(cygwin): these constants do not exist on Cygwin "ARPOP_REQUEST" | "ARPOP_REPLY" | "ATF_COM" | "ATF_PERM" | "ATF_PUBL" | "ATF_USETRAILERS" => true, @@ -809,33 +807,33 @@ fn test_cygwin(target: &str) { _ => false, }); - cfg.skip_struct(move |ty| { - if ty.starts_with("__c_anonymous_") { + cfg.skip_struct(move |struct_| { + if struct_.ident().starts_with("__c_anonymous_") { return true; } false }); - cfg.field_name(move |struct_, field| { - match field { + cfg.rename_struct_field(move |struct_, field| { + match field.ident() { // Our stat *_nsec fields normally don't actually exist but are part // of a timeval struct - s if s.ends_with("_nsec") && struct_.starts_with("stat") => { - s.replace("e_nsec", ".tv_nsec") + s if s.ends_with("_nsec") && struct_.ident().starts_with("stat") => { + Some(s.replace("e_nsec", ".tv_nsec")) } // FIXME(cygwin): sigaction actually contains a union with two variants: // a sa_sigaction with type: (*)(int, struct __siginfo *, void *) // a sa_handler with type sig_t - "sa_sigaction" if struct_ == "sigaction" => "sa_handler".to_string(), + "sa_sigaction" if struct_.ident() == "sigaction" => Some("sa_handler".to_string()), - s => s.to_string(), + _ => None, } }); - cfg.skip_field(|struct_, field| { - match (struct_, field) { + cfg.skip_struct_field(|struct_, field| { + match (struct_.ident(), field.ident()) { // this is actually a union on linux, so we can't represent it well and // just insert some padding. ("ifreq", "ifr_ifru") => true, @@ -845,9 +843,9 @@ fn test_cygwin(target: &str) { } }); - cfg.skip_fn(move |name| { + cfg.skip_fn(move |func| { // skip those that are manually verified - match name { + match func.ident() { // There are two versions of the sterror_r function, see // // https://linux.die.net/man/3/strerror_r @@ -872,7 +870,7 @@ fn test_cygwin(target: &str) { } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); + ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } fn test_windows(target: &str) { @@ -1003,7 +1001,7 @@ fn test_windows(target: &str) { fn test_redox(target: &str) { assert!(target.contains("redox")); - let mut cfg = ctest_old_cfg(); + let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); headers! { @@ -1047,7 +1045,7 @@ fn test_redox(target: &str) { "wchar.h", } - cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); + ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } fn test_solarish(target: &str) { @@ -1558,7 +1556,7 @@ fn test_netbsd(target: &str) { fn test_dragonflybsd(target: &str) { assert!(target.contains("dragonfly")); - let mut cfg = ctest_old_cfg(); + let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); headers! { @@ -1652,58 +1650,58 @@ fn test_dragonflybsd(target: &str) { "iconv.h", } - cfg.type_name(move |ty, is_struct, is_union| { + cfg.rename_struct_ty(move |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" | "Elf64_Shdr" | "Elf32_Sym" | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" - | "Elf32_Chdr" | "Elf64_Chdr" => ty.to_string(), - - // FIXME(dragonflybsd): OSX calls this something else - "sighandler_t" => "sig_t".to_string(), - - t if is_union => format!("union {t}"), + | "Elf32_Chdr" | "Elf64_Chdr" => Some(ty.to_string()), - t if t.ends_with("_t") => t.to_string(), + t if t.ends_with("_t") => Some(t.to_string()), // sigval is a struct in Rust, but a union in C: - "sigval" => "union sigval".to_string(), + "sigval" => Some("union sigval".to_string()), - // put `struct` in front of all structs:. - t if is_struct => format!("struct {t}"), + _ => None, + } + }); - t => t.to_string(), + cfg.rename_type(|ty| { + match ty { + // FIXME(dragonflybsd): OSX calls this something else + "sighandler_t" => Some("sig_t".to_string()), + _ => None, } }); - cfg.field_name(move |struct_, field| { - match field { + cfg.rename_struct_field(move |struct_, field| { + match field.ident() { // Our stat *_nsec fields normally don't actually exist but are part // of a timeval struct - s if s.ends_with("_nsec") && struct_.starts_with("stat") => { - s.replace("e_nsec", ".tv_nsec") + s if s.ends_with("_nsec") && struct_.ident().starts_with("stat") => { + Some(s.replace("e_nsec", ".tv_nsec")) } - "u64" if struct_ == "epoll_event" => "data.u64".to_string(), + "u64" if struct_.ident() == "epoll_event" => Some("data.u64".to_string()), // Field is named `type` in C but that is a Rust keyword, // so these fields are translated to `type_` in the bindings. - "type_" if struct_ == "rtprio" => "type".to_string(), - s => s.to_string(), + "type_" if struct_.ident() == "rtprio" => Some("type".to_string()), + _ => None, } }); - cfg.skip_type(move |ty| { - match ty { + cfg.skip_alias(move |ty| { + match ty.ident() { // sighandler_t is crazy across platforms "sighandler_t" => true, _ => false, } }); - cfg.skip_struct(move |ty| { - if ty.starts_with("__c_anonymous_") { + cfg.skip_struct(move |struct_| { + if struct_.ident().starts_with("__c_anonymous_") { return true; } - match ty { + match struct_.ident() { // FIXME(dragonflybsd): These are tested as part of the linux_fcntl tests since // there are header conflicts when including them with all the other // structs. @@ -1728,8 +1726,8 @@ fn test_dragonflybsd(target: &str) { } }); - cfg.skip_const(move |name| { - match name { + cfg.skip_const(move |constant| { + match constant.ident() { "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness // weird signed extension or something like that? @@ -1744,12 +1742,11 @@ fn test_dragonflybsd(target: &str) { } }); - cfg.skip_fn(move |name| { + cfg.skip_fn(move |func| { // skip those that are manually verified - match name { + match func.ident() { // FIXME: https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" | "fexecve" => true, - "getrlimit" | "getrlimit64" | // non-int in 1st arg "setrlimit" | "setrlimit64" | // non-int in 1st arg "prlimit" | "prlimit64" // non-int in 2nd arg @@ -1759,26 +1756,26 @@ fn test_dragonflybsd(target: &str) { } }); - cfg.skip_field_type(move |struct_, field| { + cfg.skip_struct_field_type(move |struct_, field| { // This is a weird union, don't check the type. - (struct_ == "ifaddrs" && field == "ifa_ifu") || + (struct_.ident() == "ifaddrs" && field.ident() == "ifa_ifu") || // sighandler_t type is super weird - (struct_ == "sigaction" && field == "sa_sigaction") || + (struct_.ident() == "sigaction" && field.ident() == "sa_sigaction") || // sigval is actually a union, but we pretend it's a struct - (struct_ == "sigevent" && field == "sigev_value") || + (struct_.ident() == "sigevent" && field.ident() == "sigev_value") || // aio_buf is "volatile void*" and Rust doesn't understand volatile - (struct_ == "aiocb" && field == "aio_buf") + (struct_.ident() == "aiocb" && field.ident() == "aio_buf") }); - cfg.skip_field(move |struct_, field| { + cfg.skip_struct_field(move |struct_, field| { // this is actually a union on linux, so we can't represent it well and // just insert some padding. - (struct_ == "siginfo_t" && field == "_pad") || + (struct_.ident() == "siginfo_t" && field.ident() == "_pad") || // sigev_notify_thread_id is actually part of a sigev_un union - (struct_ == "sigevent" && field == "sigev_notify_thread_id") + (struct_.ident() == "sigevent" && field.ident() == "sigev_notify_thread_id") }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); + ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } fn test_wasi(target: &str) { @@ -3326,7 +3323,7 @@ fn test_emscripten(target: &str) { fn test_neutrino(target: &str) { assert!(target.contains("nto-qnx")); - let mut cfg = ctest_old_cfg(); + let mut cfg = ctest_cfg(); if target.ends_with("_iosock") { let qnx_target_val = env::var("QNX_TARGET") .unwrap_or_else(|_| "QNX_TARGET_not_set_please_source_qnxsdp".into()); @@ -3448,49 +3445,40 @@ fn test_neutrino(target: &str) { ) .unwrap(); - cfg.type_name(move |ty, is_struct, is_union| { + cfg.rename_struct_ty(move |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" | "Elf64_Shdr" | "Elf32_Sym" | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" | "Elf64_Chdr" | "aarch64_qreg_t" | "syspage_entry_info" - | "syspage_array_info" => ty.to_string(), - - "Ioctl" => "int".to_string(), - - t if is_union => format!("union {t}"), - - t if t.ends_with("_t") => t.to_string(), - - // put `struct` in front of all structs:. - t if is_struct => format!("struct {t}"), + | "syspage_array_info" => Some(ty.to_string()), - t => t.to_string(), + t if t.ends_with("_t") => Some(t.to_string()), + _ => None, } }); - cfg.field_name(move |_struct_, field| match field { - "type_" => "type".to_string(), + cfg.rename_type(|ty| match ty { + "Ioctl" => Some("int".to_string()), + _ => None, + }); - s => s.to_string(), + cfg.rename_struct_field(move |_struct_, field| match field.ident() { + "type_" => Some("type".to_string()), + _ => None, }); - cfg.volatile_item(|i| { - use ctest_old::VolatileItemKind::*; - match i { - // The following fields are volatie but since we cannot express that in - // Rust types, we have to explicitly tell the checker about it here: - StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => true, - StructField(ref n, ref f) if n == "qtime_entry" && f == "nsec_tod_adjust" => true, - StructField(ref n, ref f) if n == "qtime_entry" && f == "nsec" => true, - StructField(ref n, ref f) if n == "qtime_entry" && f == "nsec_stable" => true, - StructField(ref n, ref f) if n == "intrspin" && f == "value" => true, - _ => false, - } + cfg.volatile_struct_field(|s, f| match (s.ident(), f.ident()) { + ("aiocb", "aio_buf") => true, + ("qtime_entry", "nsec_tod_adjust") => true, + ("qtime_entry", "nsec") => true, + ("qtime_entry", "nsec_stable") => true, + ("intrspin", "value") => true, + _ => false, }); - cfg.skip_type(move |ty| { - match ty { + 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, @@ -3505,11 +3493,11 @@ fn test_neutrino(target: &str) { } }); - cfg.skip_struct(move |ty| { - if ty.starts_with("__c_anonymous_") { + cfg.skip_struct(move |struct_| { + if struct_.ident().starts_with("__c_anonymous_") { return true; } - match ty { + match struct_.ident() { "Elf64_Phdr" | "Elf32_Phdr" => true, // FIXME(union): This is actually a union, not a struct @@ -3522,8 +3510,8 @@ fn test_neutrino(target: &str) { } }); - cfg.skip_const(move |name| { - match name { + cfg.skip_const(move |constant| { + match constant.ident() { // These signal "functions" are actually integer values that are casted to a fn ptr // This causes the compiler to err because of "illegal cast of int to ptr". "SIG_DFL" => true, @@ -3534,9 +3522,9 @@ fn test_neutrino(target: &str) { } }); - cfg.skip_fn(move |name| { + cfg.skip_fn(move |func| { // skip those that are manually verified - match name { + match func.ident() { // FIXME: https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" | "execvpe" => true, @@ -3571,16 +3559,16 @@ fn test_neutrino(target: &str) { } }); - cfg.skip_field_type(move |struct_, field| { + cfg.skip_struct_field_type(move |struct_, field| { // sigval is actually a union, but we pretend it's a struct - struct_ == "sigevent" && field == "sigev_value" || + struct_.ident() == "sigevent" && field.ident() == "sigev_value" || // Anonymous structures - struct_ == "_idle_hook" && field == "time" + struct_.ident() == "_idle_hook" && field.ident() == "time" }); - cfg.skip_field(|struct_, field| { + cfg.skip_struct_field(|struct_, field| { matches!( - (struct_, field), + (struct_.ident(), field.ident()), ("__sched_param", "reserved") | ("sched_param", "reserved") | ("sigevent", "__padding1") // ensure alignment @@ -3591,15 +3579,15 @@ fn test_neutrino(target: &str) { ) }); - cfg.skip_static(move |name| name == "__dso_handle"); + cfg.skip_static(move |static_| static_.ident() == "__dso_handle"); - cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); + ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } fn test_vxworks(target: &str) { assert!(target.contains("vxworks")); - let mut cfg = ctest_old::TestGenerator::new(); + let mut cfg = ctest_cfg(); headers! { cfg: "vxWorks.h", "yvals.h", @@ -3660,7 +3648,7 @@ fn test_vxworks(target: &str) { "mqueue.h", } // FIXME(vxworks) - cfg.skip_const(move |name| match name { + cfg.skip_const(move |constant| match constant.ident() { // sighandler_t weirdness "SIG_DFL" | "SIG_ERR" | "SIG_IGN" // This is not defined in vxWorks @@ -3668,28 +3656,28 @@ fn test_vxworks(target: &str) { _ => false, }); // FIXME(vxworks) - cfg.skip_type(move |ty| match ty { + cfg.skip_alias(move |ty| match ty.ident() { "stat64" | "sighandler_t" | "off64_t" => true, _ => false, }); - cfg.skip_field_type(move |struct_, field| match (struct_, field) { - ("siginfo_t", "si_value") | ("stat", "st_size") | ("sigaction", "sa_u") => true, - _ => false, - }); + cfg.skip_struct_field_type( + move |struct_, field| match (struct_.ident(), field.ident()) { + ("siginfo_t", "si_value") | ("stat", "st_size") | ("sigaction", "sa_u") => true, + _ => false, + }, + ); cfg.skip_roundtrip(|_| false); - cfg.type_name(move |ty, is_struct, is_union| match ty { - "DIR" | "FILE" | "Dl_info" | "RTP_DESC" => ty.to_string(), - t if is_union => format!("union {t}"), - t if t.ends_with("_t") => t.to_string(), - t if is_struct => format!("struct {t}"), - t => t.to_string(), + cfg.rename_struct_ty(move |ty| match ty { + "DIR" | "FILE" | "Dl_info" | "RTP_DESC" => Some(ty.to_string()), + t if t.ends_with("_t") => Some(t.to_string()), + _ => None, }); // FIXME(vxworks) - cfg.skip_fn(move |name| match name { + cfg.skip_fn(move |func| match func.ident() { // sigval "sigqueue" | "_sigqueue" // sighandler_t @@ -3699,10 +3687,10 @@ fn test_vxworks(target: &str) { _ => false, }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); + ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn config_gnu_bits(target: &str, cfg: &mut ctest_old::TestGenerator) { +fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) { let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap_or_default(); if target.contains("gnu") && target.contains("linux") @@ -3710,29 +3698,36 @@ fn config_gnu_bits(target: &str, cfg: &mut ctest_old::TestGenerator) { && !target.contains("riscv32") && pointer_width == "32" { - match env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS") { - Ok(val) if val == "64" => { - cfg.define("_FILE_OFFSET_BITS", Some("64")); - cfg.define("_TIME_BITS", Some("64")); - cfg.cfg("gnu_file_offset_bits64", None); - cfg.cfg("linux_time_bits64", None); - cfg.cfg("gnu_time_bits64", None); - } - Ok(val) if val != "32" => { - panic!("RUST_LIBC_UNSTABLE_GNU_TIME_BITS may only be set to '32' or '64'") - } - _ => { - match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") { - Ok(val) if val == "64" => { - cfg.define("_FILE_OFFSET_BITS", Some("64")); - cfg.cfg("gnu_file_offset_bits64", None); - } - Ok(val) if val != "32" => { - panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'") - } - _ => {} - } - } + let defaultbits = "32".to_string(); + let (timebits, filebits) = match ( + env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS"), + env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), + ) { + (Ok(_), Ok(_)) => panic!("Do not set both RUST_LIBC_UNSTABLE_GNU_TIME_BITS and RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), + (Err(_), Err(_)) => (defaultbits.clone(), defaultbits.clone()), + (Ok(tb), Err(_)) if tb == "64" => (tb.clone(), tb.clone()), + (Ok(tb), Err(_)) if tb == "32" => (tb, defaultbits.clone()), + (Ok(_), Err(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_TIME_BITS, must be 32 or 64"), + (Err(_), Ok(fb)) if fb == "32" || fb == "64" => (defaultbits.clone(), fb), + (Err(_), Ok(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS, must be 32 or 64"), + }; + let valid_bits = ["32", "64"]; + assert!( + valid_bits.contains(&filebits.as_str()) && valid_bits.contains(&timebits.as_str()), + "Invalid value for RUST_LIBC_UNSTABLE_GNU_TIME_BITS or RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS, must be 32, 64 or unset" + ); + assert!( + !(filebits == "32" && timebits == "64"), + "RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS must be 64 or unset if RUST_LIBC_UNSTABLE_GNU_TIME_BITS is 64" + ); + if timebits == "64" { + cfg.define("_TIME_BITS", Some("64")); + cfg.cfg("linux_time_bits64", None); + cfg.cfg("gnu_time_bits64", None); + } + if filebits == "64" { + cfg.define("_FILE_OFFSET_BITS", Some("64")); + cfg.cfg("gnu_file_offset_bits64", None); } } } @@ -3772,15 +3767,15 @@ fn test_linux(target: &str) { let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); let old_musl = musl && !musl_v1_2_3; - let mut cfg = ctest_old_cfg(); + let mut cfg = ctest_cfg(); if musl_v1_2_3 { cfg.cfg("musl_v1_2_3", None); } - cfg.define("_GNU_SOURCE", None); - // This macro re-defines fscanf,scanf,sscanf to link to the symbols that are - // deprecated since glibc >= 2.29. This allows Rust binaries to link against - // glibc versions older than 2.29. - cfg.define("__GLIBC_USE_DEPRECATED_SCANF", None); + cfg.define("_GNU_SOURCE", None) + // This macro re-defines fscanf,scanf,sscanf to link to the symbols that are + // deprecated since glibc >= 2.29. This allows Rust binaries to link against + // glibc versions older than 2.29. + .define("__GLIBC_USE_DEPRECATED_SCANF", None); config_gnu_bits(target, &mut cfg); @@ -3982,41 +3977,50 @@ fn test_linux(target: &str) { [!uclibc]: "aio.h", } - cfg.type_name(move |ty, is_struct, is_union| { - 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" - | "Elf64_Shdr" | "Elf32_Sym" | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" - | "Elf32_Chdr" | "Elf64_Chdr" => ty.to_string(), - - "Ioctl" if gnu => "unsigned long".to_string(), - "Ioctl" => "int".to_string(), + // Just pass all these through, no need for a "struct" prefix + let typedef_structs = [ + "FILE", + "fd_set", + "Dl_info", + "DIR", + "Elf32_Phdr", + "Elf64_Phdr", + "Elf32_Shdr", + "Elf64_Shdr", + "Elf32_Sym", + "Elf64_Sym", + "Elf32_Ehdr", + "Elf64_Ehdr", + "Elf32_Chdr", + "Elf64_Chdr", + ]; + // typedefs don't need any keywords + cfg.rename_struct_ty(move |ty| typedef_structs.contains(&ty).then_some(ty.to_string())) + .rename_struct_ty(|ty| ty.ends_with("_t").then_some(ty.to_string())) + .rename_union_ty(|ty| ty.ends_with("_t").then_some(ty.to_string())); + cfg.rename_type(move |ty| { + match ty { + "Ioctl" if gnu => Some("unsigned long".to_string()), + "Ioctl" => Some("int".to_string()), // LFS64 types have been removed in musl 1.2.4+ - "off64_t" if musl => "off_t".to_string(), - - // typedefs don't need any keywords - t if t.ends_with("_t") => t.to_string(), - // put `struct` in front of all structs:. - t if is_struct => format!("struct {t}"), - // put `union` in front of all unions: - t if is_union => format!("union {t}"), - - t => t.to_string(), + "off64_t" if musl => Some("off_t".to_string()), + _ => None, } }); - cfg.field_name(move |struct_, field| { - match field { + cfg.rename_struct_field(|struct_, field| { + let struct_ = struct_.ident(); + match field.ident() { // Our stat *_nsec fields normally don't actually exist but are part // of a timeval struct s if s.ends_with("_nsec") && struct_.starts_with("stat") => { - s.replace("e_nsec", ".tv_nsec") + Some(s.replace("e_nsec", ".tv_nsec")) } // FIXME(linux): epoll_event.data is actually a union in C, but in Rust // it is only a u64 because we only expose one field // http://man7.org/linux/man-pages/man2/epoll_wait.2.html - "u64" if struct_ == "epoll_event" => "data.u64".to_string(), + "u64" if struct_ == "epoll_event" => Some("data.u64".to_string()), // The following structs have a field called `type` in C, // but `type` is a Rust keyword, so these fields are translated // to `type_` in Rust. @@ -4025,14 +4029,15 @@ fn test_linux(target: &str) { || struct_ == "input_mask" || struct_ == "ff_effect" => { - "type".to_string() + Some("type".to_string()) } - s => s.to_string(), + _ => None, } }); - cfg.skip_type(move |ty| { + cfg.skip_alias(move |alias| { + let ty = alias.ident(); // FIXME(musl): very recent additions to musl, not yet released. // also apparently some glibc versions if ty == "Elf32_Relr" || ty == "Elf64_Relr" { @@ -4075,10 +4080,12 @@ fn test_linux(target: &str) { } }); - cfg.skip_struct(move |ty| { - if ty.starts_with("__c_anonymous_") { - return true; - } + // Skip structs and enums that are unnamed in C. + cfg.skip_union(move |union_| union_.ident().starts_with("__c_anonymous_")); + cfg.skip_struct(move |struct_| struct_.ident().starts_with("__c_anonymous_")); + + cfg.skip_struct(move |struct_| { + let ty = struct_.ident(); // FIXME(linux): CI has old headers if ty == "ptp_sys_offset_extended" { @@ -4254,7 +4261,8 @@ fn test_linux(target: &str) { } }); - cfg.skip_const(move |name| { + cfg.skip_const(move |constant| { + let name = constant.ident(); if !gnu { // Skip definitions from the kernel on non-glibc Linux targets. // They're libc-independent, so we only need to check them on one @@ -4753,7 +4761,19 @@ fn test_linux(target: &str) { } }); - cfg.skip_fn(move |name| { + let c_enums = [ + "tpacket_versions", + "proc_cn_mcast_op", + "proc_cn_event", + "pid_type", + ]; + cfg.alias_is_c_enum(move |e| c_enums.contains(&e)); + + // FIXME(libc): `pid_type` and `proc_cn_event` is hidden. + cfg.skip_c_enum(|e| e == "pid_type" || e == "proc_cn_event"); + + cfg.skip_fn(move |function| { + let name = function.ident(); // skip those that are manually verified match name { // FIXME: https://github.com/rust-lang/libc/issues/1272 @@ -4865,42 +4885,38 @@ fn test_linux(target: &str) { } }); - cfg.skip_field_type(move |struct_, field| { + cfg.skip_struct_field_type(move |union_, field| { + let union_ = union_.ident(); + let field = field.ident(); // This is a weird union, don't check the type. - (struct_ == "ifaddrs" && field == "ifa_ifu") || + (union_ == "ifaddrs" && field == "ifa_ifu") || // sighandler_t type is super weird - (struct_ == "sigaction" && field == "sa_sigaction") || + (union_ == "sigaction" && field == "sa_sigaction") || // __timeval type is a patch which doesn't exist in glibc - (struct_ == "utmpx" && field == "ut_tv") || + (union_ == "utmpx" && field == "ut_tv") || // sigval is actually a union, but we pretend it's a struct - (struct_ == "sigevent" && field == "sigev_value") || + (union_ == "sigevent" && field == "sigev_value") || // this one is an anonymous union - (struct_ == "ff_effect" && field == "u") || + (union_ == "ff_effect" && field == "u") || // `__exit_status` type is a patch which is absent in musl - (struct_ == "utmpx" && field == "ut_exit" && musl) || + (union_ == "utmpx" && field == "ut_exit" && musl) || // `can_addr` is an anonymous union - (struct_ == "sockaddr_can" && field == "can_addr") || + (union_ == "sockaddr_can" && field == "can_addr") || // `anonymous_1` is an anonymous union - (struct_ == "ptp_perout_request" && field == "anonymous_1") || + (union_ == "ptp_perout_request" && field == "anonymous_1") || // `anonymous_2` is an anonymous union - (struct_ == "ptp_perout_request" && field == "anonymous_2") || + (union_ == "ptp_perout_request" && field == "anonymous_2") || // FIXME(linux): `adjust_phase` requires >= 5.7 kernel headers // FIXME(linux): `max_phase_adj` requires >= 5.19 kernel headers // the rsv field shrunk when those fields got added, so is omitted too - (struct_ == "ptp_clock_caps" && (loongarch64 || sparc64) && (["adjust_phase", "max_phase_adj", "rsv"].contains(&field))) + (union_ == "ptp_clock_caps" && (loongarch64 || sparc64) && (["adjust_phase", "max_phase_adj", "rsv"].contains(&field))) }); - cfg.volatile_item(|i| { - use ctest_old::VolatileItemKind::*; - match i { - // aio_buf is a volatile void** but since we cannot express that in - // Rust types, we have to explicitly tell the checker about it here: - StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => true, - _ => false, - } - }); + cfg.volatile_struct_field(|s, f| s.ident() == "aiocb" && f.ident() == "aio_buf"); - cfg.skip_field(move |struct_, field| { + cfg.skip_struct_field(move |struct_, field| { + let struct_ = struct_.ident(); + let field = field.ident(); // this is actually a union on linux, so we can't represent it well and // just insert some padding. (struct_ == "siginfo_t" && field == "_pad") || @@ -5020,7 +5036,7 @@ fn test_linux(target: &str) { _ => false, }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); + ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); test_linux_like_apis(target); } @@ -5036,144 +5052,138 @@ fn test_linux_like_apis(target: &str) { let android = target.contains("android"); assert!(linux || android || emscripten); + let mut cfg = ctest_cfg(); if linux || android || emscripten { // test strerror_r from the `string.h` header - let mut cfg = ctest_old_cfg(); config_gnu_bits(target, &mut cfg); - cfg.skip_type(|_| true).skip_static(|_| true); - headers! { cfg: "string.h" } - cfg.skip_fn(|f| match f { - "strerror_r" => false, - _ => true, - }) - .skip_const(|_| true) - .skip_struct(|_| true); - cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_strerror_r.rs"); + + cfg.skip_alias(|_| true) + .skip_static(|_| true) + .skip_const(|_| true) + .skip_struct(|_| true) + .skip_union(|_| true) + .skip_fn(|function| function.ident() != "strerror_r"); + + ctest::generate_test(&mut cfg, "../src/lib.rs", "linux_strerror_r.rs").unwrap(); } + let mut cfg = ctest_cfg(); if linux || android || emscripten { // test fcntl - see: // http://man7.org/linux/man-pages/man2/fcntl.2.html - let mut cfg = ctest_old_cfg(); - config_gnu_bits(target, &mut cfg); + let fnctl_constants = [ + "F_CANCELLK", + "F_ADD_SEALS", + "F_GET_SEALS", + "F_SEAL_SEAL", + "F_SEAL_SHRINK", + "F_SEAL_GROW", + "F_SEAL_WRITE", + ]; + cfg.skip_alias(|_| true) + .skip_static(|_| true) + .skip_struct(|_| true) + .skip_union(|_| true) + .skip_fn(|_| true) + .skip_const(move |constant| !fnctl_constants.contains(&constant.ident())); + config_gnu_bits(target, &mut cfg); if musl { cfg.header("fcntl.h"); } else { cfg.header("linux/fcntl.h"); } - cfg.skip_type(|_| true) - .skip_static(|_| true) - .skip_struct(|_| true) - .skip_fn(|_| true) - .skip_const(move |name| match name { - // test fcntl constants: - "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" | "F_SEAL_SEAL" | "F_SEAL_SHRINK" - | "F_SEAL_GROW" | "F_SEAL_WRITE" => false, - _ => true, - }) - .type_name(move |ty, is_struct, is_union| match ty { - t if is_struct => format!("struct {t}"), - t if is_union => format!("union {t}"), - t => t.to_string(), - }); - - cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_fcntl.rs"); + ctest::generate_test(&mut cfg, "../src/lib.rs", "linux_fcntl.rs").unwrap(); } + let mut cfg = ctest_cfg(); if (linux && !wali) || android { // test termios - let mut cfg = ctest_old_cfg(); config_gnu_bits(target, &mut cfg); - cfg.header("asm/termbits.h"); - cfg.header("linux/termios.h"); - cfg.skip_type(|_| true) + + let termios_constants = [ + "BOTHER", "IBSHIFT", "TCGETS2", "TCSETS2", "TCSETSW2", "TCSETSF2", + ]; + cfg.header("asm/termbits.h") + .header("linux/termios.h") + .skip_alias(|_| true) .skip_static(|_| true) .skip_fn(|_| true) - .skip_const(|c| match c { - "BOTHER" | "IBSHIFT" => false, - "TCGETS2" | "TCSETS2" | "TCSETSW2" | "TCSETSF2" => false, - _ => true, - }) - .skip_struct(|s| s != "termios2") - .type_name(move |ty, is_struct, is_union| match ty { - "Ioctl" if gnu => "unsigned long".to_string(), - "Ioctl" => "int".to_string(), - t if is_struct => format!("struct {t}"), - t if is_union => format!("union {t}"), - t => t.to_string(), + .skip_const(move |constant| !termios_constants.contains(&constant.ident())) + .skip_union(|_| true) + .skip_struct(|s| s.ident() != "termios2") + .rename_type(move |ty| match ty { + "Ioctl" if gnu => Some("unsigned long".to_string()), + "Ioctl" => Some("int".to_string()), + _ => None, }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_termios.rs"); + + ctest::generate_test(&mut cfg, "../src/lib.rs", "linux_termios.rs").unwrap(); } + let mut cfg = ctest_cfg(); if linux || android { // test IPV6_ constants: - let mut cfg = ctest_old_cfg(); + let ipv6_constants = [ + "IPV6_FLOWINFO", + "IPV6_FLOWLABEL_MGR", + "IPV6_FLOWINFO_SEND", + "IPV6_FLOWINFO_FLOWLABEL", + "IPV6_FLOWINFO_PRIORITY", + ]; + cfg.skip_alias(|_| true) + .skip_static(|_| true) + .skip_fn(|_| true) + .skip_struct(|_| true) + .skip_union(|_| true) + .skip_const(move |constant| !ipv6_constants.contains(&constant.ident())); + config_gnu_bits(target, &mut cfg); headers! { cfg: "linux/in6.h" } - cfg.skip_type(|_| true) - .skip_static(|_| true) - .skip_fn(|_| true) - .skip_const(|_| true) - .skip_struct(|_| true) - .skip_const(move |name| match name { - "IPV6_FLOWINFO" - | "IPV6_FLOWLABEL_MGR" - | "IPV6_FLOWINFO_SEND" - | "IPV6_FLOWINFO_FLOWLABEL" - | "IPV6_FLOWINFO_PRIORITY" => false, - _ => true, - }) - .type_name(move |ty, is_struct, is_union| match ty { - t if is_struct => format!("struct {t}"), - t if is_union => format!("union {t}"), - t => t.to_string(), - }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_ipv6.rs"); + + ctest::generate_test(&mut cfg, "../src/lib.rs", "linux_ipv6.rs").unwrap(); } + let mut cfg = ctest_cfg(); if (linux && !wali) || android { // Test Elf64_Phdr and Elf32_Phdr // These types have a field called `p_type`, but including // "resolve.h" defines a `p_type` macro that expands to `__p_type` // making the tests for these fails when both are included. - let mut cfg = ctest_old_cfg(); - config_gnu_bits(target, &mut cfg); - cfg.header("elf.h"); - cfg.skip_fn(|_| true) + let elf_structs = ["Elf64_Phdr", "Elf32_Phdr"]; + cfg.header("elf.h") + .skip_fn(|_| true) .skip_static(|_| true) .skip_const(|_| true) - .type_name(move |ty, _is_struct, _is_union| ty.to_string()) - .skip_struct(move |ty| match ty { - "Elf64_Phdr" | "Elf32_Phdr" => false, - _ => true, - }) - .skip_type(move |ty| match ty { - "Elf64_Phdr" | "Elf32_Phdr" => false, - _ => true, - }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_elf.rs"); + .skip_union(|_| true) + .rename_struct_ty(move |ty| Some(ty.to_string())) + .skip_struct(move |struct_| !elf_structs.contains(&struct_.ident())) + .skip_alias(move |alias| !elf_structs.contains(&alias.ident())); + + config_gnu_bits(target, &mut cfg); + + ctest::generate_test(&mut cfg, "../src/lib.rs", "linux_elf.rs").unwrap(); } if (linux && !wali) || android { // Test `ARPHRD_CAN`. - let mut cfg = ctest_old_cfg(); + let mut cfg = ctest_cfg(); config_gnu_bits(target, &mut cfg); - cfg.header("linux/if_arp.h"); - cfg.skip_fn(|_| true) + cfg.header("linux/if_arp.h") + .skip_fn(|_| true) .skip_static(|_| true) - .skip_const(move |name| match name { - "ARPHRD_CAN" => false, - _ => true, - }) + .skip_union(|_| true) .skip_struct(|_| true) - .skip_type(|_| true); - cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_if_arp.rs"); + .skip_union(|_| true) + .skip_alias(|_| true) + .skip_const(move |constant| constant.ident() != "ARPHRD_CAN"); + + ctest::generate_test(&mut cfg, "../src/lib.rs", "linux_if_arp.rs").unwrap(); } } @@ -5547,7 +5557,7 @@ fn test_aix(target: &str) { // ctest generates arguments supported only by clang, so make sure to // run with CC=clang. While debugging, "CFLAGS=-ferror-limit=" // is useful to get more error output. - let mut cfg = ctest_old_cfg(); + let mut cfg = ctest_cfg(); cfg.define("_THREAD_SAFE", None); // Avoid the error for definitions such as '{0, 0, 0, 1}' for @@ -5641,7 +5651,7 @@ fn test_aix(target: &str) { "wchar.h", } - cfg.skip_type(move |ty| match ty { + cfg.skip_alias(move |ty| match ty.ident() { // AIX does not define type 'sighandler_t'. "sighandler_t" => true, @@ -5652,21 +5662,18 @@ fn test_aix(target: &str) { _ => false, }); - cfg.type_name(move |ty, is_struct, is_union| match ty { - "DIR" => ty.to_string(), - "FILE" => ty.to_string(), - "ACTION" => ty.to_string(), + cfg.rename_struct_ty(move |ty| match ty { + "DIR" | "FILE" | "ACTION" => Some(ty.to_string()), // 'sigval' is a struct in Rust, but a union in C. - "sigval" => format!("union sigval"), + "sigval" => Some(format!("union sigval")), - t if t.ends_with("_t") => t.to_string(), - t if is_struct => format!("struct {}", t), - t if is_union => format!("union {}", t), - t => t.to_string(), + t if t.ends_with("_t") => Some(t.to_string()), + + _ => None, }); - cfg.skip_const(move |name| match name { + cfg.skip_const(move |constant| match constant.ident() { // Skip 'sighandler_t' assignments. "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, @@ -5694,8 +5701,8 @@ fn test_aix(target: &str) { _ => false, }); - cfg.skip_struct(move |ty| { - match ty { + cfg.skip_struct(move |struct_| { + match struct_.ident() { // FIXME(union): actually a union. "sigval" => true, @@ -5723,8 +5730,8 @@ fn test_aix(target: &str) { } }); - cfg.skip_field_type(move |struct_, field| { - match (struct_, field) { + cfg.skip_struct_field_type(move |struct_, field| { + match (struct_.ident(), field.ident()) { // AIX does not define 'sighandler_t'. ("sigaction", "sa_sigaction") => true, @@ -5755,20 +5762,20 @@ fn test_aix(target: &str) { } }); - cfg.skip_field(move |s, field| { - match s { + cfg.skip_struct_field(move |s, field| { + match s.ident() { // The field 'u' is actually a unnamed union in the AIX header. - "poll_ctl_ext" if field == "u" => true, + "poll_ctl_ext" if field.ident() == "u" => true, // The field 'data' is actually a unnamed union in the AIX header. - "pollfd_ext" if field == "data" => true, + "pollfd_ext" if field.ident() == "data" => true, _ => false, } }); - cfg.skip_fn(move |name| { - match name { + cfg.skip_fn(move |func| { + match func.ident() { // 'sighandler_t' is not defined on AIX. "signal" => true, @@ -5831,17 +5838,13 @@ fn test_aix(target: &str) { } }); - cfg.volatile_item(|i| { - use ctest_old::VolatileItemKind::*; - match i { - // 'aio_buf' is of type 'volatile void**' but since we cannot - // express that in Rust types, we have to explicitly tell the - // checker about it here. - StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => true, - - _ => false, - } + cfg.volatile_struct_field(|s, f| match (s.ident(), f.ident()) { + // 'aio_buf' is of type 'volatile void**' but since we cannot + // express that in Rust types, we have to explicitly tell the + // checker about it here. + ("aiocb", "aio_buf") => true, + _ => false, }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); + ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index b13911b0f2a6..ae30adbee794 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2085,11 +2085,14 @@ O_TMPFILE PACKET_ADD_MEMBERSHIP PACKET_AUXDATA PACKET_BROADCAST +PACKET_COPY_THRESH PACKET_DROP_MEMBERSHIP PACKET_FANOUT PACKET_FANOUT_CBPF PACKET_FANOUT_CPU +PACKET_FANOUT_DATA PACKET_FANOUT_FLAG_DEFRAG +PACKET_FANOUT_FLAG_IGNORE_OUTGOING PACKET_FANOUT_FLAG_ROLLOVER PACKET_FANOUT_FLAG_UNIQUEID PACKET_FANOUT_HASH @@ -2097,6 +2100,7 @@ PACKET_FANOUT_LB PACKET_FANOUT_QM PACKET_FANOUT_RND PACKET_FANOUT_ROLLOVER +PACKET_HDRLEN PACKET_HOST PACKET_IGNORE_OUTGOING PACKET_KERNEL @@ -2107,15 +2111,22 @@ PACKET_MR_MULTICAST PACKET_MR_PROMISC PACKET_MR_UNICAST PACKET_MULTICAST +PACKET_ORIGDEV PACKET_OTHERHOST PACKET_OUTGOING PACKET_QDISC_BYPASS +PACKET_RECV_OUTPUT PACKET_RESERVE +PACKET_ROLLOVER_STATS PACKET_RX_RING PACKET_STATISTICS PACKET_TIMESTAMP +PACKET_TX_HAS_OFF +PACKET_TX_TIMESTAMP PACKET_USER PACKET_VERSION +PACKET_VNET_HDR +PACKET_VNET_HDR_SZ PENDIN PF_ALG PF_APPLETALK diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index 790f2ac76b39..3e09870a7a76 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -4,6 +4,7 @@ ATF_COM ATF_PERM ATF_PUBL ATF_USETRAILERS +AT_FDCWD B1000000 B1152000 B1500000 @@ -131,14 +132,32 @@ OLCUC O_ASYNC O_EXLOCK O_FSYNC +O_NDELAY O_NOCTTY O_PATH O_SHLOCK O_SYMLINK PTHREAD_STACK_MIN +RLIMIT_AS +RLIMIT_CORE +RLIMIT_CPU +RLIMIT_DATA +RLIMIT_FSIZE +RLIMIT_LOCKS +RLIMIT_MEMLOCK +RLIMIT_MSGQUEUE +RLIMIT_NICE +RLIMIT_NLIMITS +RLIMIT_NOFILE +RLIMIT_NPROC +RLIMIT_RSS +RLIMIT_RTPRIO +RLIMIT_SIGPENDING +RLIMIT_STACK RLIM_INFINITY RLIM_SAVED_CUR RLIM_SAVED_MAX +RUSAGE_BOTH RUSAGE_CHILDREN RUSAGE_SELF RUSAGE_THREAD @@ -180,6 +199,42 @@ VWERASE WEXITED WNOWAIT WSTOPPED +_CS_PATH +_CS_POSIX_V5_WIDTH_RESTRICTED_ENVS +_CS_POSIX_V6_ILP32_OFF32_CFLAGS +_CS_POSIX_V6_ILP32_OFF32_LDFLAGS +_CS_POSIX_V6_ILP32_OFF32_LIBS +_CS_POSIX_V6_ILP32_OFF32_LINTFLAGS +_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS +_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS +_CS_POSIX_V6_ILP32_OFFBIG_LIBS +_CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS +_CS_POSIX_V6_LP64_OFF64_CFLAGS +_CS_POSIX_V6_LP64_OFF64_LDFLAGS +_CS_POSIX_V6_LP64_OFF64_LIBS +_CS_POSIX_V6_LP64_OFF64_LINTFLAGS +_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS +_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS +_CS_POSIX_V6_LPBIG_OFFBIG_LIBS +_CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS +_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS +_CS_POSIX_V7_ILP32_OFF32_CFLAGS +_CS_POSIX_V7_ILP32_OFF32_LDFLAGS +_CS_POSIX_V7_ILP32_OFF32_LIBS +_CS_POSIX_V7_ILP32_OFF32_LINTFLAGS +_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS +_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS +_CS_POSIX_V7_ILP32_OFFBIG_LIBS +_CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS +_CS_POSIX_V7_LP64_OFF64_CFLAGS +_CS_POSIX_V7_LP64_OFF64_LDFLAGS +_CS_POSIX_V7_LP64_OFF64_LIBS +_CS_POSIX_V7_LP64_OFF64_LINTFLAGS +_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS +_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS +_CS_POSIX_V7_LPBIG_OFFBIG_LIBS +_CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS +_CS_POSIX_V7_WIDTH_RESTRICTED_ENVS _IOFBF _IOLBF _IONBF @@ -247,6 +302,7 @@ pipe2 pthread_condattr_setclock qsort reallocarray +rlim_t setgrent setpwent setrlimit diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index b41f7b4fe822..2d236327ea4e 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -3597,17 +3597,27 @@ pub const PACKET_KERNEL: c_uchar = 7; pub const PACKET_ADD_MEMBERSHIP: c_int = 1; pub const PACKET_DROP_MEMBERSHIP: c_int = 2; +pub const PACKET_RECV_OUTPUT: c_int = 3; pub const PACKET_RX_RING: c_int = 5; pub const PACKET_STATISTICS: c_int = 6; +pub const PACKET_COPY_THRESH: c_int = 7; pub const PACKET_AUXDATA: c_int = 8; +pub const PACKET_ORIGDEV: c_int = 9; pub const PACKET_VERSION: c_int = 10; +pub const PACKET_HDRLEN: c_int = 11; pub const PACKET_RESERVE: c_int = 12; pub const PACKET_TX_RING: c_int = 13; pub const PACKET_LOSS: c_int = 14; +pub const PACKET_VNET_HDR: c_int = 15; +pub const PACKET_TX_TIMESTAMP: c_int = 16; pub const PACKET_TIMESTAMP: c_int = 17; pub const PACKET_FANOUT: c_int = 18; +pub const PACKET_TX_HAS_OFF: c_int = 19; pub const PACKET_QDISC_BYPASS: c_int = 20; +pub const PACKET_ROLLOVER_STATS: c_int = 21; +pub const PACKET_FANOUT_DATA: c_int = 22; pub const PACKET_IGNORE_OUTGOING: c_int = 23; +pub const PACKET_VNET_HDR_SZ: c_int = 24; pub const PACKET_FANOUT_HASH: c_uint = 0; pub const PACKET_FANOUT_LB: c_uint = 1; @@ -3619,6 +3629,7 @@ pub const PACKET_FANOUT_CBPF: c_uint = 6; pub const PACKET_FANOUT_EBPF: c_uint = 7; pub const PACKET_FANOUT_FLAG_ROLLOVER: c_uint = 0x1000; pub const PACKET_FANOUT_FLAG_UNIQUEID: c_uint = 0x2000; +pub const PACKET_FANOUT_FLAG_IGNORE_OUTGOING: c_uint = 0x4000; pub const PACKET_FANOUT_FLAG_DEFRAG: c_uint = 0x8000; pub const PACKET_MR_MULTICAST: c_int = 0; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 308e08b7e911..3239ef4b5a1e 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -352,6 +352,8 @@ pub const F_LOCK: c_int = 1; pub const F_TLOCK: c_int = 2; pub const F_TEST: c_int = 3; +pub const AT_FDCWD: c_int = -100; + // FIXME(redox): relibc { pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); // } @@ -517,6 +519,7 @@ pub const O_WRONLY: c_int = 0x0002_0000; pub const O_RDWR: c_int = 0x0003_0000; pub const O_ACCMODE: c_int = 0x0003_0000; pub const O_NONBLOCK: c_int = 0x0004_0000; +pub const O_NDELAY: c_int = O_NONBLOCK; pub const O_APPEND: c_int = 0x0008_0000; pub const O_SHLOCK: c_int = 0x0010_0000; pub const O_EXLOCK: c_int = 0x0020_0000; @@ -627,15 +630,6 @@ pub const PTHREAD_RWLOCK_INITIALIZER: crate::pthread_rwlock_t = crate::pthread_r }; pub const PTHREAD_STACK_MIN: size_t = 4096; -// sys/resource.h -pub const RLIM_INFINITY: u64 = !0; -pub const RLIM_SAVED_CUR: u64 = RLIM_INFINITY; -pub const RLIM_SAVED_MAX: u64 = RLIM_INFINITY; -pub const RUSAGE_SELF: c_int = 0; -pub const RUSAGE_CHILDREN: c_int = -1; -pub const RUSAGE_BOTH: c_int = -2; -pub const RUSAGE_THREAD: c_int = 1; - // signal.h pub const SIG_BLOCK: c_int = 0; pub const SIG_UNBLOCK: c_int = 1; @@ -774,6 +768,32 @@ pub const MS_ASYNC: c_int = 0x0001; pub const MS_INVALIDATE: c_int = 0x0002; pub const MS_SYNC: c_int = 0x0004; +// sys/resource.h +pub const RLIM_INFINITY: rlim_t = !0; +pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; +pub const RLIMIT_CPU: c_int = 0; +pub const RLIMIT_FSIZE: c_int = 1; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_STACK: c_int = 3; +pub const RLIMIT_CORE: c_int = 4; +pub const RLIMIT_RSS: c_int = 5; +pub const RLIMIT_NPROC: c_int = 6; +pub const RLIMIT_NOFILE: c_int = 7; +pub const RLIMIT_MEMLOCK: c_int = 8; +pub const RLIMIT_AS: c_int = 9; +pub const RLIMIT_LOCKS: c_int = 10; +pub const RLIMIT_SIGPENDING: c_int = 11; +pub const RLIMIT_MSGQUEUE: c_int = 12; +pub const RLIMIT_NICE: c_int = 13; +pub const RLIMIT_RTPRIO: c_int = 14; +pub const RLIMIT_NLIMITS: c_int = 15; + +pub const RUSAGE_SELF: c_int = 0; +pub const RUSAGE_CHILDREN: c_int = -1; +pub const RUSAGE_BOTH: c_int = -2; +pub const RUSAGE_THREAD: c_int = 1; + // sys/select.h pub const FD_SETSIZE: usize = 1024; @@ -991,6 +1011,44 @@ pub const _SC_SYMLOOP_MAX: c_int = 173; pub const _SC_HOST_NAME_MAX: c_int = 180; // } POSIX.1 +// confstr +pub const _CS_PATH: c_int = 0; +pub const _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS: c_int = 1; +pub const _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS: c_int = 4; +pub const _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS: c_int = 5; +pub const _CS_POSIX_V6_ILP32_OFF32_CFLAGS: c_int = 1116; +pub const _CS_POSIX_V6_ILP32_OFF32_LDFLAGS: c_int = 1117; +pub const _CS_POSIX_V6_ILP32_OFF32_LIBS: c_int = 1118; +pub const _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS: c_int = 1119; +pub const _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS: c_int = 1120; +pub const _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS: c_int = 1121; +pub const _CS_POSIX_V6_ILP32_OFFBIG_LIBS: c_int = 1122; +pub const _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS: c_int = 1123; +pub const _CS_POSIX_V6_LP64_OFF64_CFLAGS: c_int = 1124; +pub const _CS_POSIX_V6_LP64_OFF64_LDFLAGS: c_int = 1125; +pub const _CS_POSIX_V6_LP64_OFF64_LIBS: c_int = 1126; +pub const _CS_POSIX_V6_LP64_OFF64_LINTFLAGS: c_int = 1127; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS: c_int = 1128; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS: c_int = 1129; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_LIBS: c_int = 1130; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS: c_int = 1131; +pub const _CS_POSIX_V7_ILP32_OFF32_CFLAGS: c_int = 1132; +pub const _CS_POSIX_V7_ILP32_OFF32_LDFLAGS: c_int = 1133; +pub const _CS_POSIX_V7_ILP32_OFF32_LIBS: c_int = 1134; +pub const _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS: c_int = 1135; +pub const _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS: c_int = 1136; +pub const _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS: c_int = 1137; +pub const _CS_POSIX_V7_ILP32_OFFBIG_LIBS: c_int = 1138; +pub const _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS: c_int = 1139; +pub const _CS_POSIX_V7_LP64_OFF64_CFLAGS: c_int = 1140; +pub const _CS_POSIX_V7_LP64_OFF64_LDFLAGS: c_int = 1141; +pub const _CS_POSIX_V7_LP64_OFF64_LIBS: c_int = 1142; +pub const _CS_POSIX_V7_LP64_OFF64_LINTFLAGS: c_int = 1143; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS: c_int = 1144; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS: c_int = 1145; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_LIBS: c_int = 1146; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS: c_int = 1147; + pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2;