]> git.ipfire.org Git - thirdparty/glibc.git/blob - rt/aio.h
Update.
[thirdparty/glibc.git] / rt / aio.h
1 /* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
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.
8
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.
13
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. */
18
19 /*
20 * ISO/IEC 9945-1:1996 6.7: Asynchronous Input and Output
21 */
22
23 #ifndef _AIO_H
24 #define _AIO_H 1
25
26 #include <features.h>
27 #include <fcntl.h>
28 #include <signal.h>
29 #include <time.h>
30 #include <sys/types.h>
31
32 __BEGIN_DECLS
33
34 /* Asynchronous I/O control block. */
35 struct aiocb
36 {
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. */
43
44 /* Internal members. */
45 struct aiocb *__next_prio;
46 int __abs_prio;
47 int __policy;
48 int __error_code;
49 __ssize_t __return_value;
50
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];
58 };
59
60 /* The same for the 64bit offsets. */
61 #ifdef __USE_LARGEFILE64
62 struct aiocb64
63 {
64 int aio_fildes; /* File desriptor. */
65 int aio_lio_opcode; /* Operation to be performed. */
66 int aio_reqprio; /* Request priority offset. */
67 volatile void *aio_buf; /* Location of buffer. */
68 size_t aio_nbytes; /* Length of transfer. */
69 struct sigevent aio_sigevent; /* Signal number and value. */
70
71 /* Internal members. */
72 int __abs_prio;
73 int __policy;
74 int __error_code;
75 __ssize_t __return_value;
76
77 __off64_t aio_offset; /* File offset. */
78 char __unused[32];
79 };
80 #endif
81
82
83 #ifdef __USE_GNU
84 /* To customize the implementation one can use the following struct.
85 This implementation follows the one in Irix. */
86 struct aioinit
87 {
88 int aio_threads; /* Maximal number of threads. */
89 int aio_num; /* Number of expected simultanious requests. */
90 int aio_locks; /* Not used. */
91 int aio_usedba; /* Not used. */
92 int aio_debug; /* Not used. */
93 int aio_numusers; /* Not used. */
94 int aio_reserved[2];
95 };
96 #endif
97
98
99 /* Return values of cancelation function. */
100 enum
101 {
102 AIO_CANCELED,
103 #define AIO_CANCELED AIO_CANCELED
104 AIO_NOTCANCELED,
105 #define AIO_NOTCANCELED AIO_NOTCANCELED
106 AIO_ALLDONE
107 #define AIO_ALLDONE AIO_ALLDONE
108 };
109
110
111 /* Operation codes for `aio_lio_opcode'. */
112 enum
113 {
114 LIO_READ,
115 #define LIO_READ LIO_READ
116 LIO_WRITE,
117 #define LIO_WRITE LIO_WRITE
118 LIO_NOP
119 #define LIO_NOP LIO_NOP
120 };
121
122
123 /* Synchronization options for `lio_listio' function. */
124 enum
125 {
126 LIO_WAIT,
127 #define LIO_WAIT LIO_WAIT
128 LIO_NOWAIT
129 #define LIO_NOWAIT LIO_NOWAIT
130 };
131
132
133 /* Allow user to specify optimization. */
134 #ifdef __USE_GNU
135 extern void aio_init (__const struct aioinit *__init) __THROW;
136 #endif
137
138
139 #ifndef __USE_FILE_OFFSET64
140 /* Enqueue read request for given number of bytes and the given priority. */
141 extern int aio_read (struct aiocb *__aiocbp) __THROW;
142 /* Enqueue write request for given number of bytes and the given priority. */
143 extern int aio_write (struct aiocb *__aiocbp) __THROW;
144
145 /* Initiate list of I/O requests. */
146 extern int lio_listio (int __mode, struct aiocb *__const __list[],
147 int __nent, struct sigevent *__restrict __sig) __THROW;
148
149 /* Retrieve error status associated with AIOCBP. */
150 extern int aio_error (__const struct aiocb *__aiocbp) __THROW;
151 /* Return status associated with AIOCBP. */
152 extern __ssize_t aio_return (struct aiocb *__aiocbp) __THROW;
153
154 /* Try to cancel asynchronous I/O requests outstanding against file
155 descriptor FILDES. */
156 extern int aio_cancel (int __fildes, struct aiocb *__aiocbp) __THROW;
157
158 /* Suspend calling thread until at least one of the asynchronous I/O
159 operations referenced by LIST has completed. */
160 extern int aio_suspend (__const struct aiocb *__const __list[], int __nent,
161 __const struct timespec *__restrict __timeout) __THROW;
162
163 /* Force all operations associated with file desriptor described by
164 `aio_fildes' member of AIOCBP. */
165 extern int aio_fsync (int __operation, struct aiocb *__aiocbp) __THROW;
166 #else
167 # ifdef __REDIRECT
168 extern int __REDIRECT (aio_read, (struct aiocb *__aiocbp) __THROW, aio_read64);
169 extern int __REDIRECT (aio_write, (struct aiocb *__aiocbp) __THROW,
170 aio_write64);
171
172 extern int __REDIRECT (lio_listio,
173 (int __mode, struct aiocb *__const __restrict __list[],
174 int __nent, struct sigevent *__restrict __sig) __THROW,
175 lio_listio64);
176
177 extern int __REDIRECT (aio_error, (__const struct aiocb *__aiocbp) __THROW,
178 aio_error64);
179 extern __ssize_t __REDIRECT (aio_return, (struct aiocb *__aiocbp) __THROW,
180 aio_return64);
181
182 extern int __REDIRECT (aio_cancel,
183 (int __fildes, struct aiocb *__aiocbp) __THROW,
184 aio_cancel64);
185
186 extern int __REDIRECT (aio_suspend,
187 (__const struct aiocb *__const __restrict __list[],
188 int __nent,
189 __const struct timespec *__restrict __timeout) __THROW,
190 aio_suspend64);
191
192 extern int __REDIRECT (aio_fsync,
193 (int __operation, struct aiocb *__aiocbp) __THROW,
194 aio_fsync64);
195
196 # else
197 # define aio_read aio_read64
198 # define aio_write aio_write64
199 # define lio_listio lio_listio64
200 # define aio_error aio_error64
201 # define aio_return aio_return64
202 # define aio_cancel aio_cancel64
203 # define aio_suspend aio_suspend64
204 # define aio_fsync aio_fsync64
205 # endif
206 #endif
207
208 #ifdef __USE_LARGEFILE64
209 extern int aio_read64 (struct aiocb64 *__aiocbp) __THROW;
210 extern int aio_write64 (struct aiocb64 *__aiocbp) __THROW;
211
212 extern int lio_listio64 (int __mode, struct aiocb64 *__const __list[],
213 int __nent, struct sigevent *__restrict __sig)
214 __THROW;
215
216 extern int aio_error64 (__const struct aiocb64 *__aiocbp) __THROW;
217 extern __ssize_t aio_return64 (struct aiocb64 *__aiocbp) __THROW;
218
219 extern int aio_cancel64 (int __fildes, struct aiocb64 *__aiocbp) __THROW;
220
221 extern int aio_suspend64 (__const struct aiocb64 *__const __list[], int __nent,
222 __const struct timespec *__restrict __timeout)
223 __THROW;
224
225 extern int aio_fsync64 (int __operation, struct aiocb64 *__aiocbp) __THROW;
226 #endif
227
228 __END_DECLS
229
230 #endif /* aio.h */