forked from OSchip/llvm-project
[libc] Use a wrapper for rand instead of calling std::rand in fma tests.
Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D94198
This commit is contained in:
parent
41d919aa29
commit
f9e858f5fd
|
@ -13,8 +13,7 @@
|
|||
#include "utils/FPUtil/TestHelpers.h"
|
||||
#include "utils/MPFRWrapper/MPFRUtils.h"
|
||||
#include "utils/UnitTest/Test.h"
|
||||
|
||||
#include <random>
|
||||
#include "utils/testutils/RandUtils.h"
|
||||
|
||||
namespace mpfr = __llvm_libc::testing::mpfr;
|
||||
|
||||
|
@ -32,8 +31,9 @@ private:
|
|||
|
||||
UIntType getRandomBitPattern() {
|
||||
UIntType bits{0};
|
||||
for (size_t i = 0; i < sizeof(UIntType) / 2; ++i) {
|
||||
bits = (bits << 2) + static_cast<uint16_t>(std::rand());
|
||||
for (UIntType i = 0; i < sizeof(UIntType) / 2; ++i) {
|
||||
bits =
|
||||
(bits << 2) + static_cast<uint16_t>(__llvm_libc::testutils::rand());
|
||||
}
|
||||
return bits;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ endif()
|
|||
|
||||
add_llvm_library(
|
||||
libc_test_utils
|
||||
RandUtils.cpp
|
||||
RandUtils.h
|
||||
StreamWrapper.cpp
|
||||
StreamWrapper.h
|
||||
${EFFile}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
//===-- RandUtils.cpp -----------------------------------------------------===//
|
||||
//
|
||||
// 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 "RandUtils.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace __llvm_libc {
|
||||
namespace testutils {
|
||||
|
||||
int rand() { return std::rand(); }
|
||||
|
||||
} // namespace testutils
|
||||
} // namespace __llvm_libc
|
|
@ -0,0 +1,16 @@
|
|||
//===-- RandUtils.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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace __llvm_libc {
|
||||
namespace testutils {
|
||||
|
||||
// Wrapper for std::rand.
|
||||
int rand();
|
||||
|
||||
} // namespace testutils
|
||||
} // namespace __llvm_libc
|
Loading…
Reference in New Issue