aboutsummaryrefslogtreecommitdiff
path: root/bbot/utility.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'bbot/utility.cxx')
-rw-r--r--bbot/utility.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/bbot/utility.cxx b/bbot/utility.cxx
index 591ff52..95c31e9 100644
--- a/bbot/utility.cxx
+++ b/bbot/utility.cxx
@@ -4,6 +4,9 @@
#include <bbot/utility>
+#include <chrono>
+#include <cstdlib> // rand_r()
+
#include <bbot/diagnostics>
using namespace std;
@@ -11,4 +14,25 @@ using namespace butl;
namespace bbot
{
+ static unsigned int rand_seed; // Seed for rand_r();
+
+ size_t
+ genrand ()
+ {
+ if (rand_seed == 0)
+ rand_seed = static_cast<unsigned int> (
+ chrono::system_clock::now ().time_since_epoch ().count ());
+
+ return static_cast<size_t> (rand_r (&rand_seed));
+ }
+
+ void
+ run_trace (tracer& t, const char* cmd[], size_t n)
+ {
+ if (verb >= 2)
+ {
+ diag_record dr (t);
+ process::print (dr.os, cmd, n);
+ }
+ }
}