![]() |
|
|||
File indexing completed on 2025-05-11 08:24:14
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup POSIX_AIO 0007 * 0008 * @brief POSIX Asynchronous I/O Support 0009 * 0010 * This file contains the definitions related to POSIX I/O. 0011 */ 0012 0013 /* 0014 * COPYRIGHT (c) 1989-2011. 0015 * On-Line Applications Research Corporation (OAR). 0016 * 0017 * Redistribution and use in source and binary forms, with or without 0018 * modification, are permitted provided that the following conditions 0019 * are met: 0020 * 1. Redistributions of source code must retain the above copyright 0021 * notice, this list of conditions and the following disclaimer. 0022 * 2. Redistributions in binary form must reproduce the above copyright 0023 * notice, this list of conditions and the following disclaimer in the 0024 * documentation and/or other materials provided with the distribution. 0025 * 0026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0027 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0029 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0030 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0031 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0032 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0033 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0034 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0035 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0036 * POSSIBILITY OF SUCH DAMAGE. 0037 */ 0038 0039 #ifndef _AIO_H 0040 #define _AIO_H 0041 0042 #include <sys/cdefs.h> 0043 #include <unistd.h> 0044 0045 #ifdef __cplusplus 0046 extern "C" { 0047 #endif 0048 0049 /** 0050 * @defgroup POSIX_AIO POSIX Asynchronous I/O Support 0051 * 0052 * @ingroup POSIXAPI 0053 * @{ 0054 */ 0055 0056 #if defined(_POSIX_ASYNCHRONOUS_IO) 0057 0058 /* 0059 * 6.7.1 Data Definitions for Asynchronous Input and Output, 0060 * P1003.1b-1993, p. 151 0061 */ 0062 #include <sys/types.h> 0063 #include <signal.h> 0064 #include <time.h> 0065 #include <fcntl.h> 0066 0067 /* 0068 * 6.7.1.2 Manifest Constants, P1003.1b-1993, p. 153 0069 */ 0070 0071 /** All requested operations have been canceled */ 0072 #define AIO_CANCELED 0 0073 0074 /** Some operations could not be canceled since they are in progress */ 0075 #define AIO_NOTCANCELED 1 0076 0077 /** 0078 * None of the requested operations could be canceled since 0079 * they are already complete 0080 */ 0081 #define AIO_ALLDONE 2 0082 0083 /** Calling process is to be suspendes until the operation is complete */ 0084 #define LIO_WAIT 0 0085 0086 /** 0087 * Calling process is to continue execution while the operation is performed 0088 * and no notification shall be given when the operation is completed 0089 */ 0090 #define LIO_NOWAIT 1 0091 0092 /** No transfer is requested */ 0093 #define LIO_NOP 0 0094 0095 /** Request a read() */ 0096 #define LIO_READ 1 0097 0098 /** Request a write() */ 0099 #define LIO_WRITE 2 0100 0101 /** 0102 * @brief Asynchronous I/O Control Block 0103 * 0104 * 6.7.1.1 Asynchronous I/O Control Block, P1003.1b-1993, p. 151 0105 */ 0106 struct aiocb { 0107 /** @name public */ 0108 0109 /** @brief File descriptor */ 0110 int aio_fildes; 0111 /** @brief File offset */ 0112 off_t aio_offset; 0113 /** @brief Location of buffer */ 0114 volatile void *aio_buf; 0115 /** @brief Length of transfer */ 0116 size_t aio_nbytes; 0117 /** @brief Request priority offset */ 0118 int aio_reqprio; 0119 /** @brief Signal number and value */ 0120 struct sigevent aio_sigevent; 0121 /** @brief Operation to be performed */ 0122 int aio_lio_opcode; 0123 0124 /** @name private */ 0125 0126 /** @brief Field used for aio_return() */ 0127 int return_status; 0128 /** @brief Field used for aio_error() */ 0129 int error_code; 0130 /** @brief Filed used for aio_return() */ 0131 ssize_t return_value; 0132 }; 0133 0134 /** 0135 * @brief Asynchronous Read 0136 * 0137 * 6.7.2 Asynchronous Read, P1003.1b-1993, p. 154 0138 * 0139 * @param[in,out] aiocbp is a pointer to the asynchronous I/O control block 0140 * 0141 * @retval 0 The request has been successfuly enqueued. 0142 * @retval -1 The request has not been enqueued due to an error. 0143 * The error is indicated in errno: 0144 * - EBADF FD not opened for read. 0145 * - EINVAL invalid aio_reqprio or aio_offset or aio_nbytes. 0146 * - EAGAIN not enough memory. 0147 * - EAGAIN the addition of a new request to the queue would 0148 * violate the RTEMS_AIO_MAX limit. 0149 * - EINVAL the starting position of the file is past the maximum offset. 0150 * for this file. 0151 * - EINVAL aiocbp is a NULL pointer. 0152 * - EINVAL aiocbp->sigevent is not valid. 0153 */ 0154 int aio_read( 0155 struct aiocb *aiocbp 0156 ); 0157 0158 /** 0159 * @brief Asynchronous Write 0160 * 0161 * 6.7.3 Asynchronous Write, P1003.1b-1993, p. 155 0162 * 0163 * @param[in,out] aiocbp is a pointer to the asynchronous I/O control block 0164 * 0165 * @retval 0 The request has been successfuly enqueued. 0166 * @retval -1 The request has not been enqueued due to an error. 0167 * The error is indicated in errno: 0168 * - EBADF FD not opened for write. 0169 * - EINVAL invalid aio_reqprio or aio_offset or aio_nbytes. 0170 * - EAGAIN not enough memory. 0171 * - EAGAIN the addition of a new request to the queue would 0172 * violate the RTEMS_AIO_MAX limit. 0173 * - EINVAL aiocbp is a NULL pointer. 0174 * - EINVAL aiocbp->sigevent is not valid. 0175 */ 0176 int aio_write( 0177 struct aiocb *aiocbp 0178 ); 0179 0180 /** 0181 * @brief List Directed I/O 0182 * 0183 * 6.7.4 List Directed I/O, P1003.1b-1993, p. 158 0184 * 0185 * @param[in] mode can be LIO_WAIT or LIO_NOWAIT 0186 * @param[in,out] list is a pointer to the array of aiocb 0187 * @param[in] nent is the number of element in list 0188 * @param[in] sig if mode is LIO_NOWAIT, specifies how to notify list completion. 0189 * 0190 * @retval 0 the call to lio_listio() has completed successfuly. 0191 * @retval -1 The call did not complete successfully. 0192 * The error is indicated in errno: 0193 * - ENOSYS the project has been built with RTEMS_POSIX_API not defined. 0194 * - EAGAIN the call failed due to resources limitations. 0195 * - EAGAIN the number of entries indicated by nent value would cause 0196 * the RTEMS_AIO_MAX limit to be excedeed. 0197 * - EINVAL list is a NULL pointer. 0198 * - EINVAL mode is not a valid value. 0199 * - EINVAL the value of nent is not valid or higher than AIO_LISTIO_MAX. 0200 * - EINVAL list is a NULL pointer. 0201 * - EINVAL the sigevent struct pointed by sig is not valid. 0202 * - EINTR the wait for list completion during a LIO_WAIT operation was 0203 * interrupted by an external event. 0204 * - EIO One or more of the individual I/O operations failed. 0205 */ 0206 int lio_listio( 0207 int mode, 0208 struct aiocb *__restrict const list[__restrict], 0209 int nent, 0210 struct sigevent *__restrict sig 0211 ); 0212 0213 /** 0214 * @brief Retrieve Error of Asynchronous I/O Operation 0215 * 0216 * 6.7.5 Retrieve Error of Asynchronous I/O Operation, P1003.1b-1993, p. 161 0217 * 0218 * @param[in,out] aiocbp is a pointer to the asynchronous I/O control block 0219 * 0220 * @retval 0 The operation has completed succesfully. 0221 * @retval EINPROGRESS The operation has not yet completed. 0222 * @retval EINVAL The return status for the request associated with aiocbp 0223 * has already been retrieved. 0224 * @retval EINVAL aiocbp is a NULL pointer. 0225 * @return The error status as described for the various operations. 0226 */ 0227 int aio_error( 0228 const struct aiocb *aiocbp 0229 ); 0230 0231 /** 0232 * @brief Retrieve Return Status of Asynchronous I/O Operation 0233 * 0234 * 6.7.6 Retrieve Return Status of Asynchronous I/O Operation, 0235 * P1003.1b-1993, p. 162 0236 * 0237 * @param[in,out] aiocbp is a pointer to the asynchronous I/O control block 0238 * 0239 * @retval -1 The operation returned with an error. errno is set to indicate 0240 * the error,as described for the various operations. 0241 * @retval EINVAL The return status for the request associated with aiocbp 0242 * has already been retrieved. 0243 * @retval EINVAL aiocbp is a NULL pointer. 0244 * @return The operation return status, stored in aiocbp->return_value 0245 */ 0246 ssize_t aio_return( 0247 struct aiocb *aiocbp 0248 ); 0249 0250 /** 0251 * @brief Cancel asynchronous I/O operation. 0252 * 0253 * 6.7.7 Cancel Asynchronous I/O Operation, P1003.1b-1993, p. 163 0254 * 0255 * @param[in] filedes Is the file descriptor 0256 * @param[in,out] aiocbp Is a pointer to the asynchronous I/O control block 0257 * 0258 * @retval AIO_CANCELED The requested operation(s) were canceled. 0259 * @retval AIO_NOTCANCELED Some of the requested operation(s) cannot be 0260 * canceled since they are in progress. 0261 * @retval AIO_ALLDONE None of the requested operation(s) could be 0262 * canceled since they are already complete. 0263 * @retval -1 An error has occured, errno indicates the error: 0264 * - EBADF fildes is not a valid file descriptor. 0265 */ 0266 int aio_cancel( 0267 int filedes, 0268 struct aiocb *aiocbp 0269 ); 0270 0271 /** 0272 * @brief Wait for Asynchronous I/O Request - NOT IMPLEMENTED 0273 * 0274 * 6.7.7 Wait for Asynchronous I/O Request, P1003.1b-1993, p. 164 0275 */ 0276 int aio_suspend( 0277 const struct aiocb * const list[], 0278 int nent, 0279 const struct timespec *timeout 0280 ); 0281 0282 #if defined(_POSIX_SYNCHRONIZED_IO) 0283 0284 /** 0285 * @brief Asynchronous File Synchronization 0286 * 0287 * 6.7.9 Asynchronous File Synchronization, P1003.1b-1993, p. 166 0288 * 0289 * @param[in] op O_SYNC or O_DSYNC 0290 * @param[in,out] aiocbp is a pointer to the asynchronous I/O control block 0291 * 0292 * @retval 0 The request was correctly enqueued. 0293 * @retval -1 An error occured. errno indicated the error: 0294 * - EAGAIN The requested asynchronous operation was not queued 0295 * due to temporary resource limitations. 0296 * - EAGAIN the addition of a new request to the queue would 0297 * violate the RTEMS_AIO_MAX limit. 0298 * - EBADF The aio_fildes member of the aiocb structure referenced 0299 * by the aiocbp argument is not a valid file descriptor. 0300 * - EINVAL A value of op other than O_SYNC or O_DSYNC was specified. 0301 * - EINVAL aiocbp is a NULL pointer. 0302 * - EINVAL aiocbp->sigevent is not valid. 0303 */ 0304 int aio_fsync( 0305 int op, 0306 struct aiocb *aiocbp 0307 ); 0308 0309 #endif /* _POSIX_SYNCHRONIZED_IO */ 0310 0311 #endif /* _POSIX_ASYNCHRONOUS_IO */ 0312 0313 /** @} */ 0314 0315 #ifdef __cplusplus 0316 } 0317 #endif 0318 0319 #endif 0320 0321 /* end of include file */ 0322
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |