Skip to content

Commit b4f8dd9

Browse files
authored
Merge branch 'master' into stdarch_arm_crc32
2 parents 1e0ac7b + bffd44f commit b4f8dd9

File tree

3 files changed

+141
-14
lines changed

3 files changed

+141
-14
lines changed

Diff for: .github/workflows/main.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v4
1717
- name: Install Rust
18-
run: rustup update nightly && rustup default nightly
18+
run: rustup update nightly --no-self-update && rustup default nightly
1919
- run: ci/style.sh
2020

2121
docs:
@@ -25,7 +25,7 @@ jobs:
2525
steps:
2626
- uses: actions/checkout@v4
2727
- name: Install Rust
28-
run: rustup update nightly && rustup default nightly
28+
run: rustup update nightly --no-self-update && rustup default nightly
2929
- run: ci/dox.sh
3030
env:
3131
CI: 1
@@ -45,18 +45,22 @@ jobs:
4545
steps:
4646
- uses: actions/checkout@v4
4747
- name: Install Rust
48-
run: rustup update nightly && rustup default nightly
48+
run: rustup update nightly --no-self-update && rustup default nightly
4949
- run: cargo test --manifest-path crates/stdarch-verify/Cargo.toml
5050

5151
env_override:
5252
name: Env Override
5353
needs: [style]
54-
runs-on: ubuntu-latest
54+
runs-on: ${{ matrix.os }}
55+
strategy:
56+
matrix:
57+
os: [ubuntu-latest, windows-latest]
5558
steps:
5659
- uses: actions/checkout@v4
5760
- name: Install Rust
58-
run: rustup update nightly && rustup default nightly
61+
run: rustup update nightly --no-self-update && rustup default nightly
5962
- run: RUST_STD_DETECT_UNSTABLE=avx cargo test --features=std_detect_env_override --manifest-path crates/std_detect/Cargo.toml env_override_no_avx
63+
shell: bash
6064

6165
test:
6266
needs: [style]

Diff for: crates/core_arch/src/powerpc/altivec.rs

