2014-10-04 17:59:44 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* include/aio.h
|
|
|
|
*
|
2021-02-03 11:33:49 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2014-10-04 17:59:44 +02:00
|
|
|
*
|
2021-02-03 11:33:49 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-10-04 17:59:44 +02:00
|
|
|
*
|
2021-02-03 11:33:49 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2014-10-04 17:59:44 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __INCLUDE_AIO_H
|
|
|
|
#define __INCLUDE_AIO_H
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2019-01-27 16:28:59 +01:00
|
|
|
#include <nuttx/signal.h>
|
2014-10-04 22:22:00 +02:00
|
|
|
#include <nuttx/wqueue.h>
|
|
|
|
|
2014-10-04 17:59:44 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
2020-04-30 20:43:08 +02:00
|
|
|
|
2014-10-04 22:22:00 +02:00
|
|
|
/* Configuration ************************************************************/
|
2020-04-30 20:43:08 +02:00
|
|
|
|
2014-10-05 14:02:37 +02:00
|
|
|
/* These interfaces are not available to kernel code */
|
|
|
|
|
2020-04-29 21:21:23 +02:00
|
|
|
#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
|
2014-10-05 23:44:43 +02:00
|
|
|
# undef CONFIG_FS_AIO
|
2014-10-05 14:02:37 +02:00
|
|
|
#endif
|
|
|
|
|
2014-10-05 23:33:31 +02:00
|
|
|
/* Work queue support is required. The low-priority work queue is required
|
|
|
|
* so that the asynchronous I/O does not interfere with high priority driver
|
|
|
|
* operations. If this pre-requisite is met, then asynchronous I/O support
|
2014-10-05 23:44:43 +02:00
|
|
|
* can be enabled with CONFIG_FS_AIO
|
2014-10-04 22:22:00 +02:00
|
|
|
*/
|
|
|
|
|
2014-10-05 23:44:43 +02:00
|
|
|
#ifdef CONFIG_FS_AIO
|
2014-10-04 22:22:00 +02:00
|
|
|
|
|
|
|
#ifndef CONFIG_SCHED_WORKQUEUE
|
2014-10-05 14:02:37 +02:00
|
|
|
# error Asynchronous I/O requires CONFIG_SCHED_WORKQUEUE
|
2014-10-05 23:33:31 +02:00
|
|
|
#endif
|
|
|
|
|
2014-10-04 22:22:00 +02:00
|
|
|
/* Standard Definitions *****************************************************/
|
2020-04-30 20:43:08 +02:00
|
|
|
|
2014-10-04 17:59:44 +02:00
|
|
|
/* aio_cancel return values
|
|
|
|
*
|
|
|
|
* AIO_ALLDONE - Indicates that none of the requested operations could
|
|
|
|
* be cancelled since they are already complete.
|
|
|
|
* AIO_CANCELED - Indicates that all requested operations have been
|
|
|
|
* cancelled.
|
|
|
|
* AIO_NOTCANCELED - Indicates that some of the requested operations could
|
|
|
|
* not be cancelled since they are in progress.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define AIO_CANCELED 0
|
|
|
|
#define AIO_ALLDONE 1
|
|
|
|
#define AIO_NOTCANCELED 2
|
|
|
|
|
|
|
|
/* lio_listio element operations
|
|
|
|
*
|
|
|
|
* LIO_NOP - Indicates that no transfer is requested.
|
|
|
|
* LIO_READ - Requests a read operation.
|
|
|
|
* LIO_WRITE - Requests a write operation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define LIO_NOP 0
|
|
|
|
#define LIO_READ 1
|
|
|
|
#define LIO_WRITE 2
|
|
|
|
|
|
|
|
/* lio_listio modes
|
|
|
|
*
|
|
|
|
* LIO_NOWAIT - Indicates that the calling thread is to continue
|
|
|
|
* execution while the lio_listio() operation is being
|
|
|
|
* performed, and no notification is given when the
|
|
|
|
* operation is complete.
|
|
|
|
* LIO_WAIT - Indicates that the calling thread is to suspend until
|
|
|
|
* the lio_listio() operation is complete.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define LIO_NOWAIT 0
|
|
|
|
#define LIO_WAIT 1
|
|
|
|
|
2023-02-25 09:02:11 +01:00
|
|
|
#if defined(CONFIG_FS_LARGEFILE)
|
2021-07-21 05:46:21 +02:00
|
|
|
# define aiocb64 aiocb
|
|
|
|
# define aio_read64 aio_read
|
|
|
|
# define aio_write64 aio_write
|
|
|
|
# define aio_error64 aio_error
|
|
|
|
# define aio_return64 aio_return
|
|
|
|
# define aio_cancel64 aio_cancel
|
|
|
|
# define aio_suspend64 aio_suspend
|
|
|
|
# define aio_fsync64 aio_fsync
|
|
|
|
# define lio_listio64 lio_listio
|
|
|
|
#endif
|
|
|
|
|
2014-10-04 17:59:44 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Type Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
struct aiocb
|
|
|
|
{
|
2014-10-04 22:22:00 +02:00
|
|
|
/* Standard fields required by POSIX */
|
|
|
|
|
2014-10-04 17:59:44 +02:00
|
|
|
struct sigevent aio_sigevent; /* Signal number and value */
|
|
|
|
FAR volatile void *aio_buf; /* Location of buffer */
|
|
|
|
off_t aio_offset; /* File offset */
|
|
|
|
size_t aio_nbytes; /* Length of transfer */
|
2014-10-07 16:36:53 +02:00
|
|
|
int16_t aio_fildes; /* File descriptor (should be int) */
|
|
|
|
int8_t aio_reqprio; /* Request priority offset (not used, should be int) */
|
|
|
|
uint8_t aio_lio_opcode; /* Operation to be performed (should be int) */
|
2014-10-04 22:22:00 +02:00
|
|
|
|
2014-10-05 14:53:56 +02:00
|
|
|
/* Non-standard, implementation-dependent data. For portability reasons,
|
|
|
|
* application code should never reference these elements.
|
|
|
|
*/
|
2014-10-04 22:22:00 +02:00
|
|
|
|
2019-01-27 16:28:59 +01:00
|
|
|
struct sigwork_s aio_sigwork; /* Signal work */
|
2014-10-05 01:30:24 +02:00
|
|
|
volatile ssize_t aio_result; /* Support for aio_error() and aio_return() */
|
2014-10-05 19:43:42 +02:00
|
|
|
FAR void *aio_priv; /* Used by signal handlers */
|
2014-10-04 17:59:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define EXTERN extern "C"
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-10-05 16:22:39 +02:00
|
|
|
int aio_cancel(int fildes, FAR struct aiocb *aiocbp);
|
2014-10-04 17:59:44 +02:00
|
|
|
int aio_error(FAR const struct aiocb *aiocbp);
|
2014-10-05 16:53:13 +02:00
|
|
|
int aio_fsync(int op, FAR struct aiocb *aiocbp);
|
2014-10-04 17:59:44 +02:00
|
|
|
int aio_read(FAR struct aiocb *aiocbp);
|
|
|
|
ssize_t aio_return(FAR struct aiocb *aiocbp);
|
2020-05-06 11:24:42 +02:00
|
|
|
int aio_suspend(FAR const struct aiocb * const list[], int nent,
|
2014-10-04 17:59:44 +02:00
|
|
|
FAR const struct timespec *timeout);
|
|
|
|
int aio_write(FAR struct aiocb *aiocbp);
|
2020-05-06 11:24:42 +02:00
|
|
|
int lio_listio(int mode, FAR struct aiocb * const list[], int nent,
|
2014-10-04 17:59:44 +02:00
|
|
|
FAR struct sigevent *sig);
|
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-10-05 23:44:43 +02:00
|
|
|
#endif /* CONFIG_FS_AIO */
|
2014-10-04 17:59:44 +02:00
|
|
|
#endif /* __INCLUDE_AIO_H */
|