1 /* Copyright (C) 1996-2000,2003,2004,2007,2012 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
19 * ISO/IEC 9945-1:1996 6.7: Asynchronous Input and Output
26 #include <sys/types.h>
27 #define __need_sigevent_t
28 #include <bits/siginfo.h>
29 #define __need_timespec
34 /* Asynchronous I/O control block. */
37 int aio_fildes
; /* File desriptor. */
38 int aio_lio_opcode
; /* Operation to be performed. */
39 int aio_reqprio
; /* Request priority offset. */
40 volatile void *aio_buf
; /* Location of buffer. */
41 size_t aio_nbytes
; /* Length of transfer. */
42 struct sigevent aio_sigevent
; /* Signal number and value. */
44 /* Internal members. */
45 struct aiocb
*__next_prio
;
49 __ssize_t __return_value
;
51 #ifndef __USE_FILE_OFFSET64
52 __off_t aio_offset
; /* File offset. */
53 char __pad
[sizeof (__off64_t
) - sizeof (__off_t
)];
55 __off64_t aio_offset
; /* File offset. */
60 /* The same for the 64bit offsets. Please note that the members aio_fildes
61 to __return_value have to be the same in aiocb and aiocb64. */
62 #ifdef __USE_LARGEFILE64
65 int aio_fildes
; /* File desriptor. */
66 int aio_lio_opcode
; /* Operation to be performed. */
67 int aio_reqprio
; /* Request priority offset. */
68 volatile void *aio_buf
; /* Location of buffer. */
69 size_t aio_nbytes
; /* Length of transfer. */
70 struct sigevent aio_sigevent
; /* Signal number and value. */
72 /* Internal members. */
73 struct aiocb
*__next_prio
;
77 __ssize_t __return_value
;
79 __off64_t aio_offset
; /* File offset. */
86 /* To customize the implementation one can use the following struct.
87 This implementation follows the one in Irix. */
90 int aio_threads
; /* Maximal number of threads. */
91 int aio_num
; /* Number of expected simultanious requests. */
92 int aio_locks
; /* Not used. */
93 int aio_usedba
; /* Not used. */
94 int aio_debug
; /* Not used. */
95 int aio_numusers
; /* Not used. */
96 int aio_idle_time
; /* Number of seconds before idle thread
103 /* Return values of cancelation function. */
107 #define AIO_CANCELED AIO_CANCELED
109 #define AIO_NOTCANCELED AIO_NOTCANCELED
111 #define AIO_ALLDONE AIO_ALLDONE
115 /* Operation codes for `aio_lio_opcode'. */
119 #define LIO_READ LIO_READ
121 #define LIO_WRITE LIO_WRITE
123 #define LIO_NOP LIO_NOP
127 /* Synchronization options for `lio_listio' function. */
131 #define LIO_WAIT LIO_WAIT
133 #define LIO_NOWAIT LIO_NOWAIT
137 /* Allow user to specify optimization. */
139 extern void aio_init (const struct aioinit
*__init
) __THROW
__nonnull ((1));
143 #ifndef __USE_FILE_OFFSET64
144 /* Enqueue read request for given number of bytes and the given priority. */
145 extern int aio_read (struct aiocb
*__aiocbp
) __THROW
__nonnull ((1));
146 /* Enqueue write request for given number of bytes and the given priority. */
147 extern int aio_write (struct aiocb
*__aiocbp
) __THROW
__nonnull ((1));
149 /* Initiate list of I/O requests. */
150 extern int lio_listio (int __mode
,
151 struct aiocb
*const __list
[__restrict_arr
],
152 int __nent
, struct sigevent
*__restrict __sig
)
153 __THROW
__nonnull ((2));
155 /* Retrieve error status associated with AIOCBP. */
156 extern int aio_error (const struct aiocb
*__aiocbp
) __THROW
__nonnull ((1));
157 /* Return status associated with AIOCBP. */
158 extern __ssize_t
aio_return (struct aiocb
*__aiocbp
) __THROW
__nonnull ((1));
160 /* Try to cancel asynchronous I/O requests outstanding against file
161 descriptor FILDES. */
162 extern int aio_cancel (int __fildes
, struct aiocb
*__aiocbp
) __THROW
;
164 /* Suspend calling thread until at least one of the asynchronous I/O
165 operations referenced by LIST has completed.
167 This function is a cancellation point and therefore not marked with
169 extern int aio_suspend (const struct aiocb
*const __list
[], int __nent
,
170 const struct timespec
*__restrict __timeout
)
173 /* Force all operations associated with file desriptor described by
174 `aio_fildes' member of AIOCBP. */
175 extern int aio_fsync (int __operation
, struct aiocb
*__aiocbp
)
176 __THROW
__nonnull ((2));
178 # ifdef __REDIRECT_NTH
179 extern int __REDIRECT_NTH (aio_read
, (struct aiocb
*__aiocbp
), aio_read64
)
181 extern int __REDIRECT_NTH (aio_write
, (struct aiocb
*__aiocbp
), aio_write64
)
184 extern int __REDIRECT_NTH (lio_listio
,
186 struct aiocb
*const __list
[__restrict_arr
],
187 int __nent
, struct sigevent
*__restrict __sig
),
188 lio_listio64
) __nonnull ((2));
190 extern int __REDIRECT_NTH (aio_error
, (const struct aiocb
*__aiocbp
),
191 aio_error64
) __nonnull ((1));
192 extern __ssize_t
__REDIRECT_NTH (aio_return
, (struct aiocb
*__aiocbp
),
193 aio_return64
) __nonnull ((1));
195 extern int __REDIRECT_NTH (aio_cancel
,
196 (int __fildes
, struct aiocb
*__aiocbp
),
199 extern int __REDIRECT_NTH (aio_suspend
,
200 (const struct aiocb
*const __list
[], int __nent
,
201 const struct timespec
*__restrict __timeout
),
202 aio_suspend64
) __nonnull ((1));
204 extern int __REDIRECT_NTH (aio_fsync
,
205 (int __operation
, struct aiocb
*__aiocbp
),
206 aio_fsync64
) __nonnull ((2));
209 # define aio_read aio_read64
210 # define aio_write aio_write64
211 # define lio_listio lio_listio64
212 # define aio_error aio_error64
213 # define aio_return aio_return64
214 # define aio_cancel aio_cancel64
215 # define aio_suspend aio_suspend64
216 # define aio_fsync aio_fsync64
220 #ifdef __USE_LARGEFILE64
221 extern int aio_read64 (struct aiocb64
*__aiocbp
) __THROW
__nonnull ((1));
222 extern int aio_write64 (struct aiocb64
*__aiocbp
) __THROW
__nonnull ((1));
224 extern int lio_listio64 (int __mode
,
225 struct aiocb64
*const __list
[__restrict_arr
],
226 int __nent
, struct sigevent
*__restrict __sig
)
227 __THROW
__nonnull ((2));
229 extern int aio_error64 (const struct aiocb64
*__aiocbp
)
230 __THROW
__nonnull ((1));
231 extern __ssize_t
aio_return64 (struct aiocb64
*__aiocbp
)
232 __THROW
__nonnull ((1));
234 extern int aio_cancel64 (int __fildes
, struct aiocb64
*__aiocbp
) __THROW
;
236 extern int aio_suspend64 (const struct aiocb64
*const __list
[], int __nent
,
237 const struct timespec
*__restrict __timeout
)
238 __THROW
__nonnull ((1));
240 extern int aio_fsync64 (int __operation
, struct aiocb64
*__aiocbp
)
241 __THROW
__nonnull ((2));