[libc-commits] [PATCH] D94198: [libc] Use a wrapper for rand instead of calling std::rand in fma tests.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jan 6 15:08:11 PST 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf9e858f5fd74: [libc] Use a wrapper for rand instead of calling std::rand in fma tests. (authored by sivachandra).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94198/new/

https://reviews.llvm.org/D94198

Files:
  libc/test/src/math/FmaTest.h
  libc/utils/testutils/CMakeLists.txt
  libc/utils/testutils/RandUtils.cpp
  libc/utils/testutils/RandUtils.h


Index: libc/utils/testutils/RandUtils.h
===================================================================
--- /dev/null
+++ libc/utils/testutils/RandUtils.h
@@ -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
Index: libc/utils/testutils/RandUtils.cpp
===================================================================
--- /dev/null
+++ libc/utils/testutils/RandUtils.cpp
@@ -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
Index: libc/utils/testutils/CMakeLists.txt
===================================================================
--- libc/utils/testutils/CMakeLists.txt
+++ libc/utils/testutils/CMakeLists.txt
@@ -5,6 +5,8 @@
 
 add_llvm_library(
   libc_test_utils
+  RandUtils.cpp
+  RandUtils.h
   StreamWrapper.cpp
   StreamWrapper.h
   ${EFFile}
Index: libc/test/src/math/FmaTest.h
===================================================================
--- libc/test/src/math/FmaTest.h
+++ libc/test/src/math/FmaTest.h
@@ -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 @@
 
   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;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94198.315003.patch
Type: text/x-patch
Size: 2577 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210106/cdb59ee3/attachment-0001.bin>


More information about the libc-commits mailing list