aboutsummaryrefslogtreecommitdiff
path: root/bbot/utility.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-04-10 13:16:11 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-04-10 13:16:11 +0200
commit810df40a0625835ad17a0a5bf3232a8d1a68e680 (patch)
tree1dc320fd821ce30a0a037b7fae151e1f027d0bbd /bbot/utility.cxx
parent36e0c88e7a3912c8a2e6594841172adb9c14525b (diff)
Implement vm startup and shutdown
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);
+ }
+ }
}