summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes5
-rw-r--r--eio.c29
-rw-r--r--eio.h15
3 files changed, 41 insertions, 8 deletions
diff --git a/Changes b/Changes
index d1357b0..78a3459 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,6 @@
Revision history for libeio
-TODO: maybe add mincore support? available on at leats darwin, solaris, linux, freebsd
+TODO: maybe add mincore support? available on at least darwin, solaris, linux, freebsd
1.0
- readdir: correctly handle malloc failures.
@@ -18,4 +18,7 @@ TODO: maybe add mincore support? available on at leats darwin, solaris, linux, f
- "outbundled" from IO::AIO.
- eio_set_max_polltime did not properly convert time to ticks.
- tentatively support darwin in sendfile.
+ - also use sendfile emulation for ENOTSUP and EOPNOTSUPP
+ error codes.
+ - add OS-independent EIO_MT_* and EIO_MS_* flag enums.
diff --git a/eio.c b/eio.c
index a18e8eb..d725bcd 100644
--- a/eio.c
+++ b/eio.c
@@ -1,7 +1,7 @@
/*
* libeio implementation
*
- * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libeio@schmorp.de>
+ * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libeio@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
@@ -972,10 +972,10 @@ eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self)
if (res < 0
&& (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK
+ || errno == ENOTSUP || errno == EOPNOTSUPP /* BSDs */
#if __solaris
|| errno == EAFNOSUPPORT || errno == EPROTOTYPE
#endif
- || errno == ENOTSUP || errno == EOPNOTSUPP
)
)
{
@@ -1376,8 +1376,25 @@ eio__scandir (eio_req *req, etp_worker *self)
}
#if !(_POSIX_MAPPED_FILES && _POSIX_SYNCHRONIZED_IO)
-# undef msync
-# define msync(a,b,c) ((errno = ENOSYS), -1)
+# define eio__msync(a,b,c) ((errno = ENOSYS), -1)
+#else
+
+int
+eio__msync (void *mem, size_t len, int flags)
+{
+ if (EIO_MS_ASYNC != MS_SYNC
+ || EIO_MS_INVALIDATE != MS_INVALIDATE
+ || EIO_MS_SYNC != MS_SYNC)
+ {
+ flags = 0
+ | (flags & EIO_MS_ASYNC ? MS_ASYNC : 0)
+ | (flags & EIO_MS_INVALIDATE ? MS_INVALIDATE : 0)
+ | (flags & EIO_MS_SYNC ? MS_SYNC : 0);
+ }
+
+ return msync (mem, len, flags);
+}
+
#endif
int
@@ -1398,7 +1415,7 @@ eio__mtouch (void *mem, size_t len, int flags)
addr &= ~(page - 1); /* assume page size is always a power of two */
if (addr < end)
- if (flags) /* modify */
+ if (flags & EIO_MT_MODIFY) /* modify */
do { *((volatile sig_atomic_t *)addr) |= 0; } while ((addr += page) < len);
else
do { *((volatile sig_atomic_t *)addr) ; } while ((addr += page) < len);
@@ -1580,7 +1597,7 @@ static void eio_execute (etp_worker *self, eio_req *req)
case EIO_SYNC: req->result = 0; sync (); break;
case EIO_FSYNC: req->result = fsync (req->int1); break;
case EIO_FDATASYNC: req->result = fdatasync (req->int1); break;
- case EIO_MSYNC: req->result = msync (req->ptr2, req->size, req->int1); break;
+ case EIO_MSYNC: req->result = eio__msync (req->ptr2, req->size, req->int1); break;
case EIO_MTOUCH: req->result = eio__mtouch (req->ptr2, req->size, req->int1); break;
case EIO_SYNC_FILE_RANGE: req->result = eio__sync_file_range (req->int1, req->offs, req->size, req->int2); break;
diff --git a/eio.h b/eio.h
index 53c482e..2008d85 100644
--- a/eio.h
+++ b/eio.h
@@ -1,7 +1,7 @@
/*
* libeio API header
*
- * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libeio@schmorp.de>
+ * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libeio@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
@@ -102,6 +102,19 @@ struct eio_dirent {
ino_t inode; /* the inode number, if available, otherwise unspecified */
};
+/* eio_msync flags */
+enum {
+ EIO_MS_ASYNC = 1,
+ EIO_MS_INVALIDATE = 2,
+ EIO_MS_SYNC = 4
+};
+
+/* eio_mtouch flags */
+
+enum {
+ EIO_MT_MODIFY = 1
+};
+
/* eio_sync_file_range flags */
enum {