--- IO-AIO/AIO.xs 2010/08/04 14:02:58 1.168 +++ IO-AIO/AIO.xs 2010/08/04 16:09:36 1.170 @@ -142,6 +142,31 @@ # define POSIX_FADV_DONTNEED 0 #endif +#if _XOPEN_SOURCE < 600 || NO_FADVISE +# define posix_fadvise(a,b,c,d) errno = ENOSYS /* also return ENOSYS */ +#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 + +#if _XOPEN_SOURCE < 600 || NO_MADVISE +# define posix_madvise(a,b,c) errno = ENOSYS /* also return ENOSYS */ +#endif + #ifndef ST_NODEV # define ST_NODEV 0 #endif @@ -701,6 +726,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) @@ -1364,11 +1395,7 @@ fadvise (aio_rfd fh, off_t offset, off_t length, IV advice) PROTOTYPE: $$$$ CODE: -#if _XOPEN_SOURCE >= 600 && !NO_FADVISE RETVAL = posix_fadvise (fh, offset, length, advice); -#else - RETVAL = errno = ENOSYS; /* yes, this is actually correct */ -#endif OUTPUT: RETVAL @@ -1420,6 +1447,24 @@ 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; + + RETVAL = posix_madvise (addr, length, advice); +} + OUTPUT: + RETVAL + +int mlockall (int flags) PROTOTYPE: $ CODE: