POSIX Asynchronous I/O support: fhandler files

This code is where the AIO implementation is wired into existing Cygwin
mechanisms for file and device I/O: the fhandler* functions.  It makes
use of an existing internal routine prw_open to supply a "shadow fd"
that permits asynchronous operations on a file the user app accesses
via its own fd.  This allows AIO to read or write at arbitrary locations
within a file without disturbing the app's file pointer.  (This was
already the case with normal pread|pwrite; we're just adding "async"
to the mix.)
This commit is contained in:
Mark Geisert
2018-07-23 22:31:58 -07:00
committed by Corinna Vinschen
parent a9ffa71a15
commit 87253cbe38
4 changed files with 83 additions and 34 deletions

View File

@ -380,8 +380,8 @@ public:
virtual ssize_t __stdcall write (const void *ptr, size_t len);
virtual ssize_t __stdcall readv (const struct iovec *, int iovcnt, ssize_t tot = -1);
virtual ssize_t __stdcall writev (const struct iovec *, int iovcnt, ssize_t tot = -1);
virtual ssize_t __reg3 pread (void *, size_t, off_t);
virtual ssize_t __reg3 pwrite (void *, size_t, off_t);
virtual ssize_t __reg3 pread (void *, size_t, off_t, void *aio = NULL);
virtual ssize_t __reg3 pwrite (void *, size_t, off_t, void *aio = NULL);
virtual off_t lseek (off_t offset, int whence);
virtual int lock (int, struct flock *);
virtual int mand_lock (int, struct flock *);
@ -1430,9 +1430,10 @@ class fhandler_dev_tape: public fhandler_dev_raw
class fhandler_disk_file: public fhandler_base
{
HANDLE prw_handle;
bool prw_handle_isasync;
int __reg3 readdir_helper (DIR *, dirent *, DWORD, DWORD, PUNICODE_STRING fname);
int prw_open (bool);
int prw_open (bool, void *);
public:
fhandler_disk_file ();
@ -1473,8 +1474,8 @@ class fhandler_disk_file: public fhandler_base
void rewinddir (DIR *);
int closedir (DIR *);
ssize_t __reg3 pread (void *, size_t, off_t);
ssize_t __reg3 pwrite (void *, size_t, off_t);
ssize_t __reg3 pread (void *, size_t, off_t, void *aio = NULL);
ssize_t __reg3 pwrite (void *, size_t, off_t, void *aio = NULL);
fhandler_disk_file (void *) {}
dev_t get_dev () { return pc.fs_serial_number (); }