From b3edf81f6c6c8f239cfee6432b82519169c558ea Mon Sep 17 00:00:00 2001 From: dx-mon Date: Fri, 12 Nov 2021 10:31:47 -0500 Subject: common: Improved the random seed initialisation for the context --- common/command.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/common/command.cc b/common/command.cc index 38de8344..5a13fb55 100644 --- a/common/command.cc +++ b/common/command.cc @@ -33,6 +33,7 @@ #include #include #include +#include #include "command.h" #include "design_utils.h" #include "json_frontend.h" @@ -223,12 +224,9 @@ void CommandHandler::setupContext(Context *ctx) } if (vm.count("randomize-seed")) { - srand(time(NULL)); - int r; - do { - r = rand(); - } while (r == 0); - ctx->rngseed(r); + std::random_device randDev{}; + std::uniform_int_distribution distrib{1}; + ctx->rngseed(distrib(randDev)); } if (vm.count("slack_redist_iter")) { -- cgit v1.2.3