posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
aio.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright The Zephyr Project Contributors
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
23#ifndef ZEPHYR_INCLUDE_ZEPHYR_POSIX_AIO_H_
24#define ZEPHYR_INCLUDE_ZEPHYR_POSIX_AIO_H_
25
26/* size_t must be defined by the libc stddef.h */
27#include <stddef.h>
28#include <stdint.h>
29#include <signal.h>
30
31#include <zephyr/toolchain.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37/* slightly out of order w.r.t. the specification */
38#if !defined(_OFF_T_DECLARED) && !defined(__off_t_defined)
39typedef long off_t;
40#define _OFF_T_DECLARED
41#define __off_t_defined
42#endif
43
44#ifndef __SIZE_TYPE__
45#define __SIZE_TYPE__ unsigned long
46#endif
47
48/* slightly out of order w.r.t. the specification */
49#if !defined(_SSIZE_T_DECLARED) && !defined(__ssize_t_defined)
50#define unsigned signed /* parasoft-suppress MISRAC2012-RULE_20_4-a MISRAC2012-RULE_20_4-b */
51typedef __SIZE_TYPE__ ssize_t;
52#undef unsigned
53#define _SSIZE_T_DECLARED
54#define __ssize_t_defined
55#endif
56
57/* time_t must be defined by the libc time.h */
58#include <time.h>
59
60#if __STDC_VERSION__ >= 201112L
61/* struct timespec must be defined in the libc time.h */
62#else
63/* slightly out of order w.r.t. the specification */
64#if !defined(_TIMESPEC_DECLARED) && !defined(__timespec_defined)
65struct timespec {
66 time_t tv_sec;
67 long tv_nsec;
68};
69#define _TIMESPEC_DECLARED
70#define __timespec_defined
71#endif
72#endif
73
75struct aiocb {
77 off_t aio_offset;
78 volatile void *aio_buf;
79 size_t aio_nbytes;
81#if defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__)
83#endif
86 void *z_posix_aio_req; /* sys_aio request handle; NULL when nothing is outstanding */
88};
89
91#define AIO_ALLDONE 2
93#define AIO_CANCELED 0
95#define AIO_NOTCANCELED 1
96
98#define LIO_NOP 2
100#define LIO_NOWAIT 1
102#define LIO_READ 0
104#define LIO_WAIT 0
106#define LIO_WRITE 1
107
108#if _POSIX_C_SOURCE >= 200112L
109
118int aio_cancel(int fildes, struct aiocb *aiocbp);
119
127int aio_error(const struct aiocb *aiocbp);
128
137int aio_fsync(int op, struct aiocb *aiocbp);
138
146int aio_read(struct aiocb *aiocbp);
147
159ssize_t aio_return(struct aiocb *aiocbp);
160
170int aio_suspend(const struct aiocb *const list[], int nent, const struct timespec *timeout);
171
179int aio_write(struct aiocb *aiocbp);
180
191int lio_listio(int mode, struct aiocb *const list[ZRESTRICT], int nent,
192 struct sigevent *ZRESTRICT sig);
193
194#endif /* _POSIX_C_SOURCE >= 200112L */
195
196
197#ifdef __cplusplus
198}
199#endif
200
201#endif /* ZEPHYR_INCLUDE_ZEPHYR_POSIX_AIO_H_ */
int aio_write(struct aiocb *aiocbp)
Enqueue an asynchronous write operation.
ssize_t aio_return(struct aiocb *aiocbp)
Retrieve the return status of a completed asynchronous I/O request.
int aio_read(struct aiocb *aiocbp)
Enqueue an asynchronous read operation.
int aio_error(const struct aiocb *aiocbp)
Retrieve the error status of an asynchronous I/O request.
int lio_listio(int mode, struct aiocb *const list[ZRESTRICT], int nent, struct sigevent *ZRESTRICT sig)
Initiate a list of asynchronous I/O requests.
int aio_fsync(int op, struct aiocb *aiocbp)
Asynchronously synchronise a file's data and metadata to storage.
int aio_suspend(const struct aiocb *const list[], int nent, const struct timespec *timeout)
Wait for one or more asynchronous I/O requests to complete.
int aio_cancel(int fildes, struct aiocb *aiocbp)
Cancel an outstanding asynchronous I/O request.
Asynchronous I/O control block.
Definition aio.h:75
off_t aio_offset
File offset for the operation.
Definition aio.h:77
volatile void * aio_buf
Data buffer for read or write.
Definition aio.h:78
size_t aio_nbytes
Number of bytes to transfer.
Definition aio.h:79
struct sigevent aio_sigevent
Notification method on completion.
Definition aio.h:82
int aio_reqprio
Request priority offset.
Definition aio.h:80
int aio_lio_opcode
Operation code for lio_listio() (LIO_READ, LIO_WRITE, LIO_NOP).
Definition aio.h:84
int aio_fildes
File descriptor.
Definition aio.h:76
Structure describing how to notify about an asynchronous event.
Time value with nanosecond resolution.
Definition aio.h:65
long tv_nsec
Nanoseconds [0, 999999999].
Definition aio.h:67
time_t tv_sec
Seconds.
Definition aio.h:66
POSIX time-of-day types and functions (<sys/time.h>)