diff options
author | Michael Meskes <meskes@debian.org> | 2009-12-01 08:26:35 +0100 |
---|---|---|
committer | Michael Meskes <meskes@debian.org> | 2009-12-01 08:26:35 +0100 |
commit | 92d607e8349d0f1268b236b3bf4cb433179253f1 (patch) | |
tree | 6230e827557f7cd76ac792d43f4cc6a81be3b272 /src/VBox/Runtime/r3/linux/fileaio-linux.cpp | |
parent | 541f51c4dab24f1decc1cb44888af9d45d619338 (diff) | |
download | virtualbox-92d607e8349d0f1268b236b3bf4cb433179253f1.tar.gz |
Imported Upstream version 3.1.0-dfsgupstream/3.1.0-dfsg
Diffstat (limited to 'src/VBox/Runtime/r3/linux/fileaio-linux.cpp')
-rw-r--r-- | src/VBox/Runtime/r3/linux/fileaio-linux.cpp | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/src/VBox/Runtime/r3/linux/fileaio-linux.cpp b/src/VBox/Runtime/r3/linux/fileaio-linux.cpp index 6db26eda1..aaa4a9560 100644 --- a/src/VBox/Runtime/r3/linux/fileaio-linux.cpp +++ b/src/VBox/Runtime/r3/linux/fileaio-linux.cpp @@ -1,4 +1,4 @@ -/* $Id: fileaio-linux.cpp $ */ +/* $Id: fileaio-linux.cpp 22969 2009-09-11 23:00:59Z vboxsync $ */ /** @file * IPRT - File async I/O, native implementation for the Linux host platform. */ @@ -62,8 +62,6 @@ #include <iprt/thread.h> #include "internal/fileaio.h" -#define _LINUX_BYTEORDER_SWABB_H -#include <linux/aio_abi.h> #include <unistd.h> #include <sys/syscall.h> #include <errno.h> @@ -74,6 +72,18 @@ /******************************************************************************* * Structures and Typedefs * *******************************************************************************/ +/** The async I/O context handle */ +typedef unsigned long LNXKAIOCONTEXT; + +/** + * Supported commands for the iocbs + */ +enum +{ + LNXKAIO_IOCB_CMD_READ = 0, + LNXKAIO_IOCB_CMD_WRITE +}; + /** * The iocb structure of a request which is passed to the kernel. * @@ -164,7 +174,7 @@ typedef struct LNXKAIOIOEVENT typedef struct RTFILEAIOCTXINTERNAL { /** Handle to the async I/O context. */ - aio_context_t AioContext; + LNXKAIOCONTEXT AioContext; /** Maximum number of requests this context can handle. */ int cRequestsMax; /** Current number of requests active on this context. */ @@ -192,7 +202,7 @@ typedef struct RTFILEAIOREQINTERNAL /** Current state the request is in. */ RTFILEAIOREQSTATE enmState; /** The I/O context this request is associated with. */ - aio_context_t AioContext; + LNXKAIOCONTEXT AioContext; /** Return code the request completed with. */ int Rc; /** Number of bytes actually trasnfered. */ @@ -216,7 +226,7 @@ typedef RTFILEAIOREQINTERNAL *PRTFILEAIOREQINTERNAL; /** * Creates a new async I/O context. */ -DECLINLINE(int) rtFileAsyncIoLinuxCreate(unsigned cEvents, aio_context_t *pAioContext) +DECLINLINE(int) rtFileAsyncIoLinuxCreate(unsigned cEvents, LNXKAIOCONTEXT *pAioContext) { int rc = syscall(__NR_io_setup, cEvents, pAioContext); if (RT_UNLIKELY(rc == -1)) @@ -228,7 +238,7 @@ DECLINLINE(int) rtFileAsyncIoLinuxCreate(unsigned cEvents, aio_context_t *pAioCo /** * Destroys a async I/O context. */ -DECLINLINE(int) rtFileAsyncIoLinuxDestroy(aio_context_t AioContext) +DECLINLINE(int) rtFileAsyncIoLinuxDestroy(LNXKAIOCONTEXT AioContext) { int rc = syscall(__NR_io_destroy, AioContext); if (RT_UNLIKELY(rc == -1)) @@ -240,7 +250,7 @@ DECLINLINE(int) rtFileAsyncIoLinuxDestroy(aio_context_t AioContext) /** * Submits an array of I/O requests to the kernel. */ -DECLINLINE(int) rtFileAsyncIoLinuxSubmit(aio_context_t AioContext, long cReqs, LNXKAIOIOCB **ppIoCB, int *pcSubmitted) +DECLINLINE(int) rtFileAsyncIoLinuxSubmit(LNXKAIOCONTEXT AioContext, long cReqs, LNXKAIOIOCB **ppIoCB, int *pcSubmitted) { int rc = syscall(__NR_io_submit, AioContext, cReqs, ppIoCB); if (RT_UNLIKELY(rc == -1)) @@ -254,7 +264,7 @@ DECLINLINE(int) rtFileAsyncIoLinuxSubmit(aio_context_t AioContext, long cReqs, L /** * Cancels a I/O request. */ -DECLINLINE(int) rtFileAsyncIoLinuxCancel(aio_context_t AioContext, PLNXKAIOIOCB pIoCB, PLNXKAIOIOEVENT pIoResult) +DECLINLINE(int) rtFileAsyncIoLinuxCancel(LNXKAIOCONTEXT AioContext, PLNXKAIOIOCB pIoCB, PLNXKAIOIOEVENT pIoResult) { int rc = syscall(__NR_io_cancel, AioContext, pIoCB, pIoResult); if (RT_UNLIKELY(rc == -1)) @@ -267,7 +277,7 @@ DECLINLINE(int) rtFileAsyncIoLinuxCancel(aio_context_t AioContext, PLNXKAIOIOCB * Waits for I/O events. * @returns Number of events (natural number w/ 0), IPRT error code (negative). */ -DECLINLINE(int) rtFileAsyncIoLinuxGetEvents(aio_context_t AioContext, long cReqsMin, long cReqs, +DECLINLINE(int) rtFileAsyncIoLinuxGetEvents(LNXKAIOCONTEXT AioContext, long cReqsMin, long cReqs, PLNXKAIOIOEVENT paIoResults, struct timespec *pTimeout) { int rc = syscall(__NR_io_getevents, AioContext, cReqsMin, cReqs, paIoResults, pTimeout); @@ -286,7 +296,7 @@ RTR3DECL(int) RTFileAioGetLimits(PRTFILEAIOLIMITS pAioLimits) * Check if the API is implemented by creating a * completion port. */ - aio_context_t AioContext = 0; + LNXKAIOCONTEXT AioContext = 0; rc = rtFileAsyncIoLinuxCreate(1, &AioContext); if (RT_FAILURE(rc)) return rc; @@ -382,7 +392,7 @@ DECLINLINE(int) rtFileAioReqPrepareTransfer(RTFILEAIOREQ hReq, RTFILE hFile, RTDECL(int) RTFileAioReqPrepareRead(RTFILEAIOREQ hReq, RTFILE hFile, RTFOFF off, void *pvBuf, size_t cbRead, void *pvUser) { - return rtFileAioReqPrepareTransfer(hReq, hFile, IOCB_CMD_PREAD, + return rtFileAioReqPrepareTransfer(hReq, hFile, LNXKAIO_IOCB_CMD_READ, off, pvBuf, cbRead, pvUser); } @@ -390,7 +400,7 @@ RTDECL(int) RTFileAioReqPrepareRead(RTFILEAIOREQ hReq, RTFILE hFile, RTFOFF off, RTDECL(int) RTFileAioReqPrepareWrite(RTFILEAIOREQ hReq, RTFILE hFile, RTFOFF off, void *pvBuf, size_t cbWrite, void *pvUser) { - return rtFileAioReqPrepareTransfer(hReq, hFile, IOCB_CMD_PWRITE, + return rtFileAioReqPrepareTransfer(hReq, hFile, LNXKAIO_IOCB_CMD_WRITE, off, pvBuf, cbWrite, pvUser); } @@ -715,7 +725,7 @@ RTDECL(int) RTFileAioCtxWait(RTFILEAIOCTX hAioCtx, size_t cMinReqs, unsigned cMi * purpose for it yet. */ if (RT_UNLIKELY(aPortEvents[i].rc < 0)) - pReqInt->Rc = RTErrConvertFromErrno(aPortEvents[i].rc); + pReqInt->Rc = RTErrConvertFromErrno(-aPortEvents[i].rc); /* Convert to positive value. */ else { pReqInt->Rc = VINF_SUCCESS; |