--- libeio/eio.c 2011/07/14 18:30:10 1.86 +++ libeio/eio.c 2011/07/16 16:46:10 1.90 @@ -60,7 +60,6 @@ #include #include -#include /* intptr_t comes from unistd.h, says POSIX/UNIX/tradition */ /* intptr_t only comes from stdint.h, says idiot openbsd coder */ #if HAVE_STDINT_H @@ -70,6 +69,9 @@ #ifndef ECANCELED # define ECANCELED EDOM #endif +#ifndef ELOOP +# define ELOOP EDOM +#endif static void eio_destroy (eio_req *req); @@ -98,35 +100,54 @@ #ifdef _WIN32 + #undef PAGESIZE #define PAGESIZE 4096 /* GetSystemInfo? */ - #define stat(path,buf) _stati64 (path,buf) + #ifdef EIO_STRUCT_STATI64 + #define stat(path,buf) _stati64 (path,buf) + #define fstat(fd,buf) _fstati64 (path,buf) + #endif #define lstat(path,buf) stat (path,buf) - #define fstat(fd,buf) _fstati64 (path,buf) - #define fsync(fd) (FlushFileBuffers (EIO_FD_TO_WIN32_HANDLE (fd)) ? 0 : EIO_ERRNO (EBADF, -1)) + #define fsync(fd) (FlushFileBuffers ((HANDLE)EIO_FD_TO_WIN32_HANDLE (fd)) ? 0 : EIO_ERRNO (EBADF, -1)) #define mkdir(path,mode) _mkdir (path) #define link(old,neu) (CreateHardLink (neu, old, 0) ? 0 : EIO_ERRNO (ENOENT, -1)) + #define chmod(path,mode) _chmod (path, mode) + #define fchmod(fd,mode) EIO_ENOSYS () #define chown(path,uid,gid) EIO_ENOSYS () #define fchown(fd,uid,gid) EIO_ENOSYS () #define truncate(path,offs) EIO_ENOSYS () /* far-miss: SetEndOfFile */ #define ftruncate(fd,offs) EIO_ENOSYS () /* near-miss: SetEndOfFile */ #define mknod(path,mode,dev) EIO_ENOSYS () #define sync() EIO_ENOSYS () + #define readlink(path,buf,s) EIO_ENOSYS () + #define statvfs(path,buf) EIO_ENOSYS () + #define fstatvfs(fd,buf) EIO_ENOSYS () /* we could even stat and see if it exists */ static int symlink (const char *old, const char *neu) { - if (CreateSymbolicLink (neu, old, 1)) - return 0; + #if WINVER >= 0x0600 + if (CreateSymbolicLink (neu, old, 1)) + return 0; - if (CreateSymbolicLink (neu, old, 0)) - return 0; + if (CreateSymbolicLink (neu, old, 0)) + return 0; + #endif return EIO_ERRNO (ENOENT, -1); } + /* POSIX API only */ + #define CreateHardLink(neu,old) 0 + #define CreateSymbolicLink(neu,old,flags) 0 + + struct statvfs + { + int dummy; + }; + #else #include @@ -878,10 +899,10 @@ # define pread eio__pread # define pwrite eio__pwrite -static ssize_t +static eio_ssize_t eio__pread (int fd, void *buf, size_t count, off_t offset) { - ssize_t res; + eio_ssize_t res; off_t ooffset; X_LOCK (preadwritelock); @@ -894,10 +915,10 @@ return res; } -static ssize_t +static eio_ssize_t eio__pwrite (int fd, void *buf, size_t count, off_t offset) { - ssize_t res; + eio_ssize_t res; off_t ooffset; X_LOCK (preadwritelock); @@ -996,7 +1017,7 @@ # undef readahead # define readahead(fd,offset,count) eio__readahead (fd, offset, count, self) -static ssize_t +static eio_ssize_t eio__readahead (int fd, off_t offset, size_t count, etp_worker *self) { size_t todo = count; @@ -1018,11 +1039,11 @@ #endif /* sendfile always needs emulation */ -static ssize_t +static eio_ssize_t eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self) { - ssize_t written = 0; - ssize_t res; + eio_ssize_t written = 0; + eio_ssize_t res; if (!count) return 0; @@ -1127,7 +1148,9 @@ #ifdef ENOTSUP /* sigh, if the steenking pile called openbsd would only try to at least compile posix code... */ || errno == ENOTSUP #endif +#ifdef EOPNOTSUPP /* windows */ || errno == EOPNOTSUPP /* BSDs */ +#endif #if __solaris || errno == EAFNOSUPPORT || errno == EPROTOTYPE #endif @@ -1141,7 +1164,7 @@ while (count) { - ssize_t cnt; + eio_ssize_t cnt; cnt = pread (ifd, eio_buf, count > EIO_BUFSIZE ? EIO_BUFSIZE : count, offset); @@ -1199,7 +1222,7 @@ } #if !_POSIX_MEMLOCK -# define eio__mlockall(a) eio_nosyscall() +# define eio__mlockall(a) EIO_ENOSYS () #else static int @@ -1359,7 +1382,7 @@ while (*rel) { - ssize_t len, linklen; + eio_ssize_t len, linklen; char *beg = rel; while (*rel && *rel != '/') @@ -2180,7 +2203,7 @@ REQ (EIO_FCHMOD); req->int1 = fd; req->int2 = (long)mode; SEND; } -eio_req *eio_fchown (int fd, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data) +eio_req *eio_fchown (int fd, eio_uid_t uid, eio_gid_t gid, int pri, eio_cb cb, void *data) { REQ (EIO_FCHOWN); req->int1 = fd; req->int2 = (long)uid; req->int3 = (long)gid; SEND; } @@ -2210,7 +2233,7 @@ REQ (EIO_TRUNCATE); PATH; req->offs = offset; SEND; } -eio_req *eio_chown (const char *path, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data) +eio_req *eio_chown (const char *path, eio_uid_t uid, eio_gid_t gid, int pri, eio_cb cb, void *data) { REQ (EIO_CHOWN); PATH; req->int2 = (long)uid; req->int3 = (long)gid; SEND; } @@ -2367,11 +2390,11 @@ /*****************************************************************************/ /* misc garbage */ -ssize_t +eio_ssize_t eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count) { etp_worker wrk; - ssize_t ret; + eio_ssize_t ret; wrk.dbuf = 0;