+98
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,66 @@ impl_neg! { f32x4 : 0f32 }
408408
mod sealed {
409409
use super::*;
410410

411+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
412+
pub trait VectorInsert {
413+
type S;
414+
unsafe fn vec_insert<const IDX: u32>(self, s: Self::S) -> Self;
415+
}
416+
417+
const fn idx_in_vec<T, const IDX: u32>() -> u32 {
418+
IDX & (16 / crate::mem::size_of::<T>() as u32)
419+
}
420+
421+
macro_rules! impl_vec_insert {
422+
($ty:ident) => {
423+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
424+
impl VectorInsert for t_t_l!($ty) {
425+
type S = $ty;
426+
#[inline]
427+
#[target_feature(enable = "altivec")]
428+
unsafe fn vec_insert<const IDX: u32>(self, s: Self::S) -> Self {
429+
simd_insert(self, const { idx_in_vec::<Self::S, IDX>() }, s)
430+
}
431+
}
432+
};
433+
}
434+
435+
impl_vec_insert! { i8 }
436+
impl_vec_insert! { u8 }
437+
impl_vec_insert! { i16 }
438+
impl_vec_insert! { u16 }
439+
impl_vec_insert! { i32 }
440+
impl_vec_insert! { u32 }
441+
impl_vec_insert! { f32 }
442+
443+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
444+
pub trait VectorExtract {
445+
type S;
446+
unsafe fn vec_extract<const IDX: u32>(self) -> Self::S;
447+
}
448+
449+
macro_rules! impl_vec_extract {
450+
($ty:ident) => {
451+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
452+
impl VectorExtract for t_t_l!($ty) {
453+
type S = $ty;
454+
#[inline]
455+
#[target_feature(enable = "altivec")]
456+
unsafe fn vec_extract<const IDX: u32>(self) -> Self::S {
457+
simd_extract(self, const { idx_in_vec::<Self::S, IDX>() })
458+
}
459+
}
460+
};
461+
}
462+
463+
impl_vec_extract! { i8 }
464+
impl_vec_extract! { u8 }
465+
impl_vec_extract! { i16 }
466+
impl_vec_extract! { u16 }
467+
impl_vec_extract! { i32 }
468+
impl_vec_extract! { u32 }
469+
impl_vec_extract! { f32 }
470+
411471
macro_rules! impl_vec_cmp {
412472
([$Trait:ident $m:ident] ($b:ident, $h:ident, $w:ident)) => {
413473
impl_vec_cmp! { [$Trait $m] ($b, $b, $h, $h, $w, $w) }
@@ -3219,6 +3279,44 @@ mod sealed {
32193279
}
32203280
}
32213281

3282+
/// Vector Insert
3283+
///
3284+
/// ## Purpose
3285+
/// Returns a copy of vector b with element c replaced by the value of a.
3286+
///
3287+
/// ## Result value
3288+
/// r contains a copy of vector b with element c replaced by the value of a.
3289+
/// This function uses modular arithmetic on c to determine the element number.
3290+
/// For example, if c is out of range, the compiler uses c modulo the number of
3291+
/// elements in the vector to determine the element position.
3292+
#[inline]
3293+
#[target_feature(enable = "altivec")]
3294+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3295+
pub unsafe fn vec_insert<T, const IDX: u32>(a: T, b: <T as sealed::VectorInsert>::S) -> T
3296+
where
3297+
T: sealed::VectorInsert,
3298+
{
3299+
a.vec_insert::<IDX>(b)
3300+
}
3301+
3302+
/// Vector Extract
3303+
///
3304+
/// ## Purpose
3305+
/// Returns the value of the bth element of vector a.
3306+
///
3307+
/// ## Result value
3308+
/// The value of each element of r is the element of a at position b modulo the number of
3309+
/// elements of a.
3310+
#[inline]
3311+
#[target_feature(enable = "altivec")]
3312+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3313+
pub unsafe fn vec_extract<T, const IDX: u32>(a: T) -> <T as sealed::VectorExtract>::S
3314+
where
3315+
T: sealed::VectorExtract,
3316+
{
3317+
a.vec_extract::<IDX>()
3318+
}
3319+
32223320
/// Vector Merge Low
32233321
#[inline]
32243322
#[target_feature(enable = "altivec")]

Diff for: crates/std_detect/src/detect/cache.rs

+34-9
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,42 @@ impl Cache {
118118

119119
cfg_if::cfg_if! {
120120
if #[cfg(feature = "std_detect_env_override")] {
121+
#[inline]
122+
fn disable_features(disable: &[u8], value: &mut Initializer) {
123+
if let Ok(disable) = core::str::from_utf8(disable) {
124+
for v in disable.split(" ") {
125+
let _ = super::Feature::from_str(v).map(|v| value.unset(v as u32));
126+
}
127+
}
128+
}
129+
121130
#[inline]
122131
fn initialize(mut value: Initializer) -> Initializer {
123-
let env = unsafe {
124-
libc::getenv(b"RUST_STD_DETECT_UNSTABLE\0".as_ptr() as *const libc::c_char)
125-
};
126-
if !env.is_null() {
127-
let len = unsafe { libc::strlen(env) };
128-
let env = unsafe { core::slice::from_raw_parts(env as *const u8, len) };
129-
if let Ok(disable) = core::str::from_utf8(env) {
130-
for v in disable.split(" ") {
131-
let _ = super::Feature::from_str(v).map(|v| value.unset(v as u32));
132+
const RUST_STD_DETECT_UNSTABLE: &[u8] = b"RUST_STD_DETECT_UNSTABLE\0";
133+
cfg_if::cfg_if! {
134+
if #[cfg(windows)] {
135+
use alloc::vec;
136+
#[link(name = "kernel32")]
137+
extern "system" {
138+
fn GetEnvironmentVariableA(name: *const u8, buffer: *mut u8, size: u32) -> u32;
139+
}
140+
let len = unsafe { GetEnvironmentVariableA(RUST_STD_DETECT_UNSTABLE.as_ptr(), core::ptr::null_mut(), 0) };
141+
if len > 0 {
142+
// +1 to include the null terminator.
143+
let mut env = vec![0; len as usize + 1];
144+
let len = unsafe { GetEnvironmentVariableA(RUST_STD_DETECT_UNSTABLE.as_ptr(), env.as_mut_ptr(), len + 1) };
145+
if len > 0 {
146+
disable_features(&env[..len as usize], &mut value);
147+
}
148+
}
149+
} else {
150+
let env = unsafe {
151+
libc::getenv(RUST_STD_DETECT_UNSTABLE.as_ptr() as *const libc::c_char)
152+
};
153+
if !env.is_null() {
154+
let len = unsafe { libc::strlen(env) };
155+
let env = unsafe { core::slice::from_raw_parts(env as *const u8, len) };
156+
disable_features(env, &mut value);
132157
}
133158
}
134159
}

0 commit comments

Comments
 (0)