VirtualBox

source: vbox/trunk/src/VBox/Runtime/include/internal/fileaio.h@ 31964

Last change on this file since 31964 was 29451, checked in by vboxsync, 14 years ago

Missing change

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: fileaio.h 29451 2010-05-13 15:38:48Z vboxsync $ */
2/** @file
3 * IPRT - Internal RTFileAio header.
4 */
5
6/*
7 * Copyright (C) 2009 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef ___internal_fileaio_h
28#define ___internal_fileaio_h
29
30#include <iprt/file.h>
31#include "internal/magics.h"
32
33/*******************************************************************************
34* Structures and Typedefs *
35*******************************************************************************/
36/**
37 * Defined request states.
38 */
39typedef enum RTFILEAIOREQSTATE
40{
41 /** Prepared. */
42 RTFILEAIOREQSTATE_PREPARED = 0,
43 /** Submitted. */
44 RTFILEAIOREQSTATE_SUBMITTED,
45 /** Completed. */
46 RTFILEAIOREQSTATE_COMPLETED,
47 /** Omni present 32bit hack. */
48 RTFILEAIOREQSTATE_32BIT_HACK = 0x7fffffff
49} RTFILEAIOREQSTATE;
50
51/*******************************************************************************
52* Defined Constants And Macros *
53*******************************************************************************/
54
55/** Return true if the specified request is not valid, false otherwise. */
56#define RTFILEAIOREQ_IS_NOT_VALID(pReq) \
57 (RT_UNLIKELY(!VALID_PTR(pReq) || (pReq->u32Magic != RTFILEAIOREQ_MAGIC)))
58
59/** Validates a context handle and returns VERR_INVALID_HANDLE if not valid. */
60#define RTFILEAIOREQ_VALID_RETURN_RC(pReq, rc) \
61 do { \
62 AssertPtrReturn((pReq), (rc)); \
63 AssertReturn((pReq)->u32Magic == RTFILEAIOREQ_MAGIC, (rc)); \
64 } while (0)
65
66/** Validates a context handle and returns VERR_INVALID_HANDLE if not valid. */
67#define RTFILEAIOREQ_VALID_RETURN(pReq) RTFILEAIOREQ_VALID_RETURN_RC((pReq), VERR_INVALID_HANDLE)
68
69/** Validates a context handle and returns (void) if not valid. */
70#define RTFILEAIOREQ_VALID_RETURN_VOID(pReq) \
71 do { \
72 AssertPtrReturnVoid(pReq); \
73 AssertReturnVoid((pReq)->u32Magic == RTFILEAIOREQ_MAGIC); \
74 } while (0)
75
76/** Validates a context handle and returns the specified rc if not valid. */
77#define RTFILEAIOCTX_VALID_RETURN_RC(pCtx, rc) \
78 do { \
79 AssertPtrReturn((pCtx), (rc)); \
80 AssertReturn((pCtx)->u32Magic == RTFILEAIOCTX_MAGIC, (rc)); \
81 } while (0)
82
83/** Validates a context handle and returns VERR_INVALID_HANDLE if not valid. */
84#define RTFILEAIOCTX_VALID_RETURN(pCtx) RTFILEAIOCTX_VALID_RETURN_RC((pCtx), VERR_INVALID_HANDLE)
85
86/** Checks if a request is in the specified state and returns the specified rc if not. */
87#define RTFILEAIOREQ_STATE_RETURN_RC(pReq, State, rc) \
88 do { \
89 if (RT_UNLIKELY(pReq->enmState != RTFILEAIOREQSTATE_##State)) \
90 return rc; \
91 } while (0)
92
93/** Checks if a request is not in the specified state and returns the specified rc if it is. */
94#define RTFILEAIOREQ_NOT_STATE_RETURN_RC(pReq, State, rc) \
95 do { \
96 if (RT_UNLIKELY(pReq->enmState == RTFILEAIOREQSTATE_##State)) \
97 return rc; \
98 } while (0)
99
100/** Checks if a request in the given states and sserts if not. */
101#define RTFIELAIOREQ_ASSERT_STATE(pReq, State) \
102 do { \
103 AssertPtr((pReq)); \
104 Assert((pReq)->u32Magic == RTFILEAIOREQ_MAGIC); \
105 Assert((pReq)->enmState == RTFILEAIOREQSTATE_##State); \
106 } while (0)
107
108/** Sets the request into a specific state. */
109#define RTFILEAIOREQ_SET_STATE(pReq, State) \
110 do { \
111 pReq->enmState = RTFILEAIOREQSTATE_##State; \
112 } while (0)
113
114
115RT_C_DECLS_BEGIN
116
117RT_C_DECLS_END
118
119#endif
120
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette