diff options
author | root <root> | 2008-09-21 00:23:45 +0000 |
---|---|---|
committer | root <root> | 2008-09-21 00:23:45 +0000 |
commit | f47493fa352d9c0ae7e10490c89f380195a283fc (patch) | |
tree | 81e80e5efb33fb7d589384c5fc4a851044e367b3 /eio.c | |
parent | 2593e3d47d7cfef64910fef19d29428fc13c2c92 (diff) |
*** empty log message ***
Diffstat (limited to 'eio.c')
-rw-r--r-- | eio.c | 45 |
1 files changed, 43 insertions, 2 deletions
@@ -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 |