Skip to content

[0.2] Backports #3969

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 8 commits into from
Oct 15, 2024
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
34 changes: 23 additions & 11 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
Thanks for considering submitting a PR!
<!-- Thank you for submitting a PR!

We have the [contribution guide](https://github.com/rust-lang/libc/blob/main/CONTRIBUTING.md). Please read it if you're new here!
We have the contribution guide, please read it if you are new here!
<https://github.com/rust-lang/libc/blob/main/CONTRIBUTING.md>

Here's a checklist for things that will be checked during review or continuous integration.
Please fill out the below template.
-->

- \[ ] 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.
<!-- Add a short description about what this change does -->

# Sources

<!-- All API changes must have links to headers and/or documentation,
preferably both -->

# Checklist

<!-- Please make sure the following has been done before submitting a PR,
or mark it as a draft if you are not sure. -->

- [ ] 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
2 changes: 2 additions & 0 deletions libc-test/semver/android.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions libc-test/semver/apple.txt
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ LOCAL_PEEREPID
LOCAL_PEEREUUID
LOCAL_PEERPID
LOCAL_PEERUUID
LOCAL_PEERTOKEN
LOGIN_PROCESS
LOG_AUTHPRIV
LOG_CRON
Expand Down Expand Up @@ -2019,6 +2020,8 @@ log2phys
login_tty
lutimes
mach_absolute_time
mach_error_string
mach_error_t
mach_header
mach_header_64
mach_host_self
Expand Down
4 changes: 4 additions & 0 deletions libc-test/semver/emscripten.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
AT_EACCESS
getentropy
getgrgid
getgrnam
getgrnam_r
getgrgid_r
posix_fallocate64
getpwnam_r
getpwuid_r
17 changes: 0 additions & 17 deletions libc-test/semver/linux-gnu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -4194,11 +4195,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;

Expand Down Expand Up @@ -6323,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;
Expand Down
2 changes: 2 additions & 0 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions src/unix/linux_like/emscripten/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <foo> to <foo>64 to mimic glibc's LFS64 support
Expand Down
19 changes: 0 additions & 19 deletions src/unix/linux_like/linux/gnu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions src/unix/newlib/espidf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions src/unix/newlib/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading