diff options
Diffstat (limited to 'sal/osl/unx/file.cxx')
-rw-r--r-- | sal/osl/unx/file.cxx | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index 216162e616d6..cc0c041bc328 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -1079,6 +1079,29 @@ SAL_CALL osl_mapFile ( } } } + if (uFlags & osl_File_MapFlag_WillNeed) + { + // On Linux, madvise(..., MADV_WILLNEED) appears to have the undesirable + // effect of not returning until the data has actually been paged in, so + // that its net effect would typically be to slow down the process + // (which could start processing at the beginning of the data while the + // OS simultaneously pages in the rest); on other platforms, it remains + // to be evaluated whether madvise or equivalent is available and + // actually useful: +#if defined MACOSX + int e = posix_madvise(p, nLength, POSIX_MADV_WILLNEED); + if (e != 0) + { + OSL_TRACE( + "posix_madvise(..., POSIX_MADV_WILLNEED) failed with %d", e); + } +#elif defined SOLARIS + if (madvise(static_cast< caddr_t >(p), nLength, MADV_WILLNEED) != 0) + { + OSL_TRACE("madvise(..., MADV_WILLNEED) failed with %d", errno); + } +#endif + } return osl_File_E_None; } |