[GWP-ASan] Initial build files, implementation of PRNG [1].
Summary:
See D60593 for further information.
This patch slices off the PRNG implementation and the initial build files for GWP-ASan.
Reviewers: vlad.tsyrklevich, morehouse, vitalybuka
Reviewed By: morehouse
Subscribers: srhines, kubamracek, mgorny, #sanitizers, llvm-commits, cryptoad, eugenis
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D61867
llvm-svn: 360710
2019-05-15 05:43:11 +08:00
|
|
|
//===-- 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"
|
2019-07-17 04:06:17 +08:00
|
|
|
#include "gwp_asan/guarded_pool_allocator.h"
|
[GWP-ASan] Initial build files, implementation of PRNG [1].
Summary:
See D60593 for further information.
This patch slices off the PRNG implementation and the initial build files for GWP-ASan.
Reviewers: vlad.tsyrklevich, morehouse, vitalybuka
Reviewed By: morehouse
Subscribers: srhines, kubamracek, mgorny, #sanitizers, llvm-commits, cryptoad, eugenis
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D61867
llvm-svn: 360710
2019-05-15 05:43:11 +08:00
|
|
|
|
[GWP-ASan] Fixed issue with c++ standard library dependency.
Summary:
Removed dependency on c++ standard library. Some supporting allocators (namely Scudo on Fuchsia, and shortly, scudo standalone) has a hard requirement of no c++stdlib.
This patch updates the build system so that we don't have any c++ stdlib dependencies. It also will conveniently fix a racy build-order bug discrepency between GWP-ASan and libc++.
Reviewers: phosek, morehouse
Reviewed By: phosek, morehouse
Subscribers: kubamracek, mgorny, cryptoad, #sanitizers, llvm-commits, beanz, smeenai, vitalybuka
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D62048
llvm-svn: 360982
2019-05-17 11:20:53 +08:00
|
|
|
#include <time.h>
|
[GWP-ASan] Initial build files, implementation of PRNG [1].
Summary:
See D60593 for further information.
This patch slices off the PRNG implementation and the initial build files for GWP-ASan.
Reviewers: vlad.tsyrklevich, morehouse, vitalybuka
Reviewed By: morehouse
Subscribers: srhines, kubamracek, mgorny, #sanitizers, llvm-commits, cryptoad, eugenis
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D61867
llvm-svn: 360710
2019-05-15 05:43:11 +08:00
|
|
|
|
|
|
|
namespace gwp_asan {
|
|
|
|
uint32_t getRandomUnsigned32() {
|
2019-07-17 04:06:17 +08:00
|
|
|
thread_local uint32_t RandomState =
|
|
|
|
time(nullptr) + GuardedPoolAllocator::getThreadID();
|
[GWP-ASan] Initial build files, implementation of PRNG [1].
Summary:
See D60593 for further information.
This patch slices off the PRNG implementation and the initial build files for GWP-ASan.
Reviewers: vlad.tsyrklevich, morehouse, vitalybuka
Reviewed By: morehouse
Subscribers: srhines, kubamracek, mgorny, #sanitizers, llvm-commits, cryptoad, eugenis
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D61867
llvm-svn: 360710
2019-05-15 05:43:11 +08:00
|
|
|
RandomState ^= RandomState << 13;
|
|
|
|
RandomState ^= RandomState >> 17;
|
|
|
|
RandomState ^= RandomState << 5;
|
|
|
|
return RandomState;
|
|
|
|
}
|
|
|
|
} // namespace gwp_asan
|