[PATCH] D119856: [Support] Use posix_madvise() if available

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 16 00:36:59 PST 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb66b3247f598: [Support] Use posix_madvise() if available (authored by nikic).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119856

Files:
  llvm/lib/Support/Unix/Path.inc


Index: llvm/lib/Support/Unix/Path.inc
===================================================================
--- llvm/lib/Support/Unix/Path.inc
+++ llvm/lib/Support/Unix/Path.inc
@@ -118,12 +118,6 @@
 #define STATVFS_F_FLAG(vfs) (vfs).f_flags
 #endif
 
-#if defined(__sun__) && defined(__svr4__)
-// The madvise() declaration on Illumos cannot be made visible if _XOPEN_SOURCE
-// is defined. This declaration is also compatible with Solaris 11.4.
-extern "C" int madvise(void *, size_t, int);
-#endif
-
 using namespace llvm;
 
 namespace llvm {
@@ -880,12 +874,14 @@
 
 void mapped_file_region::dontNeedImpl() {
   assert(Mode == mapped_file_region::readonly);
+  if (!Mapping)
+      return;
 #if defined(__MVS__) || defined(_AIX)
   // If we don't have madvise, or it isn't beneficial, treat this as a no-op.
-  return;
+#elif defined(POSIX_MADV_DONTNEED)
+  ::posix_madvise(Mapping, Size, POSIX_MADV_DONTNEED);
 #else
-  if (Mapping)
-    ::madvise(Mapping, Size, MADV_DONTNEED);
+  ::madvise(Mapping, Size, MADV_DONTNEED);
 #endif
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119856.409163.patch
Type: text/x-patch
Size: 1039 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220216/e100c570/attachment.bin>


More information about the llvm-commits mailing list