--- IO-AIO/AIO.xs 2010/08/04 14:02:58 1.168 +++ IO-AIO/AIO.xs 2010/08/04 16:06:54 1.169 @@ -142,6 +142,23 @@ # define POSIX_FADV_DONTNEED 0 #endif +#ifndef POSIX_MADV_NORMAL +# define POSIX_MADV_NORMAL 0 +# define NO_MADVISE 1 +#endif +#ifndef POSIX_MADV_SEQUENTIAL +# define POSIX_MADV_SEQUENTIAL 0 +#endif +#ifndef POSIX_MADV_RANDOM +# define POSIX_MADV_RANDOM 0 +#endif +#ifndef POSIX_MADV_WILLNEED +# define POSIX_MADV_WILLNEED 0 +#endif +#ifndef POSIX_MADV_DONTNEED +# define POSIX_MADV_DONTNEED 0 +#endif + #ifndef ST_NODEV # define ST_NODEV 0 #endif @@ -701,6 +718,12 @@ const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED) const_niv (FADV_DONTNEED , POSIX_FADV_DONTNEED) + const_niv (MADV_NORMAL , POSIX_MADV_NORMAL) + const_niv (MADV_SEQUENTIAL, POSIX_MADV_SEQUENTIAL) + const_niv (MADV_RANDOM , POSIX_MADV_RANDOM) + const_niv (MADV_WILLNEED , POSIX_MADV_WILLNEED) + const_niv (MADV_DONTNEED , POSIX_MADV_DONTNEED) + const_iv (ST_RDONLY) const_iv (ST_NOSUID) const_iv (ST_NODEV) @@ -1420,6 +1443,28 @@ sv_unmagic (scalar, MMAP_MAGIC); int +madvise (SV *scalar, off_t offset, off_t length, IV advice) + PROTOTYPE: $$$$ + CODE: +{ + char *addr = SvPV_nolen (scalar) + offset; + + if (!SvOK (ST (2))) + length = SvCUR (scalar) - offset; + + if (addr >= SvEND (scalar) || length <= 0) + XSRETURN_EMPTY; + + #if _XOPEN_SOURCE >= 600 && !NO_MADVISE + RETVAL = posix_madvise (addr, length, advice); + #else + RETVAL = errno = ENOSYS; /* yes, this is actually correct */ + #endif +} + OUTPUT: + RETVAL + +int mlockall (int flags) PROTOTYPE: $ CODE: