-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
48 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
OPTION(ENABLE_RDSEED "Use RDSEED for True Randomness" ON) | ||
OPTION(USE_RANDOM_DEVICE "Option description" OFF) | ||
|
||
include(CheckCSourceRuns) | ||
|
||
# Use rdseed if available | ||
unset(RDSEED_COMPILE_RESULT CACHE) | ||
unset(RDSEED_RUN_RESULT CACHE) | ||
file(WRITE ${CMAKE_SOURCE_DIR}/rdseedtest.c "#include <stdio.h>\n#include <x86intrin.h>\nint main(){\nunsigned long long r;\n_rdseed64_step(&r);\nreturn 0;\n}\n") | ||
try_run(RDSEED_RUN_RESULT RDSEED_COMPILE_RESULT ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/rdseedtest.c CMAKE_FLAGS ${CMAKE_C_FLAGS}) | ||
file(REMOVE ${CMAKE_SOURCE_DIR}/rdseedtest.c) | ||
string(COMPARE EQUAL "${RDSEED_RUN_RESULT}" "0" RDSEED_RUN_SUCCESS) | ||
set(CMAKE_REQUIRED_FLAGS "-mrdseed") # in case CMAKE_C_FLAGS doesn't have it, ex. if add_compile_options is used instead | ||
check_c_source_runs("#include <x86intrin.h>\nint main(){\nunsigned long long r;\n_rdseed64_step(&r);\nreturn 0;\n}\n" RDSEED_RUN_RESULT) | ||
|
||
IF(NOT ${RDSEED_COMPILE_RESULT} OR NOT ${RDSEED_RUN_SUCCESS}) | ||
set(ENABLE_RDSEED OFF) | ||
ENDIF(NOT ${RDSEED_COMPILE_RESULT} OR NOT ${RDSEED_RUN_SUCCESS}) | ||
string(COMPARE EQUAL "${RDSEED_RUN_RESULT}" "1" RDSEED_RUN_SUCCESS) | ||
IF(NOT ${RDSEED_RUN_SUCCESS}) | ||
set(USE_RANDOM_DEVICE ON) | ||
ENDIF(NOT ${RDSEED_RUN_SUCCESS}) | ||
|
||
IF(${ENABLE_RDSEED}) | ||
ADD_DEFINITIONS(-DEMP_ENABLE_RDSEED) | ||
message("${Green}-- Source of Randomness: rdseed${ColourReset}") | ||
ELSE(${ENABLE_RDSEED}) | ||
IF(${USE_RANDOM_DEVICE}) | ||
ADD_DEFINITIONS(-DEMP_USE_RANDOM_DEVICE) | ||
message("${Red}-- Source of Randomness: random_device${ColourReset}") | ||
ENDIF(${ENABLE_RDSEED}) | ||
|
||
ELSE(${USE_RANDOM_DEVICE}) | ||
message("${Green}-- Source of Randomness: rdseed${ColourReset}") | ||
ENDIF(${USE_RANDOM_DEVICE}) |
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