diff --git a/io.c b/io.c index 7bf5543..65f8804 100644 --- a/io.c +++ b/io.c @@ -2098,6 +2098,19 @@ io_setstrbuf(VALUE *str,long len) #endif } +#ifdef HAVE_POSIX_FADVISE +struct io_advise_struct { + int fd; + off_t offset; + off_t len; + int advice; +}; + +#ifdef POSIX_FADV_SEQUENTIAL +static VALUE io_advise_internal(void *arg); +#endif /* POSIX_FADV_SEQUENTIAL */ +#endif /* HAVE_POSIX_FADVISE */ + static VALUE read_all(rb_io_t *fptr, long siz, VALUE str) { @@ -2107,6 +2120,18 @@ read_all(rb_io_t *fptr, long siz, VALUE str) rb_encoding *enc; int cr; +#ifdef HAVE_POSIX_FADVISE +#ifdef POSIX_FADV_SEQUENTIAL + struct io_advise_struct ias; + + ias.fd = fptr->fd; + ias.advice = POSIX_FADV_SEQUENTIAL; + ias.offset = 0; + ias.len = 0; + io_advise_internal(&ias); +#endif /* POSIX_FADV_SEQUENTIAL */ +#endif /* HAVE_POSIX_FADVISE */ + if (NEED_READCONV(fptr)) { SET_BINARY_MODE(fptr); io_setstrbuf(&str,0); @@ -7894,13 +7919,6 @@ static VALUE sym_normal, sym_sequential, sym_random, sym_willneed, sym_dontneed, sym_noreuse; #ifdef HAVE_POSIX_FADVISE -struct io_advise_struct { - int fd; - off_t offset; - off_t len; - int advice; -}; - static VALUE io_advise_internal(void *arg) {