-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reimplement detection of CPU features, Don't use Cpuid
- Loading branch information
Showing
7 changed files
with
61 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "mirage_crypto.h" | ||
|
||
#ifdef __mc_ACCELERATE__ | ||
|
||
#include <cpuid.h> | ||
|
||
struct _mc_cpu_features mc_detected_cpu_features = { 0 }; | ||
|
||
CAMLprim value | ||
mc_detect_cpu_features (__unit ()) { | ||
unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0; | ||
|
||
if (__get_cpuid(1, &eax, &ebx, &ecx, &edx)) | ||
{ | ||
if (ecx & bit_PCLMUL) | ||
mc_detected_cpu_features.pclmul = 1; | ||
if (ecx & bit_SSSE3) | ||
mc_detected_cpu_features.ssse3 = 1; | ||
if (ecx & bit_AES) | ||
mc_detected_cpu_features.aesni = 1; | ||
} | ||
return Val_unit; | ||
} | ||
|
||
#else /* __mc_ACCELERATE__ */ | ||
|
||
CAMLprim value | ||
mc_detect_cpu_features (__unit ()) { | ||
return Val_unit; | ||
} | ||
|
||
#endif /* __mc_ACCELERATE__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters