[PATCH] D116603: [AIX][z/OS][Support] Provide alternate mapped_file_region::dontNeedImpl implementations

David Tenty via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 4 08:53:41 PST 2022


daltenty created this revision.
daltenty added reviewers: abhina.sreeskantharajan, zibi, aganea, MaskRay.
Herald added subscribers: dexonsmith, hiraditya.
daltenty requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

mapped_file_region::dontNeedImpl added in D116366 <https://reviews.llvm.org/D116366> calls madvise, which causes problems for z/OS and AIX.

For AIX, it doesn't have a standardized signature, so it'd require additional casts and it needs certain feature test macros (i.e. _ALL_SOURCE) we don't set by default on AIX, so prefer posix_madvise.

For z/OS, we don't have either madvise, so treat this as a no-op, same as Windows does.


https://reviews.llvm.org/D116603

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
@@ -873,7 +873,16 @@
 void mapped_file_region::dontNeedImpl() {
   assert(Mode == mapped_file_region::readonly);
   if (Mapping)
+#if defined(__MVS__)
+    // z/OS doesn't have either madvise, so treat this as a nop.
+    return;
+#elif defined(_AIX)
+    // Prefer the POSIX implementation on AIX, since the signature for madvise is non-standardised
+    // and only exists with certain feature test macros.
+    ::posix_madvise(Mapping, Size, POSIX_MADV_DONTNEED);
+#else
     ::madvise(Mapping, Size, MADV_DONTNEED);
+#endif
 }

 int mapped_file_region::alignment() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116603.397316.patch
Type: text/x-patch
Size: 747 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220104/b144d066/attachment.bin>


More information about the llvm-commits mailing list