1 | /* $Id: fileaio.h 93115 2022-01-01 11:31:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Internal RTFileAio header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2022 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 IPRT_INCLUDED_INTERNAL_fileaio_h
|
---|
28 | #define IPRT_INCLUDED_INTERNAL_fileaio_h
|
---|
29 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
30 | # pragma once
|
---|
31 | #endif
|
---|
32 |
|
---|
33 | #include <iprt/file.h>
|
---|
34 | #include "internal/magics.h"
|
---|
35 |
|
---|
36 | /*******************************************************************************
|
---|
37 | * Structures and Typedefs *
|
---|
38 | *******************************************************************************/
|
---|
39 | /**
|
---|
40 | * Defined request states.
|
---|
41 | */
|
---|
42 | typedef enum RTFILEAIOREQSTATE
|
---|
43 | {
|
---|
44 | /** Prepared. */
|
---|
45 | RTFILEAIOREQSTATE_PREPARED = 0,
|
---|
46 | /** Submitted. */
|
---|
47 | RTFILEAIOREQSTATE_SUBMITTED,
|
---|
48 | /** Completed. */
|
---|
49 | RTFILEAIOREQSTATE_COMPLETED,
|
---|
50 | /** Omni present 32bit hack. */
|
---|
51 | RTFILEAIOREQSTATE_32BIT_HACK = 0x7fffffff
|
---|
52 | } RTFILEAIOREQSTATE;
|
---|
53 |
|
---|
54 | /*******************************************************************************
|
---|
55 | * Defined Constants And Macros *
|
---|
56 | *******************************************************************************/
|
---|
57 |
|
---|
58 | /** Return true if the specified request is not valid, false otherwise. */
|
---|
59 | #define RTFILEAIOREQ_IS_NOT_VALID(pReq) \
|
---|
60 | (RT_UNLIKELY(!RT_VALID_PTR(pReq) || (pReq->u32Magic != RTFILEAIOREQ_MAGIC)))
|
---|
61 |
|
---|
62 | /** Validates a context handle and returns VERR_INVALID_HANDLE if not valid. */
|
---|
63 | #define RTFILEAIOREQ_VALID_RETURN_RC(pReq, rc) \
|
---|
64 | do { \
|
---|
65 | AssertPtrReturn((pReq), (rc)); \
|
---|
66 | AssertReturn((pReq)->u32Magic == RTFILEAIOREQ_MAGIC, (rc)); \
|
---|
67 | } while (0)
|
---|
68 |
|
---|
69 | /** Validates a context handle and returns VERR_INVALID_HANDLE if not valid. */
|
---|
70 | #define RTFILEAIOREQ_VALID_RETURN(pReq) RTFILEAIOREQ_VALID_RETURN_RC((pReq), VERR_INVALID_HANDLE)
|
---|
71 |
|
---|
72 | /** Validates a context handle and returns (void) if not valid. */
|
---|
73 | #define RTFILEAIOREQ_VALID_RETURN_VOID(pReq) \
|
---|
74 | do { \
|
---|
75 | AssertPtrReturnVoid(pReq); \
|
---|
76 | AssertReturnVoid((pReq)->u32Magic == RTFILEAIOREQ_MAGIC); \
|
---|
77 | } while (0)
|
---|
78 |
|
---|
79 | /** Validates a context handle and returns the specified rc if not valid. */
|
---|
80 | #define RTFILEAIOCTX_VALID_RETURN_RC(pCtx, rc) \
|
---|
81 | do { \
|
---|
82 | AssertPtrReturn((pCtx), (rc)); \
|
---|
83 | AssertReturn((pCtx)->u32Magic == RTFILEAIOCTX_MAGIC, (rc)); \
|
---|
84 | } while (0)
|
---|
85 |
|
---|
86 | /** Validates a context handle and returns VERR_INVALID_HANDLE if not valid. */
|
---|
87 | #define RTFILEAIOCTX_VALID_RETURN(pCtx) RTFILEAIOCTX_VALID_RETURN_RC((pCtx), VERR_INVALID_HANDLE)
|
---|
88 |
|
---|
89 | /** Checks if a request is in the specified state and returns the specified rc if not. */
|
---|
90 | #define RTFILEAIOREQ_STATE_RETURN_RC(pReq, State, rc) \
|
---|
91 | do { \
|
---|
92 | if (RT_UNLIKELY(pReq->enmState != RTFILEAIOREQSTATE_##State)) \
|
---|
93 | return rc; \
|
---|
94 | } while (0)
|
---|
95 |
|
---|
96 | /** Checks if a request is not in the specified state and returns the specified rc if it is. */
|
---|
97 | #define RTFILEAIOREQ_NOT_STATE_RETURN_RC(pReq, State, rc) \
|
---|
98 | do { \
|
---|
99 | if (RT_UNLIKELY(pReq->enmState == RTFILEAIOREQSTATE_##State)) \
|
---|
100 | return rc; \
|
---|
101 | } while (0)
|
---|
102 |
|
---|
103 | /** Checks if a request in the given states and sserts if not. */
|
---|
104 | #define RTFIELAIOREQ_ASSERT_STATE(pReq, State) \
|
---|
105 | do { \
|
---|
106 | AssertPtr((pReq)); \
|
---|
107 | Assert((pReq)->u32Magic == RTFILEAIOREQ_MAGIC); \
|
---|
108 | Assert((pReq)->enmState == RTFILEAIOREQSTATE_##State); \
|
---|
109 | } while (0)
|
---|
110 |
|
---|
111 | /** Sets the request into a specific state. */
|
---|
112 | #define RTFILEAIOREQ_SET_STATE(pReq, State) \
|
---|
113 | do { \
|
---|
114 | pReq->enmState = RTFILEAIOREQSTATE_##State; \
|
---|
115 | } while (0)
|
---|
116 |
|
---|
117 |
|
---|
118 | RT_C_DECLS_BEGIN
|
---|
119 |
|
---|
120 | RT_C_DECLS_END
|
---|
121 |
|
---|
122 | #endif /* !IPRT_INCLUDED_INTERNAL_fileaio_h */
|
---|
123 |
|
---|