--- IO-AIO/AIO.xs 2010/11/01 22:03:43 1.174 +++ IO-AIO/AIO.xs 2011/02/11 00:05:17 1.180 @@ -18,7 +18,7 @@ #include #include -#if _POSIX_MEMLOCK || _POSIX_MAPPED_FILES +#if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES # include #endif @@ -120,11 +120,11 @@ #define EIO_NO_WRAPPERS 1 +#include "libeio/config.h" #include "libeio/eio.h" #ifndef POSIX_FADV_NORMAL # define POSIX_FADV_NORMAL 0 -# define NO_FADVISE 1 #endif #ifndef POSIX_FADV_SEQUENTIAL # define POSIX_FADV_SEQUENTIAL 0 @@ -142,13 +142,12 @@ # define POSIX_FADV_DONTNEED 0 #endif -#if _XOPEN_SOURCE < 600 || NO_FADVISE +#if !HAVE_POSIX_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 @@ -163,7 +162,7 @@ # define POSIX_MADV_DONTNEED 0 #endif -#if _XOPEN_SOURCE < 600 || NO_MADVISE +#if !HAVE_POSIX_MADVISE # define posix_madvise(a,b,c) errno = ENOSYS /* also return ENOSYS */ #endif @@ -211,6 +210,31 @@ # define ST_RELATIME 0 #endif +#ifndef S_IFIFO +# define S_IFIFO 0 +#endif +#ifndef S_IFCHR +# define S_IFCHR 0 +#endif +#ifndef S_IFBLK +# define S_IFBLK 0 +#endif +#ifndef S_IFLNK +# define S_IFLNK 0 +#endif +#ifndef S_IFREG +# define S_IFREG 0 +#endif +#ifndef S_IFDIR +# define S_IFDIR 0 +#endif +#ifndef S_IFWHT +# define S_IFWHT 0 +#endif +#ifndef S_IFSOCK +# define S_IFSOCK 0 +#endif + #ifndef MAP_ANONYMOUS # ifdef MAP_ANON # define MAP_ANONYMOUS MAP_ANON @@ -234,6 +258,16 @@ # define MAP_NONBLOCK 0 #endif +#ifndef makedev +# define makedev(maj,min) (((maj) << 8) | (min)) +#endif +#ifndef major +# define major(dev) ((dev) >> 8) +#endif +#ifndef minor +# define minor(dev) ((dev) & 0xff) +#endif + #ifndef PAGESIZE # define PAGESIZE sysconf (_SC_PAGESIZE) #endif @@ -356,6 +390,7 @@ { sv_result = sv_result_cache; sv_result_cache = 0; SvIV_set (sv_result, req->result); + SvIOK_only (sv_result); } else { @@ -529,7 +564,7 @@ } break; - case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), su fudge result value */ + case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), so fudge result value */ if (req->result > 0) SvIV_set (sv_result, 0); /* FALLTHROUGH */ @@ -639,6 +674,9 @@ #if !_POSIX_MAPPED_FILES # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) # define munmap(addr,length) (errno = ENOSYS, -1) +#endif + +#if !_POSIX_MEMORY_PROTECTION # define mprotect(addr,len,prot) (errno = ENOSYS, -1) # define PROT_NONE 0 # define PROT_WRITE 0 @@ -728,9 +766,17 @@ const_iv (O_TRUNC) const_iv (O_EXCL) const_iv (O_APPEND) -#ifndef _WIN32 + const_iv (S_IFIFO) -#endif + const_iv (S_IFCHR) + const_iv (S_IFBLK) + const_iv (S_IFLNK) + const_iv (S_IFREG) + const_iv (S_IFDIR) + const_iv (S_IFWHT) + const_iv (S_IFSOCK) + const_iv (S_IFMT) + const_niv (FADV_NORMAL , POSIX_FADV_NORMAL) const_niv (FADV_SEQUENTIAL, POSIX_FADV_SEQUENTIAL) const_niv (FADV_RANDOM , POSIX_FADV_RANDOM) @@ -1062,6 +1108,22 @@ REQ_SEND; } +UV +major (UV dev) + ALIAS: + minor = 1 + CODE: + RETVAL = ix ? major (dev) : minor (dev); + OUTPUT: + RETVAL + +UV +makedev (UV maj, UV min) + CODE: + RETVAL = makedev (maj, min); + OUTPUT: + RETVAL + void aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef) PPCODE: @@ -1526,7 +1588,7 @@ addr = (void *)(((intptr_t)addr) + offset); eio_page_align (&addr, &len); -#if _POSIX_MEMLOCK +#if _POSIX_MEMLOCK_RANGE RETVAL = munlock (addr, len); #else RETVAL = ((errno = ENOSYS), -1);