1 | /* $Id: fileaio.h 20364 2009-06-08 00:17:43Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Internal RTFileAio header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
27 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
28 | * additional information or have any questions.
|
---|
29 | */
|
---|
30 |
|
---|
31 | #ifndef ___internal_fileaio_h
|
---|
32 | #define ___internal_fileaio_h
|
---|
33 |
|
---|
34 | #include <iprt/file.h>
|
---|
35 | #include "internal/magics.h"
|
---|
36 |
|
---|
37 | /*******************************************************************************
|
---|
38 | * Structures and Typedefs *
|
---|
39 | *******************************************************************************/
|
---|
40 | /**
|
---|
41 | * Defined request states.
|
---|
42 | */
|
---|
43 | typedef enum RTFILEAIOREQSTATE
|
---|
44 | {
|
---|
45 | /** Prepared. */
|
---|
46 | RTFILEAIOREQSTATE_PREPARED = 0,
|
---|
47 | /** Submitted. */
|
---|
48 | RTFILEAIOREQSTATE_SUBMITTED,
|
---|
49 | /** Completed. */
|
---|
50 | RTFILEAIOREQSTATE_COMPLETED,
|
---|
51 | /** Omni present 32bit hack. */
|
---|
52 | RTFILEAIOREQSTATE_32BIT_HACK = 0x7fffffff
|
---|
53 | } RTFILEAIOREQSTATE;
|
---|
54 |
|
---|
55 | /*******************************************************************************
|
---|
56 | * Defined Constants And Macros *
|
---|
57 | *******************************************************************************/
|
---|
58 |
|
---|
59 | /** Return true if the specified request is not valid, false otherwise. */
|
---|
60 | #define RTFILEAIOREQ_IS_NOT_VALID(pReq) \
|
---|
61 | (RT_UNLIKELY(!VALID_PTR(pReq) || (pReq->u32Magic != RTFILEAIOREQ_MAGIC)))
|
---|
62 |
|
---|
63 | /** Validates a context handle and returns VERR_INVALID_HANDLE if not valid. */
|
---|
64 | #define RTFILEAIOREQ_VALID_RETURN_RC(pReq, rc) \
|
---|
65 | do { \
|
---|
66 | AssertPtrReturn((pReq), (rc)); \
|
---|
67 | AssertReturn((pReq)->u32Magic == RTFILEAIOREQ_MAGIC, (rc)); \
|
---|
68 | } while (0)
|
---|
69 |
|
---|
70 | /** Validates a context handle and returns VERR_INVALID_HANDLE if not valid. */
|
---|
71 | #define RTFILEAIOREQ_VALID_RETURN(pReq) RTFILEAIOREQ_VALID_RETURN_RC((pReq), VERR_INVALID_HANDLE)
|
---|
72 |
|
---|
73 | /** Validates a context handle and returns (void) if not valid. */
|
---|
74 | #define RTFILEAIOREQ_VALID_RETURN_VOID(pReq) \
|
---|
75 | do { \
|
---|
76 | AssertPtrReturnVoid(pReq); \
|
---|
77 | AssertReturnVoid((pReq)->u32Magic == RTFILEAIOREQ_MAGIC); \
|
---|
78 | } while (0)
|
---|
79 |
|
---|
80 | /** Validates a context handle and returns the specified rc if not valid. */
|
---|
81 | #define RTFILEAIOCTX_VALID_RETURN_RC(pCtx, rc) \
|
---|
82 | do { \
|
---|
83 | AssertPtrReturn((pCtx), (rc)); \
|
---|
84 | AssertReturn((pCtx)->u32Magic == RTFILEAIOCTX_MAGIC, (rc)); \
|
---|
85 | } while (0)
|
---|
86 |
|
---|
87 | /** Validates a context handle and returns VERR_INVALID_HANDLE if not valid. */
|
---|
88 | #define RTFILEAIOCTX_VALID_RETURN(pCtx) RTFILEAIOCTX_VALID_RETURN_RC((pCtx), VERR_INVALID_HANDLE)
|
---|
89 |
|
---|
90 | /** Checks if a request is in the specified state and returns the specified rc if not. */
|
---|
91 | #define RTFILEAIOREQ_STATE_RETURN_RC(pReq, State, rc) \
|
---|
92 | do { \
|
---|
93 | if (RT_UNLIKELY(pReq->enmState != RTFILEAIOREQSTATE_##State)) \
|
---|
94 | return rc; \
|
---|
95 | } while (0)
|
---|
96 |
|
---|
97 | /** Checks if a request is not in the specified state and returns the specified rc if it is. */
|
---|
98 | #define RTFILEAIOREQ_NOT_STATE_RETURN_RC(pReq, State, rc) \
|
---|
99 | do { \
|
---|
100 | if (RT_UNLIKELY(pReq->enmState == RTFILEAIOREQSTATE_##State)) \
|
---|
101 | return rc; \
|
---|
102 | } while (0)
|
---|
103 |
|
---|
104 | /** Sets the request into a specific state. */
|
---|
105 | #define RTFILEAIOREQ_SET_STATE(pReq, State) \
|
---|
106 | do { \
|
---|
107 | pReq->enmState = RTFILEAIOREQSTATE_##State; \
|
---|
108 | } while (0)
|
---|
109 |
|
---|
110 |
|
---|
111 | RT_BEGIN_DECLS
|
---|
112 |
|
---|
113 | RT_END_DECLS
|
---|
114 |
|
---|
115 | #endif
|
---|
116 |
|
---|