diff options
| author | gatecat <gatecat@ds0.me> | 2021-11-19 21:45:07 +0000 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-19 21:45:07 +0000 | 
| commit | f5cc959c4efdc4e6922bc0a7bcbc9eb38c37248e (patch) | |
| tree | f440b93c08d4e38dedb58f8812ab8d447e8b620c | |
| parent | b7207b088539e7b5f34ebbd9f53f9fa14bef6e62 (diff) | |
| parent | b3edf81f6c6c8f239cfee6432b82519169c558ea (diff) | |
| download | nextpnr-f5cc959c4efdc4e6922bc0a7bcbc9eb38c37248e.tar.gz nextpnr-f5cc959c4efdc4e6922bc0a7bcbc9eb38c37248e.tar.bz2 nextpnr-f5cc959c4efdc4e6922bc0a7bcbc9eb38c37248e.zip | |
Merge pull request #862 from DX-MON/master
common: Improved the random seed initialisation for the context
| -rw-r--r-- | common/command.cc | 10 | 
1 files 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 <boost/program_options.hpp>  #include <fstream>  #include <iostream> +#include <random>  #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<int> distrib{1}; +        ctx->rngseed(distrib(randDev));      }      if (vm.count("slack_redist_iter")) { | 
