fileaio.h revision 643b32fda84b53ffdc94e190ff8c5bce34d022b0
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson/* $Id$ */
c110d61b173a68420d19858abb80285be0dc1120Tinderbox User/** @file
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * IPRT - Internal RTFileAio header.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence */
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson/*
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson * Copyright (C) 2009 Oracle Corporation
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * This file is part of VirtualBox Open Source Edition (OSE), as
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * available from http://www.virtualbox.org. This file is free software;
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * you can redistribute it and/or modify it under the terms of the GNU
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * General Public License (GPL) as published by the Free Software
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * Foundation, in version 2 as it comes in the "COPYING" file of the
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson *
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson * The contents of this file may alternatively be used under the terms
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson * of the Common Development and Distribution License Version 1.0
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington * VirtualBox OSE distribution, in which case the provisions of the
a5c077e40c784cf9e25c95a1ab94db2faab04ae9Brian Wellington * CDDL are applicable instead of those of the GPL.
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson *
cc0a5f714231709409b9e1b85f0f97ae50854451Mark Andrews * You may elect to license modified versions of this file under the
d9059b0c38bd630c367d81424d72b1308cd74b04Tatuya JINMEI 神明達哉 * terms and conditions of either the GPL or the CDDL or both.
6028d1ce0380d0ba7f6c6ecd1ad20b31ddd1becbDavid Lawrence */
364a82f7c25b62967678027043425201a5e5171aBob Halley
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson#ifndef ___internal_fileaio_h
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence#define ___internal_fileaio_h
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington#include <iprt/file.h>
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafsson#include "internal/magics.h"
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt/*******************************************************************************
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉* Structures and Typedefs *
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington*******************************************************************************/
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉/**
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * Defined request states.
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 */
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunttypedef enum RTFILEAIOREQSTATE
5afa531442369eed0e93a8af14422b30f400bd89Mark Andrews{
8907d8fa04fdaa65baf0bc6b01230b2ebde93106Mark Andrews /** Prepared. */
476386968b1f287a695f73c48862e961011af99bMark Andrews RTFILEAIOREQSTATE_PREPARED = 0,
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson /** Submitted. */
9259fed3d8ac5d1efa9b5a647969e40c9c934484Andreas Gustafsson RTFILEAIOREQSTATE_SUBMITTED,
3aca8e5bf3740bbcc3bb13dde242d7cc369abb27Mark Andrews /** Completed. */
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington RTFILEAIOREQSTATE_COMPLETED,
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafsson /** Omni present 32bit hack. */
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafsson RTFILEAIOREQSTATE_32BIT_HACK = 0x7fffffff
62700b67eb8abb7d13f9c3c1bc4b60a1477d35d8Mark Andrews} RTFILEAIOREQSTATE;
9259fed3d8ac5d1efa9b5a647969e40c9c934484Andreas Gustafsson
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson/*******************************************************************************
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt* Defined Constants And Macros *
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt*******************************************************************************/
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt/** Return true if the specified request is not valid, false otherwise. */
222d38735f97f771054e223b03f84c5858252332Evan Hunt#define RTFILEAIOREQ_IS_NOT_VALID(pReq) \
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt (RT_UNLIKELY(!VALID_PTR(pReq) || (pReq->u32Magic != RTFILEAIOREQ_MAGIC)))
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt/** Validates a context handle and returns VERR_INVALID_HANDLE if not valid. */
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt#define RTFILEAIOREQ_VALID_RETURN_RC(pReq, rc) \
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt do { \
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson AssertPtrReturn((pReq), (rc)); \
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson AssertReturn((pReq)->u32Magic == RTFILEAIOREQ_MAGIC, (rc)); \
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson } while (0)
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson/** Validates a context handle and returns VERR_INVALID_HANDLE if not valid. */
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson#define RTFILEAIOREQ_VALID_RETURN(pReq) RTFILEAIOREQ_VALID_RETURN_RC((pReq), VERR_INVALID_HANDLE)
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt/** Validates a context handle and returns (void) if not valid. */
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt#define RTFILEAIOREQ_VALID_RETURN_VOID(pReq) \
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt do { \
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt AssertPtrReturnVoid(pReq); \
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt AssertReturnVoid((pReq)->u32Magic == RTFILEAIOREQ_MAGIC); \
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein } while (0)
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson/** Validates a context handle and returns the specified rc if not valid. */
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson#define RTFILEAIOCTX_VALID_RETURN_RC(pCtx, rc) \
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews do { \
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt AssertPtrReturn((pCtx), (rc)); \
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater AssertReturn((pCtx)->u32Magic == RTFILEAIOCTX_MAGIC, (rc)); \
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson } while (0)
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson/** Validates a context handle and returns VERR_INVALID_HANDLE if not valid. */
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson#define RTFILEAIOCTX_VALID_RETURN(pCtx) RTFILEAIOCTX_VALID_RETURN_RC((pCtx), VERR_INVALID_HANDLE)
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews/** Checks if a request is in the specified state and returns the specified rc if not. */
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington#define RTFILEAIOREQ_STATE_RETURN_RC(pReq, State, rc) \
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt do { \
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt if (RT_UNLIKELY(pReq->enmState != RTFILEAIOREQSTATE_##State)) \
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater return rc; \
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt } while (0)
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt/** Checks if a request is not in the specified state and returns the specified rc if it is. */
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt#define RTFILEAIOREQ_NOT_STATE_RETURN_RC(pReq, State, rc) \
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt do { \
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater if (RT_UNLIKELY(pReq->enmState == RTFILEAIOREQSTATE_##State)) \
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater return rc; \
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt } while (0)
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt/** Checks if a request in the given states and sserts if not. */
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater#define RTFIELAIOREQ_ASSERT_STATE(pReq, State) \
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater do { \
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt AssertPtr((pReq)); \
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt Assert((pReq)->u32Magic == RTFILEAIOREQ_MAGIC); \
222d38735f97f771054e223b03f84c5858252332Evan Hunt Assert((pReq)->enmState == RTFILEAIOREQSTATE_##State); \
222d38735f97f771054e223b03f84c5858252332Evan Hunt } while (0)
222d38735f97f771054e223b03f84c5858252332Evan Hunt
222d38735f97f771054e223b03f84c5858252332Evan Hunt/** Sets the request into a specific state. */
222d38735f97f771054e223b03f84c5858252332Evan Hunt#define RTFILEAIOREQ_SET_STATE(pReq, State) \
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt do { \
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater pReq->enmState = RTFILEAIOREQSTATE_##State; \
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater } while (0)
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan HuntRT_C_DECLS_BEGIN
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic UpdaterRT_C_DECLS_END
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt#endif
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater