mirror of
https://github.com/saymrwulf/betrusted-curve25519-dalek-source.git
synced 2026-09-04 20:24:07 +00:00
add cfg statements to only build doctest on x86 (#585)
This commit is contained in:
parent
0cd099a9fb
commit
e6675c67ce
1 changed files with 7 additions and 0 deletions
|
|
@ -44,6 +44,7 @@ to build out more elaborate abstractions it starts to become painful to use.
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AVX;
|
struct AVX;
|
||||||
|
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||||
impl Backend for AVX {
|
impl Backend for AVX {
|
||||||
#[target_feature(enable = "avx")]
|
#[target_feature(enable = "avx")]
|
||||||
unsafe fn sum(xs: &[u32]) -> u32 {
|
unsafe fn sum(xs: &[u32]) -> u32 {
|
||||||
|
|
@ -53,6 +54,7 @@ to build out more elaborate abstractions it starts to become painful to use.
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AVX2;
|
struct AVX2;
|
||||||
|
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||||
impl Backend for AVX2 {
|
impl Backend for AVX2 {
|
||||||
#[target_feature(enable = "avx2")]
|
#[target_feature(enable = "avx2")]
|
||||||
unsafe fn sum(xs: &[u32]) -> u32 {
|
unsafe fn sum(xs: &[u32]) -> u32 {
|
||||||
|
|
@ -87,6 +89,7 @@ fn func() {}
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// It works, but must be `unsafe`
|
// It works, but must be `unsafe`
|
||||||
|
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||||
#[target_feature(enable = "avx2")]
|
#[target_feature(enable = "avx2")]
|
||||||
unsafe fn func() {}
|
unsafe fn func() {}
|
||||||
```
|
```
|
||||||
|
|
@ -95,6 +98,7 @@ unsafe fn func() {}
|
||||||
use curve25519_dalek_derive::unsafe_target_feature;
|
use curve25519_dalek_derive::unsafe_target_feature;
|
||||||
|
|
||||||
// No `unsafe` on the function itself!
|
// No `unsafe` on the function itself!
|
||||||
|
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||||
#[unsafe_target_feature("avx2")]
|
#[unsafe_target_feature("avx2")]
|
||||||
fn func() {}
|
fn func() {}
|
||||||
```
|
```
|
||||||
|
|
@ -119,6 +123,7 @@ use curve25519_dalek_derive::unsafe_target_feature;
|
||||||
|
|
||||||
struct S;
|
struct S;
|
||||||
|
|
||||||
|
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||||
#[unsafe_target_feature("avx2")]
|
#[unsafe_target_feature("avx2")]
|
||||||
impl core::ops::Add for S {
|
impl core::ops::Add for S {
|
||||||
type Output = S;
|
type Output = S;
|
||||||
|
|
@ -135,6 +140,7 @@ impl core::ops::Add for S {
|
||||||
```rust
|
```rust
|
||||||
use curve25519_dalek_derive::unsafe_target_feature_specialize;
|
use curve25519_dalek_derive::unsafe_target_feature_specialize;
|
||||||
|
|
||||||
|
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||||
#[unsafe_target_feature_specialize("sse2", "avx2", conditional("avx512ifma", nightly))]
|
#[unsafe_target_feature_specialize("sse2", "avx2", conditional("avx512ifma", nightly))]
|
||||||
mod simd {
|
mod simd {
|
||||||
#[for_target_feature("sse2")]
|
#[for_target_feature("sse2")]
|
||||||
|
|
@ -149,6 +155,7 @@ mod simd {
|
||||||
pub fn func() { /* ... */ }
|
pub fn func() { /* ... */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||||
fn entry_point() {
|
fn entry_point() {
|
||||||
#[cfg(nightly)]
|
#[cfg(nightly)]
|
||||||
if std::is_x86_feature_detected!("avx512ifma") {
|
if std::is_x86_feature_detected!("avx512ifma") {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue