Skip to content

Commit ce3afbf

Browse files
committed
add runtime-feature detection for tsc
1 parent d83dcc3 commit ce3afbf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

coresimd/src/runtime/x86.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ macro_rules! __unstable_detect_feature {
3232
("aes", $unstable_detect_feature:path) => {
3333
$unstable_detect_feature(
3434
$crate::__vendor_runtime::__Feature::aes{}) };
35+
("tsc", $unstable_detect_feature:path) => {
36+
$unstable_detect_feature(
37+
$crate::__vendor_runtime::__Feature::tsc{}) };
3538
("mmx", $unstable_detect_feature:path) => {
3639
$unstable_detect_feature(
3740
$crate::__vendor_runtime::__Feature::mmx{}) };
@@ -173,6 +176,8 @@ macro_rules! __unstable_detect_feature {
173176
pub enum __Feature {
174177
/// AES (Advanced Encryption Standard New Instructions AES-NI)
175178
aes,
179+
/// TSC (Time Stamp Counter)
180+
tsc,
176181
/// MMX
177182
mmx,
178183
/// SSE (Streaming SIMD Extensions)
@@ -346,8 +351,9 @@ pub fn detect_features() -> usize {
346351
enable(proc_info_ecx, 20, __Feature::sse4_2);
347352
enable(proc_info_ecx, 23, __Feature::popcnt);
348353
enable(proc_info_ecx, 25, __Feature::aes);
349-
enable(proc_info_edx, 24, __Feature::fxsr);
354+
enable(proc_info_edx, 4, __Feature::tsc);
350355
enable(proc_info_edx, 23, __Feature::mmx);
356+
enable(proc_info_edx, 24, __Feature::fxsr);
351357
enable(proc_info_edx, 25, __Feature::sse);
352358
enable(proc_info_edx, 26, __Feature::sse2);
353359

@@ -457,6 +463,7 @@ mod tests {
457463
#[test]
458464
fn dump() {
459465
println!("aes: {:?}", cfg_feature_enabled!("aes"));
466+
println!("tsc: {:?}", cfg_feature_enabled!("tsc"));
460467
println!("sse: {:?}", cfg_feature_enabled!("sse"));
461468
println!("sse2: {:?}", cfg_feature_enabled!("sse2"));
462469
println!("sse3: {:?}", cfg_feature_enabled!("sse3"));
@@ -497,6 +504,7 @@ mod tests {
497504
fn compare_with_cupid() {
498505
let information = cupid::master().unwrap();
499506
assert_eq!(cfg_feature_enabled!("aes"), information.aesni());
507+
assert_eq!(cfg_feature_enabled!("tsc"), information.tsc());
500508
assert_eq!(cfg_feature_enabled!("sse"), information.sse());
501509
assert_eq!(cfg_feature_enabled!("sse2"), information.sse2());
502510
assert_eq!(cfg_feature_enabled!("sse3"), information.sse3());

0 commit comments

Comments
 (0)