From a648a8e6377154ff5296ae60331d1265f827557b Mon Sep 17 00:00:00 2001 From: Yoh Deadfall Date: Mon, 30 Sep 2024 20:06:35 +0300 Subject: [PATCH 1/8] Android: Added PR_GET_NAME and PR_SET_NAME (#3941) (backport ) (cherry picked from commit 2191c87696b414a87a3e53428f176358179c7918) --- libc-test/semver/android.txt | 2 ++ src/unix/linux_like/android/mod.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index ddd651da0d6df..3c452943dd7e3 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -1904,9 +1904,11 @@ POSIX_FADV_NORMAL POSIX_FADV_RANDOM POSIX_FADV_SEQUENTIAL POSIX_FADV_WILLNEED +PR_GET_NAME PR_GET_NO_NEW_PRIVS PR_GET_SECCOMP PR_GET_TIMING +PR_SET_NAME PR_SET_NO_NEW_PRIVS PR_SET_SECCOMP PR_TIMING_STATISTICAL diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index a8e935967c132..3896492ebe706 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3153,6 +3153,8 @@ pub const PR_GET_TIMING: ::c_int = 13; pub const PR_SET_TIMING: ::c_int = 14; pub const PR_TIMING_STATISTICAL: ::c_int = 0; pub const PR_TIMING_TIMESTAMP: ::c_int = 1; +pub const PR_SET_NAME: ::c_int = 15; +pub const PR_GET_NAME: ::c_int = 16; // linux/if_addr.h pub const IFA_UNSPEC: ::c_ushort = 0; From bd30fe142e09dd3324dbda77a6312a1049964a6c Mon Sep 17 00:00:00 2001 From: Paul Mabileau <35344098+PaulDance@users.noreply.github.com> Date: Mon, 30 Sep 2024 18:17:53 +0200 Subject: [PATCH 2/8] Feat(Apple): Add the LOCAL_PEERTOKEN socket option (#3929) * Feat(apple): Add LOCAL_PEERTOKEN Taken from `sys/un.h`. Signed-off-by: Paul Mabileau * Docs(apple): Add description for LOCAL_PEER* socket options Signed-off-by: Paul Mabileau * Chore(test/apple): Add the LOCAL_PEERTOKEN symbol Signed-off-by: Paul Mabileau --------- Signed-off-by: Paul Mabileau (backport ) (cherry picked from commit 0a25ed85c91df598b1f730fadc75ddac0dcdee7e) --- libc-test/semver/apple.txt | 1 + src/unix/bsd/apple/mod.rs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index b528a1c64350c..0faff99297129 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -849,6 +849,7 @@ LOCAL_PEEREPID LOCAL_PEEREUUID LOCAL_PEERPID LOCAL_PEERUUID +LOCAL_PEERTOKEN LOGIN_PROCESS LOG_AUTHPRIV LOG_CRON diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 3e150feee6afa..50320c759a90f 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -4194,11 +4194,18 @@ pub const TCP_CONNECTION_INFO: ::c_int = 0x106; pub const SOL_LOCAL: ::c_int = 0; +/// Retrieve peer credentials. pub const LOCAL_PEERCRED: ::c_int = 0x001; +/// Retrieve peer PID. pub const LOCAL_PEERPID: ::c_int = 0x002; +/// Retrieve effective peer PID. pub const LOCAL_PEEREPID: ::c_int = 0x003; +/// Retrieve peer UUID. pub const LOCAL_PEERUUID: ::c_int = 0x004; +/// Retrieve effective peer UUID. pub const LOCAL_PEEREUUID: ::c_int = 0x005; +/// Retrieve peer audit token. +pub const LOCAL_PEERTOKEN: ::c_int = 0x006; pub const SOL_SOCKET: ::c_int = 0xffff; From b80609c661f1e6f2eab242b63ccbf20be14f6b91 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 30 Sep 2024 23:02:26 -0400 Subject: [PATCH 3/8] Update PULL_REQUEST_TEMPLATE.md (#3953) (backport ) (cherry picked from commit 3f2d4cbd6b6fd9017d0a98217dadecc584a1cfe8) --- .github/PULL_REQUEST_TEMPLATE.md | 34 +++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 70ed1ca355300..5aafd9213ef20 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,15 +1,27 @@ -Thanks for considering submitting a PR! + -- \[ ] Edit corresponding file(s) under `libc-test/semver` when you add/remove item(s), e.g. edit `linux.txt` if you add an item to `src/unix/linux_like/linux/mod.rs` -- \[ ] Your PR doesn't contain any private or *unstable* values like `*LAST` or `*MAX` (see [#3131](https://github.com/rust-lang/libc/issues/3131)) -- \[ ] If your PR has a breaking change, please clarify it -- \[ ] If your PR increments version number, it must NOT contain any other changes (otherwise a release could be delayed) -- \[ ] Make sure `ci/style.sh` passes -- \[ ] `cd libc-test && cargo test` - - (this might fail on your env due to environment difference between your env and CI. Ignore failures if you are not sure) +# Description -Delete this line and everything above before opening your PR. + + +# Sources + + + +# Checklist + + + +- [ ] Relevant tests in `libc-test/semver` have been updated +- [ ] No placeholder or unstable values like `*LAST` or `*MAX` are + included (see [#3131](https://github.com/rust-lang/libc/issues/3131)) +- [ ] Tested locally (`cd libc-test && cargo test --target mytarget`); + especially relevant for platforms that may not be checked in CI From 68d73f40591dc4edb7295cd6bc12ff05ab114a92 Mon Sep 17 00:00:00 2001 From: SteveLauC Date: Tue, 1 Oct 2024 10:35:54 +0800 Subject: [PATCH 4/8] feat: move NT_XXX constants defined in elf.h to linux/mod.rs (#3938) (backport ) (cherry picked from commit 4ce03dad4387f27d15ab9f7da81a93ac7f82d9ce) --- libc-test/semver/linux-gnu.txt | 17 ----------------- libc-test/semver/linux.txt | 17 +++++++++++++++++ src/unix/linux_like/linux/gnu/mod.rs | 19 ------------------- src/unix/linux_like/linux/mod.rs | 19 +++++++++++++++++++ 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index bca6e4fd18ed7..59d956fa42d99 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -337,23 +337,6 @@ NFT_USERDATA_MAXLEN NF_NETDEV_INGRESS NF_NETDEV_NUMHOOKS NILFS_SUPER_MAGIC -NT_PRSTATUS -NT_PRFPREG -NT_FPREGSET -NT_PRPSINFO -NT_PRXREG -NT_TASKSTRUCT -NT_PLATFORM -NT_AUXV -NT_GWINDOWS -NT_ASRS -NT_PSTATUS -NT_PSINFO -NT_PRCRED -NT_UTSNAME -NT_LWPSTATUS -NT_LWPSINFO -NT_PRFPXREG NTF_EXT_LEARNED NTF_MASTER NTF_OFFLOADED diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index d0b966f4f1085..a5ccef469541d 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -3950,3 +3950,20 @@ eventfd_write __c_anonymous_ifru_map __c_anonymous_ifr_ifru __c_anonymous_ifc_ifcu +NT_PRSTATUS +NT_PRFPREG +NT_FPREGSET +NT_PRPSINFO +NT_PRXREG +NT_TASKSTRUCT +NT_PLATFORM +NT_AUXV +NT_GWINDOWS +NT_ASRS +NT_PSTATUS +NT_PSINFO +NT_PRCRED +NT_UTSNAME +NT_LWPSTATUS +NT_LWPSINFO +NT_PRFPXREG diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 7fd7fb190ca9d..b28c33f2c1d41 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -1103,25 +1103,6 @@ pub const XSK_UNALIGNED_BUF_ADDR_MASK: ::c_ulonglong = (1 << XSK_UNALIGNED_BUF_O pub const XDP_PKT_CONTD: ::__u32 = 1 << 0; -// elf.h -pub const NT_PRSTATUS: ::c_int = 1; -pub const NT_PRFPREG: ::c_int = 2; -pub const NT_FPREGSET: ::c_int = 2; -pub const NT_PRPSINFO: ::c_int = 3; -pub const NT_PRXREG: ::c_int = 4; -pub const NT_TASKSTRUCT: ::c_int = 4; -pub const NT_PLATFORM: ::c_int = 5; -pub const NT_AUXV: ::c_int = 6; -pub const NT_GWINDOWS: ::c_int = 7; -pub const NT_ASRS: ::c_int = 8; -pub const NT_PSTATUS: ::c_int = 10; -pub const NT_PSINFO: ::c_int = 13; -pub const NT_PRCRED: ::c_int = 14; -pub const NT_UTSNAME: ::c_int = 15; -pub const NT_LWPSTATUS: ::c_int = 16; -pub const NT_LWPSINFO: ::c_int = 17; -pub const NT_PRFPXREG: ::c_int = 20; - pub const ELFOSABI_ARM_AEABI: u8 = 64; // linux/sched.h diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 7df3a953c293b..20c4a16979087 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -4907,6 +4907,25 @@ pub const SCHED_FLAG_KEEP_PARAMS: ::c_int = 0x10; pub const SCHED_FLAG_UTIL_CLAMP_MIN: ::c_int = 0x20; pub const SCHED_FLAG_UTIL_CLAMP_MAX: ::c_int = 0x40; +// elf.h +pub const NT_PRSTATUS: ::c_int = 1; +pub const NT_PRFPREG: ::c_int = 2; +pub const NT_FPREGSET: ::c_int = 2; +pub const NT_PRPSINFO: ::c_int = 3; +pub const NT_PRXREG: ::c_int = 4; +pub const NT_TASKSTRUCT: ::c_int = 4; +pub const NT_PLATFORM: ::c_int = 5; +pub const NT_AUXV: ::c_int = 6; +pub const NT_GWINDOWS: ::c_int = 7; +pub const NT_ASRS: ::c_int = 8; +pub const NT_PSTATUS: ::c_int = 10; +pub const NT_PSINFO: ::c_int = 13; +pub const NT_PRCRED: ::c_int = 14; +pub const NT_UTSNAME: ::c_int = 15; +pub const NT_LWPSTATUS: ::c_int = 16; +pub const NT_LWPSINFO: ::c_int = 17; +pub const NT_PRFPXREG: ::c_int = 20; + pub const SCHED_FLAG_KEEP_ALL: ::c_int = SCHED_FLAG_KEEP_POLICY | SCHED_FLAG_KEEP_PARAMS; pub const SCHED_FLAG_UTIL_CLAMP: ::c_int = SCHED_FLAG_UTIL_CLAMP_MIN | SCHED_FLAG_UTIL_CLAMP_MAX; From ccbcfbbf137652b0501a0c4e9aba6239b77a1ddc Mon Sep 17 00:00:00 2001 From: ChanTsune <41658782+ChanTsune@users.noreply.github.com> Date: Mon, 30 Sep 2024 21:25:40 -0700 Subject: [PATCH 5/8] Add `getgrgid`, `getgrnam`, `getgrnam_r` and `getgrgid_r` for emscripten (#3912) (backport ) (cherry picked from commit 1566923c37118df370ed4620a157cb803b0d4415) --- libc-test/semver/emscripten.txt | 4 ++++ src/unix/linux_like/emscripten/mod.rs | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/libc-test/semver/emscripten.txt b/libc-test/semver/emscripten.txt index d61541c4f2baf..150a7fb8a6c6f 100644 --- a/libc-test/semver/emscripten.txt +++ b/libc-test/semver/emscripten.txt @@ -1,5 +1,9 @@ AT_EACCESS getentropy +getgrgid +getgrnam +getgrnam_r +getgrgid_r posix_fallocate64 getpwnam_r getpwuid_r diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 5a598f5503850..2f515f390d8e2 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1793,6 +1793,24 @@ extern "C" { buflen: ::size_t, result: *mut *mut passwd, ) -> ::c_int; + + // grp.h + pub fn getgrgid(gid: ::gid_t) -> *mut ::group; + pub fn getgrnam(name: *const ::c_char) -> *mut ::group; + pub fn getgrnam_r( + name: *const ::c_char, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + pub fn getgrgid_r( + gid: ::gid_t, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; } // Alias to 64 to mimic glibc's LFS64 support From 9606af1acdd3b8e4603426524f5ad91e8fe792d8 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Tue, 1 Oct 2024 05:48:22 +0100 Subject: [PATCH 6/8] Add mach_error_string (and mach_error_t) (#3913) `mach_error_string` is defined in `/usr/include/mach/mach_error.h` It is not referenced in the documentation Apple website. ``` char *mach_error_string( /* * Returns a string appropriate to the error argument given */ mach_error_t error_value ); ``` `mach_error_t` is defined in `/usr/include/mach/error.h` https://developer.apple.com/documentation/kernel/mach_error_t ``` typedef kern_return_t mach_error_t; ``` (backport ) (cherry picked from commit d8ff07b336fd28c58088b718fee4f0f350b0f733) --- libc-test/semver/apple.txt | 2 ++ src/unix/bsd/apple/mod.rs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 0faff99297129..69166efd65e81 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -2020,6 +2020,8 @@ log2phys login_tty lutimes mach_absolute_time +mach_error_string +mach_error_t mach_header mach_header_64 mach_host_self diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 50320c759a90f..c204f1db507fe 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -56,6 +56,7 @@ pub type thread_inspect_t = ::mach_port_t; pub type thread_act_t = ::mach_port_t; pub type thread_act_array_t = *mut ::thread_act_t; pub type policy_t = ::c_int; +pub type mach_error_t = ::kern_return_t; pub type mach_vm_address_t = u64; pub type mach_vm_offset_t = u64; pub type mach_vm_size_t = u64; @@ -6330,6 +6331,8 @@ extern "C" { pub fn copyfile_state_get(s: copyfile_state_t, flags: u32, dst: *mut ::c_void) -> ::c_int; pub fn copyfile_state_set(s: copyfile_state_t, flags: u32, src: *const ::c_void) -> ::c_int; + pub fn mach_error_string(error_value: ::mach_error_t) -> *mut ::c_char; + // Added in macOS 10.13 // ISO/IEC 9899:2011 ("ISO C11") K.3.7.4.1 pub fn memset_s(s: *mut ::c_void, smax: ::size_t, c: ::c_int, n: ::size_t) -> ::c_int; From 8ec259489064d56130bf3e33fd3a91a513d5a9ae Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Fri, 13 Sep 2024 10:07:43 +0200 Subject: [PATCH 7/8] fix: Update ESP-IDF constants (backport ) (cherry picked from commit 133d9d0aa84519dc999c45a2c1fabe3c62b1a37c) --- src/unix/newlib/espidf/mod.rs | 16 ++-- src/unix/newlib/mod.rs | 134 ++++++++++++++++++++++++++++------ 2 files changed, 120 insertions(+), 30 deletions(-) diff --git a/src/unix/newlib/espidf/mod.rs b/src/unix/newlib/espidf/mod.rs index 1a2a907d83191..a73e85315971f 100644 --- a/src/unix/newlib/espidf/mod.rs +++ b/src/unix/newlib/espidf/mod.rs @@ -89,15 +89,15 @@ pub const MSG_EOR: ::c_int = 0x08; pub const PTHREAD_STACK_MIN: ::size_t = 768; -pub const SIGABRT: ::c_int = 1; -pub const SIGFPE: ::c_int = 1; -pub const SIGILL: ::c_int = 1; -pub const SIGINT: ::c_int = 1; -pub const SIGSEGV: ::c_int = 1; -pub const SIGTERM: ::c_int = 1; +pub const SIGABRT: ::c_int = 6; +pub const SIGFPE: ::c_int = 8; +pub const SIGILL: ::c_int = 4; +pub const SIGINT: ::c_int = 2; +pub const SIGSEGV: ::c_int = 11; +pub const SIGTERM: ::c_int = 15; pub const SIGHUP: ::c_int = 1; -pub const SIGQUIT: ::c_int = 1; -pub const NSIG: ::size_t = 2; +pub const SIGQUIT: ::c_int = 3; +pub const NSIG: ::size_t = 32; extern "C" { pub fn pthread_create( diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 91380db247b05..e3f7d71c90212 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -42,7 +42,13 @@ cfg_if! { pub type socklen_t = u32; pub type speed_t = u32; pub type suseconds_t = i32; -pub type tcflag_t = ::c_uint; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub type tcflag_t = u16; + } else { + pub type tcflag_t = ::c_uint; + } +} pub type useconds_t = u32; cfg_if! { @@ -244,7 +250,14 @@ align_const! { size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_RWLOCK_T], }; } -pub const NCCS: usize = 32; + +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const NCCS: usize = 11; + } else { + pub const NCCS: usize = 32; + } +} cfg_if! { if #[cfg(target_os = "espidf")] { @@ -423,7 +436,13 @@ pub const O_SYNC: ::c_int = 8192; pub const O_NONBLOCK: ::c_int = 16384; pub const O_ACCMODE: ::c_int = 3; -pub const O_CLOEXEC: ::c_int = 0x80000; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const O_CLOEXEC: ::c_int = 0x40000; + } else { + pub const O_CLOEXEC: ::c_int = 0x80000; + } +} pub const RTLD_LAZY: ::c_int = 0x1; @@ -465,7 +484,13 @@ pub const SOL_TCP: ::c_int = 6; pub const PF_UNSPEC: ::c_int = 0; pub const PF_INET: ::c_int = 2; -pub const PF_INET6: ::c_int = 23; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const PF_INET6: ::c_int = 10; + } else { + pub const PF_INET6: ::c_int = 23; + } +} pub const AF_UNSPEC: ::c_int = 0; pub const AF_INET: ::c_int = 2; @@ -550,6 +575,9 @@ cfg_if! { if #[cfg(target_os = "vita")] { pub const TCP_NODELAY: ::c_int = 1; pub const TCP_MAXSEG: ::c_int = 2; + } else if #[cfg(target_os = "espidf")] { + pub const TCP_NODELAY: ::c_int = 1; + pub const TCP_MAXSEG: ::c_int = 8194; } else { pub const TCP_NODELAY: ::c_int = 8193; pub const TCP_MAXSEG: ::c_int = 8194; @@ -558,13 +586,23 @@ cfg_if! { pub const TCP_NOPUSH: ::c_int = 4; pub const TCP_NOOPT: ::c_int = 8; -pub const TCP_KEEPIDLE: ::c_int = 256; -pub const TCP_KEEPINTVL: ::c_int = 512; -pub const TCP_KEEPCNT: ::c_int = 1024; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const TCP_KEEPIDLE: ::c_int = 3; + pub const TCP_KEEPINTVL: ::c_int = 4; + pub const TCP_KEEPCNT: ::c_int = 5; + } else { + pub const TCP_KEEPIDLE: ::c_int = 256; + pub const TCP_KEEPINTVL: ::c_int = 512; + pub const TCP_KEEPCNT: ::c_int = 1024; + } +} cfg_if! { if #[cfg(target_os = "horizon")] { pub const IP_TOS: ::c_int = 7; + } else if #[cfg(target_os = "espidf")] { + pub const IP_TOS: ::c_int = 1; } else { pub const IP_TOS: ::c_int = 3; } @@ -572,55 +610,107 @@ cfg_if! { cfg_if! { if #[cfg(target_os = "vita")] { pub const IP_TTL: ::c_int = 4; + } else if #[cfg(target_os = "espidf")] { + pub const IP_TTL: ::c_int = 2; } else { pub const IP_TTL: ::c_int = 8; } } -pub const IP_MULTICAST_IF: ::c_int = 9; -pub const IP_MULTICAST_TTL: ::c_int = 10; -pub const IP_MULTICAST_LOOP: ::c_int = 11; + +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const IP_MULTICAST_IF: ::c_int = 6; + pub const IP_MULTICAST_TTL: ::c_int = 5; + pub const IP_MULTICAST_LOOP: ::c_int = 7; + } else { + pub const IP_MULTICAST_IF: ::c_int = 9; + pub const IP_MULTICAST_TTL: ::c_int = 10; + pub const IP_MULTICAST_LOOP: ::c_int = 11; + } +} + cfg_if! { if #[cfg(target_os = "vita")] { pub const IP_ADD_MEMBERSHIP: ::c_int = 12; pub const IP_DROP_MEMBERSHIP: ::c_int = 13; + } else if #[cfg(target_os = "espidf")] { + pub const IP_ADD_MEMBERSHIP: ::c_int = 3; + pub const IP_DROP_MEMBERSHIP: ::c_int = 4; } else { pub const IP_ADD_MEMBERSHIP: ::c_int = 11; pub const IP_DROP_MEMBERSHIP: ::c_int = 12; } } pub const IPV6_UNICAST_HOPS: ::c_int = 4; -pub const IPV6_MULTICAST_IF: ::c_int = 9; -pub const IPV6_MULTICAST_HOPS: ::c_int = 10; -pub const IPV6_MULTICAST_LOOP: ::c_int = 11; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const IPV6_MULTICAST_IF: ::c_int = 768; + pub const IPV6_MULTICAST_HOPS: ::c_int = 769; + pub const IPV6_MULTICAST_LOOP: ::c_int = 770; + } else { + pub const IPV6_MULTICAST_IF: ::c_int = 9; + pub const IPV6_MULTICAST_HOPS: ::c_int = 10; + pub const IPV6_MULTICAST_LOOP: ::c_int = 11; + } +} pub const IPV6_V6ONLY: ::c_int = 27; pub const IPV6_JOIN_GROUP: ::c_int = 12; pub const IPV6_LEAVE_GROUP: ::c_int = 13; pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12; pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13; -pub const HOST_NOT_FOUND: ::c_int = 1; -pub const NO_DATA: ::c_int = 2; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const HOST_NOT_FOUND: ::c_int = 210; + pub const NO_DATA: ::c_int = 211; + pub const NO_RECOVERY: ::c_int = 212; + pub const TRY_AGAIN: ::c_int = 213; + + } else { + pub const HOST_NOT_FOUND: ::c_int = 1; + pub const NO_DATA: ::c_int = 2; + pub const NO_RECOVERY: ::c_int = 3; + pub const TRY_AGAIN: ::c_int = 4; + } +} pub const NO_ADDRESS: ::c_int = 2; -pub const NO_RECOVERY: ::c_int = 3; -pub const TRY_AGAIN: ::c_int = 4; pub const AI_PASSIVE: ::c_int = 1; pub const AI_CANONNAME: ::c_int = 2; pub const AI_NUMERICHOST: ::c_int = 4; -pub const AI_NUMERICSERV: ::c_int = 0; -pub const AI_ADDRCONFIG: ::c_int = 0; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const AI_NUMERICSERV: ::c_int = 8; + pub const AI_ADDRCONFIG: ::c_int = 64; + } else { + pub const AI_NUMERICSERV: ::c_int = 0; + pub const AI_ADDRCONFIG: ::c_int = 0; + } +} pub const NI_MAXHOST: ::c_int = 1025; pub const NI_MAXSERV: ::c_int = 32; pub const NI_NOFQDN: ::c_int = 1; pub const NI_NUMERICHOST: ::c_int = 2; pub const NI_NAMEREQD: ::c_int = 4; -pub const NI_NUMERICSERV: ::c_int = 0; -pub const NI_DGRAM: ::c_int = 0; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const NI_NUMERICSERV: ::c_int = 8; + pub const NI_DGRAM: ::c_int = 16; + } else { + pub const NI_NUMERICSERV: ::c_int = 0; + pub const NI_DGRAM: ::c_int = 0; + } +} cfg_if! { // Defined in vita/mod.rs for "vita" - if #[cfg(not(target_os = "vita"))] { + if #[cfg(target_os = "espidf")] { + pub const EAI_FAMILY: ::c_int = 204; + pub const EAI_MEMORY: ::c_int = 203; + pub const EAI_NONAME: ::c_int = 200; + pub const EAI_SOCKTYPE: ::c_int = 10; + } else if #[cfg(not(target_os = "vita"))] { pub const EAI_FAMILY: ::c_int = -303; pub const EAI_MEMORY: ::c_int = -304; pub const EAI_NONAME: ::c_int = -305; From 016e498afa588ed56b87c9398dbcef33c9ea483a Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Fri, 13 Sep 2024 14:25:37 +0200 Subject: [PATCH 8/8] fix: Update ESP-IDF structs (backport ) (cherry picked from commit 6f2b73a294d929120f328edffc076fab919f87b0) --- src/unix/newlib/generic.rs | 3 +++ src/unix/newlib/mod.rs | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/unix/newlib/generic.rs b/src/unix/newlib/generic.rs index e45413a7a9e2c..d716dec19f0f8 100644 --- a/src/unix/newlib/generic.rs +++ b/src/unix/newlib/generic.rs @@ -2,7 +2,10 @@ s! { pub struct sigset_t { + #[cfg(target_os = "horizon")] __val: [::c_ulong; 16], + #[cfg(not(target_os = "horizon"))] + __val: u32, } pub struct stat { diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index e3f7d71c90212..78e18d8ceac72 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -203,6 +203,10 @@ s! { pub c_lflag: ::tcflag_t, pub c_line: ::cc_t, pub c_cc: [::cc_t; ::NCCS], + #[cfg(target_os = "espidf")] + pub c_ispeed: u32, + #[cfg(target_os = "espidf")] + pub c_ospeed: u32, } pub struct sem_t { // Unverified @@ -230,7 +234,24 @@ s! { } pub struct pthread_attr_t { // Unverified - __size: [u8; __SIZEOF_PTHREAD_ATTR_T] + #[cfg(not(target_os = "espidf"))] + __size: [u8; __SIZEOF_PTHREAD_ATTR_T], + #[cfg(target_os = "espidf")] + pub is_initialized: i32, + #[cfg(target_os = "espidf")] + pub stackaddr: *mut crate::c_void, + #[cfg(target_os = "espidf")] + pub stacksize: i32, + #[cfg(target_os = "espidf")] + pub contentionscope: i32, + #[cfg(target_os = "espidf")] + pub inheritsched: i32, + #[cfg(target_os = "espidf")] + pub schedpolicy: i32, + #[cfg(target_os = "espidf")] + pub schedparam: i32, + #[cfg(target_os = "espidf")] + pub detachstate: i32, } pub struct pthread_rwlockattr_t { // Unverified