[PATCH] D20410: [LibFuzzer] Fix implementation of ``GetPeakRSSMb()`` on Mac OSX

Dan Liew via llvm-commits llvm-commits at lists.llvm.org
Wed May 18 20:47:26 PDT 2016


delcypher created this revision.
delcypher added reviewers: kcc, kubabrecka.
delcypher added subscribers: llvm-commits, kcc, kubabrecka.

[LibFuzzer]
Fix implementation of ``GetPeakRSSMb()`` on Mac OSX. On Linux
``rusage.ru_maxrss`` is in KiB but on Mac OSX it is in
bytes.

http://reviews.llvm.org/D20410

Files:
  lib/Fuzzer/FuzzerUtil.cpp

Index: lib/Fuzzer/FuzzerUtil.cpp
===================================================================
--- lib/Fuzzer/FuzzerUtil.cpp
+++ lib/Fuzzer/FuzzerUtil.cpp
@@ -273,7 +273,15 @@
   struct rusage usage;
   if (getrusage(RUSAGE_SELF, &usage))
     return 0;
+#ifdef __linux__
+  // ru_maxrss is in KiB
   return usage.ru_maxrss >> 10;
+#elif __APPLE__
+  // ru_maxrss is in bytes
+  return usage.ru_maxrss >> 20;
+#else
+#error "GetPeakRSSMb() is not implemented for your platform"
+#endif
 }
 
 }  // namespace fuzzer


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20410.57731.patch
Type: text/x-patch
Size: 521 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160519/25c3ec91/attachment.bin>


More information about the llvm-commits mailing list