21 VOID CALLBACK IoCompletionRoutine(DWORD dwErrorCode,
 
   22                                   DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped)
 
   25     struct aiocb *aiocbp = (
struct aiocb *) lpOverlapped->hEvent;
 
   27     aiocbp->aio_sigevent.sigev_notify = dwErrorCode;
 
   28     aiocbp->aio_sigevent.sigev_signo = dwNumberOfBytesTransfered;
 
   29     debugs(81, 7, 
"AIO operation complete: errorcode=" << dwErrorCode << 
" nbytes=" << dwNumberOfBytesTransfered);
 
   33 int aio_read(
struct aiocb *aiocbp)
 
   35     LPOVERLAPPED Overlapped;
 
   36     BOOL IoOperationStatus;
 
   39     Overlapped = (LPOVERLAPPED) 
xcalloc(1, 
sizeof(OVERLAPPED));
 
   46 #if _FILE_OFFSET_BITS==64 
   48     Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000LL);
 
   50     Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000LL);
 
   54     Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000);
 
   56     Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000);
 
   61     Overlapped->Offset = aiocbp->aio_offset;
 
   63     Overlapped->OffsetHigh = 0;
 
   67     Overlapped->hEvent = aiocbp;
 
   69     aiocbp->aio_sigevent.sigev_notify = EINPROGRESS;
 
   71     aiocbp->aio_sigevent.sigev_signo = -1;
 
   73     IoOperationStatus = ReadFileEx((HANDLE)_get_osfhandle(aiocbp->aio_fildes),
 
   80     if (!IoOperationStatus) {
 
   81         errno = GetLastError();
 
   92 int aio_read64(
struct aiocb64 *aiocbp)
 
   94     LPOVERLAPPED Overlapped;
 
   95     BOOL IoOperationStatus;
 
   98     Overlapped = (LPOVERLAPPED) 
xcalloc(1, 
sizeof(OVERLAPPED));
 
  106     Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000LL);
 
  108     Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000LL);
 
  112     Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000);
 
  114     Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000);
 
  118     Overlapped->hEvent = aiocbp;
 
  120     aiocbp->aio_sigevent.sigev_notify = EINPROGRESS;
 
  122     aiocbp->aio_sigevent.sigev_signo = -1;
 
  124     IoOperationStatus = ReadFileEx((HANDLE)_get_osfhandle(aiocbp->aio_fildes),
 
  128                                    IoCompletionRoutine);
 
  131     if (!IoOperationStatus) {
 
  132         errno = GetLastError();
 
  143 int aio_write(
struct aiocb *aiocbp)
 
  145     LPOVERLAPPED Overlapped;
 
  146     BOOL IoOperationStatus;
 
  149     Overlapped = (LPOVERLAPPED) 
xcalloc(1, 
sizeof(OVERLAPPED));
 
  156 #if _FILE_OFFSET_BITS==64 
  158     Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000LL);
 
  160     Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000LL);
 
  164     Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000);
 
  166     Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000);
 
  171     Overlapped->Offset = aiocbp->aio_offset;
 
  173     Overlapped->OffsetHigh = 0;
 
  177     Overlapped->hEvent = aiocbp;
 
  179     aiocbp->aio_sigevent.sigev_notify = EINPROGRESS;
 
  181     aiocbp->aio_sigevent.sigev_signo = -1;
 
  183     IoOperationStatus = WriteFileEx((HANDLE)_get_osfhandle(aiocbp->aio_fildes),
 
  187                                     IoCompletionRoutine);
 
  190     if (!IoOperationStatus) {
 
  191         errno = GetLastError();
 
  202 int aio_write64(
struct aiocb64 *aiocbp)
 
  204     LPOVERLAPPED Overlapped;
 
  205     BOOL IoOperationStatus;
 
  208     Overlapped = (LPOVERLAPPED) 
xcalloc(1, 
sizeof(OVERLAPPED));
 
  216     Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000LL);
 
  218     Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000LL);
 
  222     Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000);
 
  224     Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000);
 
  228     Overlapped->hEvent = aiocbp;
 
  230     aiocbp->aio_sigevent.sigev_notify = EINPROGRESS;
 
  232     aiocbp->aio_sigevent.sigev_signo = -1;
 
  234     IoOperationStatus = WriteFileEx((HANDLE)_get_osfhandle(aiocbp->aio_fildes),
 
  238                                     IoCompletionRoutine);
 
  241     if (!IoOperationStatus) {
 
  242         errno = GetLastError();
 
  253 int aio_error(
const struct aiocb * aiocbp)
 
  255     return aiocbp->aio_sigevent.sigev_notify;
 
  258 int aio_error64(
const struct aiocb64 * aiocbp)
 
  260     return aiocbp->aio_sigevent.sigev_notify;
 
  263 int aio_open(
const char *path, 
int mode)
 
  266     DWORD dwCreationDisposition;
 
  267     DWORD dwDesiredAccess;
 
  278         dwDesiredAccess = GENERIC_WRITE;
 
  280         dwDesiredAccess = (mode & O_RDONLY) ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE;
 
  283         dwCreationDisposition = CREATE_ALWAYS;
 
  285         dwCreationDisposition = (mode & O_CREAT) ? OPEN_ALWAYS : OPEN_EXISTING;
 
  287     if ((hndl = CreateFile(path,                    
 
  291                            dwCreationDisposition,   
 
  292                            FILE_FLAG_OVERLAPPED,    
 
  294                           )) != INVALID_HANDLE_VALUE) {
 
  296         fd = _open_osfhandle((
long) hndl, 0);
 
  300         errno = GetLastError();
 
  307 void aio_close(
int fd)
 
  309     CloseHandle((HANDLE)_get_osfhandle(fd));
 
  314 ssize_t aio_return(
struct aiocb * aiocbp)
 
  316     return aiocbp->aio_sigevent.sigev_signo;
 
  319 ssize_t aio_return64(
struct aiocb64 * aiocbp)
 
  322     return aiocbp->aio_sigevent.sigev_signo;