1//===-- random.cpp ----------------------------------------------*- C++ -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8 9#include "gwp_asan/random.h" 10#include "gwp_asan/guarded_pool_allocator.h" 11 12#include <time.h> 13 14namespace gwp_asan { 15uint32_t getRandomUnsigned32() { 16 thread_local uint32_t RandomState = 17 time(nullptr) + GuardedPoolAllocator::getThreadID(); 18 RandomState ^= RandomState << 13; 19 RandomState ^= RandomState >> 17; 20 RandomState ^= RandomState << 5; 21 return RandomState; 22} 23} // namespace gwp_asan 24