mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 865387 - Handle the read-ahead flag operation on Linux. r=Yoric
This commit is contained in:
parent
a2bab79dcb
commit
350b7b56ed
@ -15,6 +15,10 @@
|
||||
#include "sys/stat.h"
|
||||
#endif // defined(XP_UNIX)
|
||||
|
||||
#if defined(XP_LINUX)
|
||||
#include <linux/fadvise.h>
|
||||
#endif // defined(XP_LINUX)
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
#include "copyfile.h"
|
||||
#endif // defined(XP_MACOSX)
|
||||
@ -377,6 +381,10 @@ static const dom::ConstantSpec gLibcProperties[] =
|
||||
INT_CONSTANT(AT_SYMLINK_NOFOLLOW),
|
||||
#endif //defined(AT_SYMLINK_NOFOLLOW)
|
||||
|
||||
#if defined(POSIX_FADV_SEQUENTIAL)
|
||||
INT_CONSTANT(POSIX_FADV_SEQUENTIAL),
|
||||
#endif //defined(POSIX_FADV_SEQUENTIAL)
|
||||
|
||||
// access
|
||||
#if defined(F_OK)
|
||||
INT_CONSTANT(F_OK),
|
||||
|
@ -447,6 +447,14 @@
|
||||
/*buf*/ Types.void_t.out_ptr,
|
||||
/*nbytes*/Types.size_t);
|
||||
|
||||
UnixFile.posix_fadvise =
|
||||
declareFFI("posix_fadvise", ctypes.default_abi,
|
||||
/*return*/ Types.int,
|
||||
/*fd*/ Types.fd,
|
||||
/*offset*/ Types.off_t,
|
||||
/*len*/ Types.off_t,
|
||||
/*advise*/ Types.int);
|
||||
|
||||
if (OS.Constants.libc._DARWIN_FEATURE_64_BIT_INODE) {
|
||||
// Special case for MacOS X 10.5+
|
||||
// Symbol name "readdir" still exists but is used for a
|
||||
|
@ -94,6 +94,13 @@
|
||||
* @throws {OS.File.Error} In case of I/O error.
|
||||
*/
|
||||
File.prototype._read = function _read(buffer, nbytes, options) {
|
||||
// Populate the page cache with data from a file so the subsequent reads
|
||||
// from that file will not block on disk I/O.
|
||||
if (typeof(UnixFile.posix_fadvise) === 'function' &&
|
||||
(options.sequential || !("sequential" in options))) {
|
||||
UnixFile.posix_fadvise(this.fd, 0, nbytes,
|
||||
OS.Constants.libc.POSIX_FADV_SEQUENTIAL);
|
||||
}
|
||||
return throw_on_negative("read",
|
||||
UnixFile.read(this.fd, buffer, nbytes)
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user