Initial commit
[authen-passphrase-scrypt.git] / scrypt-1.2.1 / libcperciva / cpusupport / cpusupport_x86_aesni.c
CommitLineData
0c1f3509
MG
1#include "cpusupport.h"
2
3#ifdef CPUSUPPORT_X86_CPUID
4#include <cpuid.h>
5
6#define CPUID_AESNI_BIT (1 << 25)
7#endif
8
9CPUSUPPORT_FEATURE_DECL(x86, aesni)
10{
11#ifdef CPUSUPPORT_X86_CPUID
12 unsigned int eax, ebx, ecx, edx;
13
14 /* Check if CPUID supports the level we need. */
15 if (!__get_cpuid(0, &eax, &ebx, &ecx, &edx))
16 goto unsupported;
17 if (eax < 1)
18 goto unsupported;
19
20 /* Ask about CPU features. */
21 if (!__get_cpuid(1, &eax, &ebx, &ecx, &edx))
22 goto unsupported;
23
24 /* Return the relevant feature bit. */
25 return ((ecx & CPUID_AESNI_BIT) ? 1 : 0);
26
27unsupported:
28#endif
29 return (0);
30}
This page took 0.011438 seconds and 4 git commands to generate.