x86cpuid.pl: don't punish "last-year" OSes on "this-year" CPUs.
[openssl.git] / crypto / x86cpuid.pl
index 70c8a2d671a50ee3347672e2278eb273507c94b8..168e4fa0a9b3b02caa66f110f42aec0cd2de9eb7 100644 (file)
@@ -122,7 +122,7 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
        &bt     ("ecx",26);             # check XSAVE bit
        &jnc    (&label("done"));
        &bt     ("ecx",27);             # check OSXSAVE bit
-       &jnc    (&label("clear_xmm"));
+       &jnc    (&label("clear_avx"));
        &xor    ("ecx","ecx");
        &data_byte(0x0f,0x01,0xd0);     # xgetbv
        &and    ("eax",6);
@@ -442,6 +442,18 @@ my $max = "ebp";
 &function_end("OPENSSL_instrument_bus2");
 }
 
+&function_begin_B("OPENSSL_ia32_rdrand");
+       &mov    ("ecx",8);
+&set_label("loop");
+       &rdrand ("eax");
+       &jc     (&label("break"));
+       &loop   (&label("loop"));
+&set_label("break");
+       &cmp    ("eax",0);
+       &cmove  ("eax","ecx");
+       &ret    ();
+&function_end_B("OPENSSL_ia32_rdrand");
+
 &initseg("OPENSSL_cpuid_setup");
 
 &asm_finish();