Skip to content

Commit

Permalink
Unrolled build for rust-lang#128817
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#128817 - biabbas:vxworks_update, r=tgross35

VxWorks code refactored

1. Extern TaskNameSet as minimum supported version of os is VxWorks 7 which would have taskNameSet
2. Vx_TASK_NAME_LEN is 31 on VxWorks7, defined variable res.
3. Add unsafe blocks on Non::Zero usage in available_parallelism()
4. Update vxworks docs.
r? `@tgross35`
cc `@devnexen`
  • Loading branch information
rust-timer committed Aug 9, 2024
2 parents 899eb03 + b20d9f0 commit 81026bc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 29 deletions.
36 changes: 13 additions & 23 deletions library/std/src/sys/pal/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ use crate::mem::{self, ManuallyDrop};
use crate::num::NonZero;
#[cfg(all(target_os = "linux", target_env = "gnu"))]
use crate::sys::weak::dlsym;
#[cfg(any(
target_os = "solaris",
target_os = "illumos",
target_os = "nto",
target_os = "vxworks"
))]
#[cfg(any(target_os = "solaris", target_os = "illumos", target_os = "nto",))]
use crate::sys::weak::weak;
use crate::sys::{os, stack_overflow};
use crate::time::Duration;
Expand Down Expand Up @@ -220,23 +215,16 @@ impl Thread {
#[cfg(target_os = "vxworks")]
pub fn set_name(name: &CStr) {
// FIXME(libc): adding real STATUS, ERROR type eventually.
weak! {
fn taskNameSet(
libc::TASK_ID, *mut libc::c_char
) -> libc::c_int
extern "C" {
fn taskNameSet(task_id: libc::TASK_ID, task_name: *mut libc::c_char) -> libc::c_int;
}

// We can't assume taskNameSet is necessarily available.
// VX_TASK_NAME_LEN can be found set to 31,
// however older versions can be set to only 10.
// FIXME(vxworks): if the minimum supported VxWorks is >= 7, the maximum length can be changed to 31.
if let Some(f) = taskNameSet.get() {
const VX_TASK_NAME_LEN: usize = 10;
// VX_TASK_NAME_LEN is 31 in VxWorks 7.
const VX_TASK_NAME_LEN: usize = 31;

let name = truncate_cstr::<{ VX_TASK_NAME_LEN }>(name);
let status = unsafe { f(libc::taskIdSelf(), name.as_mut_ptr()) };
debug_assert_eq!(res, libc::OK);
}
let mut name = truncate_cstr::<{ VX_TASK_NAME_LEN }>(name);
let res = unsafe { taskNameSet(libc::taskIdSelf(), name.as_mut_ptr()) };
debug_assert_eq!(res, libc::OK);
}

#[cfg(any(
Expand Down Expand Up @@ -489,9 +477,11 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
fn vxCpuEnabledGet() -> libc::cpuset_t;
}

// always fetches a valid bitmask
let set = unsafe { vxCpuEnabledGet() };
Ok(NonZero::new_unchecked(set.count_ones() as usize))
// SAFETY: `vxCpuEnabledGet` always fetches a mask with at least one bit set
unsafe{
let set = vxCpuEnabledGet();
Ok(NonZero::new_unchecked(set.count_ones() as usize))
}
} else {
// FIXME: implement on Redox, l4re
Err(io::const_io_error!(io::ErrorKind::Unsupported, "Getting the number of hardware threads is not supported on the target platform"))
Expand Down
12 changes: 6 additions & 6 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ target | std | host | notes
[`armv7-unknown-linux-uclibceabihf`](platform-support/armv7-unknown-linux-uclibceabihf.md) | ✓ | ? | Armv7-A Linux with uClibc, hardfloat
`armv7-unknown-freebsd` | ✓ | ✓ | Armv7-A FreeBSD
[`armv7-unknown-netbsd-eabihf`](platform-support/netbsd.md) | ✓ | ✓ | Armv7-A NetBSD w/hard-float
[`armv7-wrs-vxworks-eabihf`](platform-support/vxworks.md) | ? | | Armv7-A for VxWorks
[`armv7-wrs-vxworks-eabihf`](platform-support/vxworks.md) | | | Armv7-A for VxWorks
[`armv7a-kmc-solid_asp3-eabi`](platform-support/kmc-solid.md) | ✓ | | ARM SOLID with TOPPERS/ASP3
[`armv7a-kmc-solid_asp3-eabihf`](platform-support/kmc-solid.md) | ✓ | | ARM SOLID with TOPPERS/ASP3, hardfloat
[`armv7a-none-eabihf`](platform-support/arm-none-eabi.md) | * | | Bare Armv7-A, hardfloat
Expand All @@ -308,7 +308,7 @@ target | std | host | notes
`i686-uwp-windows-gnu` | ✓ | | [^x86_32-floats-return-ABI]
`i686-uwp-windows-msvc` | ✓ | | [^x86_32-floats-return-ABI]
[`i686-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 32-bit Windows 7 support [^x86_32-floats-return-ABI]
[`i686-wrs-vxworks`](platform-support/vxworks.md) | ? | | [^x86_32-floats-return-ABI]
[`i686-wrs-vxworks`](platform-support/vxworks.md) | | | [^x86_32-floats-return-ABI]
[`m68k-unknown-linux-gnu`](platform-support/m68k-unknown-linux-gnu.md) | ? | | Motorola 680x0 Linux
`mips-unknown-linux-gnu` | ✓ | ✓ | MIPS Linux (kernel 4.4, glibc 2.23)
`mips-unknown-linux-musl` | ✓ | | MIPS Linux with musl 1.2.3
Expand All @@ -334,13 +334,13 @@ target | std | host | notes
`powerpc-unknown-linux-musl` | ? | | PowerPC Linux with musl 1.2.3
[`powerpc-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD 32-bit powerpc systems
[`powerpc-unknown-openbsd`](platform-support/powerpc-unknown-openbsd.md) | * | |
[`powerpc-wrs-vxworks-spe`](platform-support/vxworks.md) | ? | |
[`powerpc-wrs-vxworks`](platform-support/vxworks.md) | ? | |
[`powerpc-wrs-vxworks-spe`](platform-support/vxworks.md) | | |
[`powerpc-wrs-vxworks`](platform-support/vxworks.md) | | |
`powerpc64-unknown-freebsd` | ✓ | ✓ | PPC64 FreeBSD (ELFv1 and ELFv2)
`powerpc64le-unknown-freebsd` | | | PPC64LE FreeBSD
`powerpc-unknown-freebsd` | | | PowerPC FreeBSD
`powerpc64-unknown-linux-musl` | ? | | 64-bit PowerPC Linux with musl 1.2.3
`powerpc64-wrs-vxworks` | ? | |
[`powerpc64-wrs-vxworks`](platform-support/vxworks.md) | | |
`powerpc64le-unknown-linux-musl` | ? | | 64-bit PowerPC Linux with musl 1.2.3, Little Endian
[`powerpc64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/powerpc64
[`powerpc64-ibm-aix`](platform-support/aix.md) | ? | | 64-bit AIX (7.2 and newer)
Expand Down Expand Up @@ -383,7 +383,7 @@ target | std | host | notes
`x86_64-uwp-windows-gnu` | ✓ | |
`x86_64-uwp-windows-msvc` | ✓ | |
[`x86_64-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 64-bit Windows 7 support
[`x86_64-wrs-vxworks`](platform-support/vxworks.md) | ? | |
[`x86_64-wrs-vxworks`](platform-support/vxworks.md) | | |
[`x86_64h-apple-darwin`](platform-support/x86_64h-apple-darwin.md) | ✓ | ✓ | macOS with late-gen Intel (at least Haswell)
[`x86_64-unknown-linux-none`](platform-support/x86_64-unknown-linux-none.md) | * | | 64-bit Linux with no libc
[`xtensa-esp32-none-elf`](platform-support/xtensa.md) | * | | Xtensa ESP32
Expand Down
2 changes: 2 additions & 0 deletions src/doc/rustc/src/platform-support/vxworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Target triplets available:
- `i686-wrs-vxworks`
- `armv7-wrs-vxworks-eabihf`
- `powerpc-wrs-vxworks`
- `powerpc64-wrs-vxworks`
- `powerpc-wrs-vxworks-spe`

## Target maintainers
Expand Down Expand Up @@ -42,6 +43,7 @@ target = [
"i686-wrs-vxworks",
"armv7-wrs-vxworks-eabihf",
"powerpc-wrs-vxworks",
"powerpc64-wrs-vxworks",
"powerpc-wrs-vxworks-spe",
]
```
Expand Down

0 comments on commit 81026bc

Please sign in to comment.