[compiler-rt] facf22b - [fuzzer] Platfom specific version of PageSize

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Thu May 25 21:00:27 PDT 2023


Author: Vitaly Buka
Date: 2023-05-25T21:00:14-07:00
New Revision: facf22b8b07b9bbd59a078cce25137b297b5eaae

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

LOG: [fuzzer] Platfom specific version of PageSize

Added: 
    

Modified: 
    compiler-rt/lib/fuzzer/FuzzerUtil.cpp
    compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
    compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
    compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/fuzzer/FuzzerUtil.cpp b/compiler-rt/lib/fuzzer/FuzzerUtil.cpp
index 71c3dc1ce7af..aeab70f20c28 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtil.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtil.cpp
@@ -21,7 +21,6 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <thread>
-#include <unistd.h>
 
 namespace fuzzer {
 
@@ -235,9 +234,4 @@ uint64_t SimpleFastHash(const void *Data, size_t Size, uint64_t Initial) {
   return Res;
 }
 
-size_t PageSize() {
-  static size_t PageSizeCached = sysconf(_SC_PAGESIZE);
-  return PageSizeCached;
-}
-
 }  // namespace fuzzer

diff  --git a/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
index d80b80cccb80..2a21529fbf8a 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
@@ -551,6 +551,11 @@ void DiscardOutput(int Fd) {
   dup2(nullfd, Fd);
 }
 
+size_t PageSize() {
+  static size_t PageSizeCached = _zx_system_get_page_size();
+  return PageSizeCached;
+}
+
 } // namespace fuzzer
 
 #endif // LIBFUZZER_FUCHSIA

diff  --git a/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
index 0446d732a9ec..392c1e5be4ee 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
@@ -183,6 +183,11 @@ std::string SearchRegexCmd(const std::string &Regex) {
   return "grep '" + Regex + "'";
 }
 
+size_t PageSize() {
+  static size_t PageSizeCached = sysconf(_SC_PAGESIZE);
+  return PageSizeCached;
+}
+
 }  // namespace fuzzer
 
 #endif // LIBFUZZER_POSIX

diff  --git a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
index 3598758dbb4f..6d9bc766c695 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
@@ -224,6 +224,15 @@ void DiscardOutput(int Fd) {
   fclose(Temp);
 }
 
+size_t PageSize() {
+  static size_t PageSizeCached = []() -> size_t {
+    SYSTEM_INFO si;
+    GetSystemInfo(&si);
+    return si.dwPageSize;
+  }();
+  return PageSizeCached;
+}
+
 } // namespace fuzzer
 
 #endif // LIBFUZZER_WINDOWS


        


More information about the llvm-commits mailing list