From f47493fa352d9c0ae7e10490c89f380195a283fc Mon Sep 17 00:00:00 2001 From: root Date: Sun, 21 Sep 2008 00:23:45 +0000 Subject: *** empty log message *** --- eio.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'eio.c') diff --git a/eio.c b/eio.c index 725de8e..61456e2 100644 --- a/eio.c +++ b/eio.c @@ -952,6 +952,35 @@ eio__scandir (eio_req *req, etp_worker *self) req->result = res; } +#if !(_POSIX_MAPPED_FILES && _POSIX_SYNCHRONIZED_IO) +# define msync(a,b,c) ENOSYS +#endif + +int +eio__mtouch (void *mem, size_t len, int flags) +{ + intptr_t addr = (intptr_t)mem; + intptr_t end = addr + len; +#ifdef PAGESIZE + const intptr_t page = PAGESIZE; +#else + static intptr_t page; + + if (!page) + page = sysconf (_SC_PAGESIZE); +#endif + + addr &= ~(page - 1); /* assume page size is always a power of two */ + + if (addr < end) + if (flags) /* modify */ + do { *((volatile sig_atomic_t *)addr) |= 0; } while ((addr += page) < len); + else + do { *((volatile sig_atomic_t *)addr) ; } while ((addr += page) < len); + + return 0; +} + /*****************************************************************************/ #define ALLOC(len) \ @@ -1126,6 +1155,8 @@ 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_MTOUCH: req->result = eio__mtouch (req->ptr2, req->size, req->int1); break; case EIO_READDIR: eio__scandir (req, self); break; @@ -1174,7 +1205,7 @@ static void eio_execute (etp_worker *self, eio_req *req) break; case EIO_CUSTOM: - req->feed (req); + ((void (*)(eio_req *))req->feed) (req); break; default: @@ -1207,6 +1238,16 @@ eio_req *eio_fsync (int fd, int pri, eio_cb cb, void *data) REQ (EIO_FSYNC); req->int1 = fd; SEND; } +eio_req *eio_msync (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data) +{ + REQ (EIO_MSYNC); req->ptr2 = addr; req->size = length; req->int1 = flags; SEND; +} + +eio_req *eio_mtouch (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data) +{ + REQ (EIO_MTOUCH); req->ptr2 = addr; req->size = length; req->int1 = flags; SEND; +} + eio_req *eio_fdatasync (int fd, int pri, eio_cb cb, void *data) { REQ (EIO_FDATASYNC); req->int1 = fd; SEND; @@ -1371,7 +1412,7 @@ eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, eio_req *eio_custom (eio_cb execute, int pri, eio_cb cb, void *data) { - REQ (EIO_CUSTOM); req->feed = execute; SEND; + REQ (EIO_CUSTOM); req->feed = (void (*)(eio_req *))execute; SEND; } #endif -- cgit v1.2.3