hanchenye-llvm-project/compiler-rt/include
Max Moroz df3b465c9c [compiler-rt] Add ConsumeProbability and ConsumeFloatingPoint methods to FDP.
Summary:
Also slightly cleaned up the comments and changed the header's extension
back to `.h` as per comments on https://reviews.llvm.org/D65812.

New methods added:

* `ConsumeProbability` returns [0.0, 1.0] by consuming an unsigned integer value
   from the input data and dividing that value by the integer's max value.
* `ConsumeFloatingPointInRange` returns a floating point value in the given
   range. Relies on `ConsumeProbability` method. This method does not have the
   limitation of `std::uniform_real_distribution` that requires the given range
   to be <= the floating point type's max. If the range is too large, this
   implementation will additionally call `ConsumeBool` to decide whether the
   result will be in the first or the second half of the range.
* `ConsumeFloatingPoint` returns a floating point value in the range
  `[std::numeric_limits<T>::lowest(), std::numeric_limits<T>::min()]`.

Tested on Linux, Mac, Windows.


Reviewers: morehouse

Reviewed By: morehouse

Subscribers: kubamracek, mgorny, dberris, delcypher, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

Differential Revision: https://reviews.llvm.org/D65905

llvm-svn: 368331
2019-08-08 19:49:37 +00:00
..
fuzzer [compiler-rt] Add ConsumeProbability and ConsumeFloatingPoint methods to FDP. 2019-08-08 19:49:37 +00:00
sanitizer [dfsan] Introduce dfsan_flush(). 2019-06-13 20:11:06 +00:00
xray Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CMakeLists.txt [compiler-rt] Add ConsumeProbability and ConsumeFloatingPoint methods to FDP. 2019-08-08 19:49:37 +00:00