LHASH revamp. make depend.
[openssl.git] / crypto / x86_64cpuid.pl
index bc06e99cfb732280f0fbab87a9fa3d49d90d0872..331529ae592ea3a41a0053aaf3027f2c2a65aebf 100644 (file)
@@ -99,7 +99,10 @@ OPENSSL_wipe_cpu:
 
 ___
 
-open STDOUT,"| $^X perlasm/x86_64-xlate.pl $output";
+$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
+$dir = "." if $dir eq "";
+open STDOUT,"| $^X $dir/perlasm/x86_64-xlate.pl $output";
+
 print<<___;
 .text
 
@@ -134,16 +137,16 @@ OPENSSL_ia32_cpuid:
 
        mov     \$1,%eax
        cpuid
-       bt      \$28,%edx               # test hyper-threading bit
-       jnc     .Ldone
        cmp     \$0,%r9d
        jne     .Lnotintel
-       or      \$1<<20,%edx            # use reserved bit to engage RC4_CHAR
+       or      \$0x00100000,%edx       # use reserved 20th bit to engage RC4_CHAR
        and     \$15,%ah
        cmp     \$15,%ah                # examine Family ID
        je      .Lnotintel
-       or      \$1<<30,%edx            # use reserved bit to skip unrolled loop
+       or      \$0x40000000,%edx       # use reserved bit to skip unrolled loop
 .Lnotintel:
+       bt      \$28,%edx               # test hyper-threading bit
+       jnc     .Ldone
        shr     \$16,%ebx
        cmp     \$1,%bl                 # see if cache is shared
        ja      .Ldone
@@ -155,4 +158,37 @@ OPENSSL_ia32_cpuid:
        or      %rcx,%rax
        ret
 .size  OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid
+
+.globl  OPENSSL_cleanse
+.type   OPENSSL_cleanse,\@function,2
+.align  16
+OPENSSL_cleanse:
+       xor     %rax,%rax
+       cmp     \$15,%rsi
+       jae     .Lot
+.Little:
+       mov     %al,(%rdi)
+       sub     \$1,%rsi
+       lea     1(%rdi),%rdi
+       jnz     .Little
+       ret
+.align 16
+.Lot:
+       test    \$7,%rdi
+       jz      .Laligned
+       mov     %al,(%rdi)
+       lea     -1(%rsi),%rsi
+       lea     1(%rdi),%rdi
+       jmp     .Lot
+.Laligned:
+       mov     %rax,(%rdi)
+       lea     -8(%rsi),%rsi
+       test    \$-8,%rsi
+       lea     8(%rdi),%rdi
+       jnz     .Laligned
+       cmp     \$0,%rsi
+       jne     .Little
+       ret
+.size  OPENSSL_cleanse,.-OPENSSL_cleanse
 ___
+close STDOUT;  # flush