[libc-commits] [libc] ac8ed7f - [libc] Remove RandUtils.(h|cpp). (#88044)

via libc-commits libc-commits at lists.llvm.org
Mon Apr 8 14:25:35 PDT 2024


Author: lntue
Date: 2024-04-08T17:25:32-04:00
New Revision: ac8ed7f16e5355d7062535afc08ff4be15875c47

URL: https://github.com/llvm/llvm-project/commit/ac8ed7f16e5355d7062535afc08ff4be15875c47
DIFF: https://github.com/llvm/llvm-project/commit/ac8ed7f16e5355d7062535afc08ff4be15875c47.diff

LOG: [libc] Remove RandUtils.(h|cpp). (#88044)

Added: 
    

Modified: 
    libc/test/src/CMakeLists.txt
    libc/test/src/math/CMakeLists.txt
    libc/test/src/math/FmaTest.h

Removed: 
    libc/test/src/math/RandUtils.cpp
    libc/test/src/math/RandUtils.h


################################################################################
diff  --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt
index 95f1768c96aac3..a5e7a2a4dee725 100644
--- a/libc/test/src/CMakeLists.txt
+++ b/libc/test/src/CMakeLists.txt
@@ -24,7 +24,7 @@ function(add_fp_unittest name)
       message(FATAL_ERROR "Hermetic math test cannot require MPFR.")
     endif()
     set(test_type UNIT_TEST_ONLY)
-    list(APPEND MATH_UNITTEST_LINK_LIBRARIES libcMPFRWrapper libc_math_test_utils -lmpfr -lgmp)
+    list(APPEND MATH_UNITTEST_LINK_LIBRARIES libcMPFRWrapper -lmpfr -lgmp)
   endif()
   list(APPEND MATH_UNITTEST_LINK_LIBRARIES LibcFPTestHelpers)
 

diff  --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 01416eefc15ef8..274018e59da5ac 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -1,15 +1,5 @@
 add_custom_target(libc-math-unittests)
 
-# FIXME: We shouldn't have regular libraries created because we could be
-#        cross-compiling the tests and running through an emulator.
-if(NOT LIBC_TARGET_OS_IS_GPU)
-  add_library(
-    libc_math_test_utils
-    RandUtils.cpp
-    RandUtils.h
-  )
-endif()
-
 add_fp_unittest(
   cosf_test
   NEED_MPFR
@@ -1280,6 +1270,7 @@ add_fp_unittest(
     fmaf_test.cpp
   DEPENDS
     libc.src.math.fmaf
+    libc.src.stdlib.rand
     libc.src.__support.FPUtil.fp_bits
   FLAGS
     FMA_OPT__ONLY
@@ -1294,6 +1285,7 @@ add_fp_unittest(
     fma_test.cpp
   DEPENDS
     libc.src.math.fma
+    libc.src.stdlib.rand
     libc.src.__support.FPUtil.fp_bits
 )
 

diff  --git a/libc/test/src/math/FmaTest.h b/libc/test/src/math/FmaTest.h
index 0c93ec858a12cd..a3b1c9bb8f9b8f 100644
--- a/libc/test/src/math/FmaTest.h
+++ b/libc/test/src/math/FmaTest.h
@@ -10,9 +10,9 @@
 #define LLVM_LIBC_TEST_SRC_MATH_FMATEST_H
 
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/stdlib/rand.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
-#include "test/src/math/RandUtils.h"
 #include "utils/MPFRWrapper/MPFRUtils.h"
 
 namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
@@ -43,8 +43,7 @@ class FmaTestTemplate : public LIBC_NAMESPACE::testing::Test {
   StorageType get_random_bit_pattern() {
     StorageType bits{0};
     for (StorageType i = 0; i < sizeof(StorageType) / 2; ++i) {
-      bits = (bits << 2) +
-             static_cast<uint16_t>(LIBC_NAMESPACE::testutils::rand());
+      bits = (bits << 2) + static_cast<uint16_t>(LIBC_NAMESPACE::rand());
     }
     return bits;
   }

diff  --git a/libc/test/src/math/RandUtils.cpp b/libc/test/src/math/RandUtils.cpp
deleted file mode 100644
index 0d09764f6056d6..00000000000000
--- a/libc/test/src/math/RandUtils.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- 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 LIBC_NAMESPACE {
-namespace testutils {
-
-int rand() { return std::rand(); }
-
-} // namespace testutils
-} // namespace LIBC_NAMESPACE

diff  --git a/libc/test/src/math/RandUtils.h b/libc/test/src/math/RandUtils.h
deleted file mode 100644
index fecbd8eaabf2cd..00000000000000
--- a/libc/test/src/math/RandUtils.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIBC_TEST_SRC_MATH_RANDUTILS_H
-#define LLVM_LIBC_TEST_SRC_MATH_RANDUTILS_H
-
-namespace LIBC_NAMESPACE {
-namespace testutils {
-
-// Wrapper for std::rand.
-int rand();
-
-} // namespace testutils
-} // namespace LIBC_NAMESPACE
-
-#endif // LLVM_LIBC_TEST_SRC_MATH_RANDUTILS_H


        


More information about the libc-commits mailing list