[GWP-ASan] Initial build files, implementation of PRNG [1]. am: afc02ff020 am: 87412234db
am: 7da1e9b706

Change-Id: Icbf65a552552603eee798840b5136a6683980e36
diff --git a/gwp_asan/random.cpp b/gwp_asan/random.cpp
new file mode 100644
index 0000000..625973c
--- /dev/null
+++ b/gwp_asan/random.cpp
@@ -0,0 +1,21 @@
+//===-- random.cpp ----------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "gwp_asan/random.h"
+
+#include <ctime>
+
+namespace gwp_asan {
+uint32_t getRandomUnsigned32() {
+  thread_local uint32_t RandomState = static_cast<uint64_t>(time(nullptr));
+  RandomState ^= RandomState << 13;
+  RandomState ^= RandomState >> 17;
+  RandomState ^= RandomState << 5;
+  return RandomState;
+}
+} // namespace gwp_asan
diff --git a/gwp_asan/random.h b/gwp_asan/random.h
new file mode 100644
index 0000000..a71f3e5
--- /dev/null
+++ b/gwp_asan/random.h
@@ -0,0 +1,20 @@
+//===-- random.h ------------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef GWP_ASAN_RANDOM_H_
+#define GWP_ASAN_RANDOM_H_
+
+#include <cstdint>
+
+namespace gwp_asan {
+// xorshift (32-bit output), extremely fast PRNG that uses arithmetic operations
+// only. Seeded using walltime.
+uint32_t getRandomUnsigned32();
+} // namespace gwp_asan
+
+#endif // GWP_ASAN_RANDOM_H_