--- libeio/eio.c 2010/09/12 03:36:28 1.56 +++ libeio/eio.c 2011/02/11 00:53:24 1.61 @@ -1,7 +1,7 @@ /* * libeio implementation * - * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann + * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- @@ -81,7 +81,7 @@ # include # include -#if _POSIX_MEMLOCK || _POSIX_MAPPED_FILES +#if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES # include #endif @@ -818,12 +818,10 @@ } #endif -#ifndef HAVE_FUTIMES +#ifndef HAVE_UTIMES # undef utimes -# undef futimes -# define utimes(path,times) eio__utimes (path, times) -# define futimes(fd,times) eio__futimes (fd, times) +# define utimes(path,times) eio__utimes (path, times) static int eio__utimes (const char *filename, const struct timeval times[2]) @@ -841,6 +839,13 @@ return utime (filename, 0); } +#endif + +#ifndef HAVE_FUTIMES + +# undef futimes +# define futimes(fd,times) eio__futimes (fd, times) + static int eio__futimes (int fd, const struct timeval tv[2]) { errno = ENOSYS; @@ -1428,19 +1433,10 @@ } #if !_POSIX_MEMLOCK -# define eio__mlock(a,b) ((errno = ENOSYS), -1) # define eio__mlockall(a) ((errno = ENOSYS), -1) #else static int -eio__mlock (void *addr, size_t length) -{ - eio_page_align (&addr, &length); - - mlock (addr, length); -} - -static int eio__mlockall (int flags) { #if __GLIBC__ == 2 && __GLIBC_MINOR__ <= 7 @@ -1456,10 +1452,24 @@ | (flags & EIO_MCL_FUTURE ? MCL_FUTURE : 0); } - mlockall (flags); + return mlockall (flags); } #endif +#if !_POSIX_MEMLOCK_RANGE +# define eio__mlock(a,b) ((errno = ENOSYS), -1) +#else + +static int +eio__mlock (void *addr, size_t length) +{ + eio_page_align (&addr, &length); + + return mlock (addr, length); +} + +#endif + #if !(_POSIX_MAPPED_FILES && _POSIX_SYNCHRONIZED_IO) # define eio__msync(a,b,c) ((errno = ENOSYS), -1) #else @@ -1632,8 +1642,6 @@ static void eio_execute (etp_worker *self, eio_req *req) { - errno = 0; - switch (req->type) { case EIO_READ: ALLOC (req->size); @@ -1675,7 +1683,7 @@ case EIO_RENAME: req->result = rename (req->ptr1, req->ptr2); break; case EIO_LINK: req->result = link (req->ptr1, req->ptr2); break; case EIO_SYMLINK: req->result = symlink (req->ptr1, req->ptr2); break; - case EIO_MKNOD: req->result = mknod (req->ptr1, (mode_t)req->int2, (dev_t)req->int3); break; + case EIO_MKNOD: req->result = mknod (req->ptr1, (mode_t)req->int2, (dev_t)req->offs); break; case EIO_READLINK: ALLOC (PATH_MAX); req->result = readlink (req->ptr1, req->ptr2, PATH_MAX); break; @@ -1693,13 +1701,13 @@ case EIO_BUSY: #ifdef _WIN32 - Sleep (req->nv1 * 1000.); + Sleep (req->nv1 * 1e3); #else { struct timeval tv; tv.tv_sec = req->nv1; - tv.tv_usec = (req->nv1 - tv.tv_sec) * 1000000.; + tv.tv_usec = (req->nv1 - tv.tv_sec) * 1e6; req->result = select (0, 0, 0, 0, &tv); } @@ -1724,7 +1732,6 @@ else times = 0; - req->result = req->type == EIO_FUTIME ? futimes (req->int1, times) : utimes (req->ptr1, times); @@ -1743,6 +1750,7 @@ break; default: + errno = ENOSYS; req->result = -1; break; } @@ -1935,7 +1943,7 @@ eio_req *eio_mknod (const char *path, mode_t mode, dev_t dev, int pri, eio_cb cb, void *data) { - REQ (EIO_MKNOD); PATH; req->int2 = (long)mode; req->int3 = (long)dev; SEND; + REQ (EIO_MKNOD); PATH; req->int2 = (long)mode; req->offs = (off_t)dev; SEND; } static eio_req *