* sysdeps/m68k/fpu/libm-test-ulps: Update.
[glibc.git] / rt / aio.h
blob61662089ff6337ddcace7feb9d0a981eab03bf46
1 /* Copyright (C) 1996, 1997, 1998, 1999, 2000 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 Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 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 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
20 * ISO/IEC 9945-1:1996 6.7: Asynchronous Input and Output
23 #ifndef _AIO_H
24 #define _AIO_H 1
26 #include <features.h>
27 #include <fcntl.h>
28 #include <signal.h>
29 #include <time.h>
30 #include <sys/types.h>
32 __BEGIN_DECLS
34 /* Asynchronous I/O control block. */
35 struct aiocb
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;
46 int __abs_prio;
47 int __policy;
48 int __error_code;
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)];
54 #else
55 __off64_t aio_offset; /* File offset. */
56 #endif
57 char __unused[32];
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
63 struct aiocb64
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;
74 int __abs_prio;
75 int __policy;
76 int __error_code;
77 __ssize_t __return_value;
79 __off64_t aio_offset; /* File offset. */
80 char __unused[32];
82 #endif
85 #ifdef __USE_GNU
86 /* To customize the implementation one can use the following struct.
87 This implementation follows the one in Irix. */
88 struct aioinit
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
97 terminates. */
98 int aio_reserved;
100 #endif
103 /* Return values of cancelation function. */
104 enum
106 AIO_CANCELED,
107 #define AIO_CANCELED AIO_CANCELED
108 AIO_NOTCANCELED,
109 #define AIO_NOTCANCELED AIO_NOTCANCELED
110 AIO_ALLDONE
111 #define AIO_ALLDONE AIO_ALLDONE
115 /* Operation codes for `aio_lio_opcode'. */
116 enum
118 LIO_READ,
119 #define LIO_READ LIO_READ
120 LIO_WRITE,
121 #define LIO_WRITE LIO_WRITE
122 LIO_NOP
123 #define LIO_NOP LIO_NOP
127 /* Synchronization options for `lio_listio' function. */
128 enum
130 LIO_WAIT,
131 #define LIO_WAIT LIO_WAIT
132 LIO_NOWAIT
133 #define LIO_NOWAIT LIO_NOWAIT
137 /* Allow user to specify optimization. */
138 #ifdef __USE_GNU
139 extern void aio_init (__const struct aioinit *__init) __THROW;
140 #endif
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;
146 /* Enqueue write request for given number of bytes and the given priority. */
147 extern int aio_write (struct aiocb *__aiocbp) __THROW;
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) __THROW;
154 /* Retrieve error status associated with AIOCBP. */
155 extern int aio_error (__const struct aiocb *__aiocbp) __THROW;
156 /* Return status associated with AIOCBP. */
157 extern __ssize_t aio_return (struct aiocb *__aiocbp) __THROW;
159 /* Try to cancel asynchronous I/O requests outstanding against file
160 descriptor FILDES. */
161 extern int aio_cancel (int __fildes, struct aiocb *__aiocbp) __THROW;
163 /* Suspend calling thread until at least one of the asynchronous I/O
164 operations referenced by LIST has completed. */
165 extern int aio_suspend (__const struct aiocb *__const __list[], int __nent,
166 __const struct timespec *__restrict __timeout) __THROW;
168 /* Force all operations associated with file desriptor described by
169 `aio_fildes' member of AIOCBP. */
170 extern int aio_fsync (int __operation, struct aiocb *__aiocbp) __THROW;
171 #else
172 # ifdef __REDIRECT
173 extern int __REDIRECT (aio_read, (struct aiocb *__aiocbp) __THROW, aio_read64);
174 extern int __REDIRECT (aio_write, (struct aiocb *__aiocbp) __THROW,
175 aio_write64);
177 extern int __REDIRECT (lio_listio,
178 (int __mode,
179 struct aiocb *__const __list[__restrict_arr],
180 int __nent, struct sigevent *__restrict __sig) __THROW,
181 lio_listio64);
183 extern int __REDIRECT (aio_error, (__const struct aiocb *__aiocbp) __THROW,
184 aio_error64);
185 extern __ssize_t __REDIRECT (aio_return, (struct aiocb *__aiocbp) __THROW,
186 aio_return64);
188 extern int __REDIRECT (aio_cancel,
189 (int __fildes, struct aiocb *__aiocbp) __THROW,
190 aio_cancel64);
192 extern int __REDIRECT (aio_suspend,
193 (__const struct aiocb *__const __list[],
194 int __nent,
195 __const struct timespec *__restrict __timeout) __THROW,
196 aio_suspend64);
198 extern int __REDIRECT (aio_fsync,
199 (int __operation, struct aiocb *__aiocbp) __THROW,
200 aio_fsync64);
202 # else
203 # define aio_read aio_read64
204 # define aio_write aio_write64
205 # define lio_listio lio_listio64
206 # define aio_error aio_error64
207 # define aio_return aio_return64
208 # define aio_cancel aio_cancel64
209 # define aio_suspend aio_suspend64
210 # define aio_fsync aio_fsync64
211 # endif
212 #endif
214 #ifdef __USE_LARGEFILE64
215 extern int aio_read64 (struct aiocb64 *__aiocbp) __THROW;
216 extern int aio_write64 (struct aiocb64 *__aiocbp) __THROW;
218 extern int lio_listio64 (int __mode,
219 struct aiocb64 *__const __list[__restrict_arr],
220 int __nent, struct sigevent *__restrict __sig)
221 __THROW;
223 extern int aio_error64 (__const struct aiocb64 *__aiocbp) __THROW;
224 extern __ssize_t aio_return64 (struct aiocb64 *__aiocbp) __THROW;
226 extern int aio_cancel64 (int __fildes, struct aiocb64 *__aiocbp) __THROW;
228 extern int aio_suspend64 (__const struct aiocb64 *__const __list[], int __nent,
229 __const struct timespec *__restrict __timeout)
230 __THROW;
232 extern int aio_fsync64 (int __operation, struct aiocb64 *__aiocbp) __THROW;
233 #endif
235 __END_DECLS
237 #endif /* aio.h */