added clflush after explicit_bzero on x86 nightly builds

ffi
Avril 4 years ago
parent c0d7234b5a
commit 1ecf0eab91
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -17,3 +17,6 @@ base64 = "0.13"
getrandom = "0.2"
openssl = "0.10"
smallvec = {version = "1.6", features=["union"], optional = true}
[build-dependencies]
rustc_version = "0.2"

@ -0,0 +1,24 @@
extern crate rustc_version;
use rustc_version::{version, version_meta, Channel};
fn main() {
// Assert we haven't travelled back in time
assert!(version().unwrap().major >= 1);
// Set cfg flags depending on release channel
match version_meta().unwrap().channel {
Channel::Stable => {
println!("cargo:rustc-cfg=stable");
}
Channel::Beta => {
println!("cargo:rustc-cfg=beta");
}
Channel::Nightly => {
println!("cargo:rustc-cfg=nightly");
}
Channel::Dev => {
println!("cargo:rustc-cfg=dev");
}
}
}

@ -1,3 +1,5 @@
#![cfg_attr(nightly, feature(asm))]
#![allow(dead_code)]
//extern crate test;

@ -128,6 +128,14 @@ where W: Write
}
unsafe {
explicit_bzero(self.buffer.as_mut_ptr() as *mut c_void, self.buffer.len());
#[cfg(nightly)]
if cfg!(target_arch = "x86_64") || cfg!(target_arch = "x86"){
asm!(
"clflush [{}]",
in(reg) self.buffer.as_mut_ptr()
);
}
}
return;
}

Loading…
Cancel
Save