From 8f3cadc28cb2bb9e8f9d69eeaaea1f57f2f7b2ab Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Tue, 20 Aug 2019 20:51:06 +0000 Subject: Vendor import of stripped compiler-rt trunk r366426 (just before the release_90 branch point): https://llvm.org/svn/llvm-project/compiler-rt/trunk@366426 --- lib/gwp_asan/random.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/gwp_asan/random.cpp (limited to 'lib/gwp_asan/random.cpp') diff --git a/lib/gwp_asan/random.cpp b/lib/gwp_asan/random.cpp new file mode 100644 index 000000000000..90493da7e038 --- /dev/null +++ b/lib/gwp_asan/random.cpp @@ -0,0 +1,23 @@ +//===-- 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 "gwp_asan/guarded_pool_allocator.h" + +#include + +namespace gwp_asan { +uint32_t getRandomUnsigned32() { + thread_local uint32_t RandomState = + time(nullptr) + GuardedPoolAllocator::getThreadID(); + RandomState ^= RandomState << 13; + RandomState ^= RandomState >> 17; + RandomState ^= RandomState << 5; + return RandomState; +} +} // namespace gwp_asan -- cgit v1.2.3