@@ -34,6 +34,12 @@ macro_rules! is_target_feature_detected {
3434 ( "pclmulqdq" ) => {
3535 $crate:: arch:: detect:: check_for(
3636 $crate:: arch:: detect:: Feature :: pclmulqdq) } ;
37+ ( "rdrand" ) => {
38+ $crate:: arch:: detect:: check_for(
39+ $crate:: arch:: detect:: Feature :: rdrand) } ;
40+ ( "rdseed" ) => {
41+ $crate:: arch:: detect:: check_for(
42+ $crate:: arch:: detect:: Feature :: rdseed) } ;
3743 ( "tsc" ) => {
3844 $crate:: arch:: detect:: check_for(
3945 $crate:: arch:: detect:: Feature :: tsc) } ;
@@ -180,6 +186,10 @@ pub enum Feature {
180186 aes,
181187 /// CLMUL (Carry-less Multiplication)
182188 pclmulqdq,
189+ /// RDRAND
190+ rdrand,
191+ /// RDSEED
192+ rdseed,
183193 /// TSC (Time Stamp Counter)
184194 tsc,
185195 /// MMX
@@ -352,6 +362,8 @@ pub fn detect_features() -> cache::Initializer {
352362 enable ( proc_info_ecx, 23 , Feature :: popcnt) ;
353363 enable ( proc_info_ecx, 25 , Feature :: aes) ;
354364 enable ( proc_info_ecx, 1 , Feature :: pclmulqdq) ;
365+ enable ( proc_info_ecx, 30 , Feature :: rdrand) ;
366+ enable ( extended_features_ebx, 18 , Feature :: rdseed) ;
355367 enable ( proc_info_edx, 4 , Feature :: tsc) ;
356368 enable ( proc_info_edx, 23 , Feature :: mmx) ;
357369 enable ( proc_info_edx, 24 , Feature :: fxsr) ;
@@ -465,6 +477,8 @@ mod tests {
465477 fn dump ( ) {
466478 println ! ( "aes: {:?}" , is_target_feature_detected!( "aes" ) ) ;
467479 println ! ( "pclmulqdq: {:?}" , is_target_feature_detected!( "pclmulqdq" ) ) ;
480+ println ! ( "rdrand: {:?}" , is_target_feature_detected!( "rdrand" ) ) ;
481+ println ! ( "rdseed: {:?}" , is_target_feature_detected!( "rdseed" ) ) ;
468482 println ! ( "tsc: {:?}" , is_target_feature_detected!( "tsc" ) ) ;
469483 println ! ( "sse: {:?}" , is_target_feature_detected!( "sse" ) ) ;
470484 println ! ( "sse2: {:?}" , is_target_feature_detected!( "sse2" ) ) ;
@@ -507,6 +521,8 @@ mod tests {
507521 let information = cupid:: master ( ) . unwrap ( ) ;
508522 assert_eq ! ( is_target_feature_detected!( "aes" ) , information. aesni( ) ) ;
509523 assert_eq ! ( is_target_feature_detected!( "pclmulqdq" ) , information. pclmulqdq( ) ) ;
524+ assert_eq ! ( is_target_feature_detected!( "rdrand" ) , information. rdrand( ) ) ;
525+ assert_eq ! ( is_target_feature_detected!( "rdseed" ) , information. rdseed( ) ) ;
510526 assert_eq ! ( is_target_feature_detected!( "tsc" ) , information. tsc( ) ) ;
511527 assert_eq ! ( is_target_feature_detected!( "sse" ) , information. sse( ) ) ;
512528 assert_eq ! ( is_target_feature_detected!( "sse2" ) , information. sse2( ) ) ;
0 commit comments