Update.
[platform/upstream/glibc.git] / rt / aio.h
1 /* Copyright (C) 1996, 1997 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 #define __need_timespec
30 #include <time.h>
31 #include <sys/types.h>
32
33 __BEGIN_DECLS
34
35 /* Asynchronous I/O control block.  */
36 struct aiocb
37 {
38   int aio_fildes;               /* File desriptor.  */
39   int aio_lio_opcode;           /* Operation to be performed.  */
40   int aio_reqprio;              /* Request priority offset.  */
41   volatile void *aio_buf;       /* Location of buffer.  */
42   size_t aio_nbytes;            /* Length of transfer.  */
43   struct sigevent aio_sigevent; /* Signal number and value.  */
44
45   /* Internal members.  */
46   struct aiocb *__last_fd;
47   struct aiocb *__next_fd;
48   struct aiocb *__next_prio;
49   int __abs_prio;
50   int __policy;
51   int __error_code;
52   __ssize_t __return_value;
53
54 #ifndef __USE_FILE_OFFSET64
55   __off_t aio_offset;           /* File offset.  */
56 #else
57   __off64_t aio_offset;         /* File offset.  */
58 #endif
59   int __unused[32];
60 };
61
62 /* The same for the 64bit offsets.  */
63 #ifdef __USE_LARGEFILE64
64 struct aiocb64
65 {
66   int aio_fildes;               /* File desriptor.  */
67   int aio_lio_opcode;           /* Operation to be performed.  */
68   int aio_reqprio;              /* Request priority offset.  */
69   volatile void *aio_buf;       /* Location of buffer.  */
70   size_t aio_nbytes;            /* Length of transfer.  */
71   struct sigevent aio_sigevent; /* Signal number and value.  */
72
73   /* Internal members.  */
74   struct aiocb64 *__last_fd;
75   struct aiocb64 *__next_fd;
76   struct aiocb64 *__next_prio;
77   int __abs_prio;
78   int __policy;
79   int __error_code;
80   __ssize_t __return_value;
81
82   __off64_t aio_offset;         /* File offset.  */
83   int __unused[32];
84 };
85 #endif
86
87
88 /* Return values of cancelation function.  */
89 enum
90 {
91   AIO_CANCELED,
92 #define AIO_CANCELED AIO_CANCELED
93   AIO_NOTCANCELED,
94 #define AIO_NOTCANCELED AIO_NOTCANCELED
95   AIO_ALLDONE
96 #define AIO_ALLDONE AIO_ALLDONE
97 };
98
99
100 /* Operation codes for `aio_lio_opcode'.  */
101 enum
102 {
103   LIO_READ,
104 #define LIO_READ LIO_READ
105   LIO_WRITE,
106 #define LIO_WRITE LIO_WRITE
107   LIO_NOP,
108 #define LIO_NOP LIO_NOP
109   __LIO_DSYNC,
110   __LIO_SYNC,
111   __LIO_READ64 = LIO_READ | 128,
112   __LIO_WRITE64 = LIO_WRITE | 128
113 };
114
115
116 /* Synchronization options for `lio_listio' function.  */
117 enum
118 {
119   LIO_WAIT,
120 #define LIO_WAIT LIO_WAIT
121   LIO_NOWAIT
122 #define LIO_NOWAIT LIO_NOWAIT
123 };
124
125
126 /* Enqueue read request for given number of bytes and the given priority.  */
127 #ifndef __USE_FILE_OFFSET64
128 extern int aio_read __P ((struct aiocb *__aiocbp));
129 #else
130 extern int aio_read __P ((struct aiocb *__aiocbp)) __asm__ ("aio_read64");
131 #endif
132 #ifdef __USE_LARGEFILE64
133 extern int aio_read64 __P ((struct aiocb64 *__aiocbp));
134 #endif
135
136 /* Enqueue write request for given number of bytes and the given priority.  */
137 #ifndef __USE_FILE_OFFSET64
138 extern int aio_write __P ((struct aiocb *__aiocbp));
139 #else
140 extern int aio_write __P ((struct aiocb *__aiocbp)) __asm__ ("aio_write64");
141 #endif
142 #ifdef __USE_LARGEFILE64
143 extern int aio_write64 __P ((struct aiocb64 *__aiocbp));
144 #endif
145
146
147 /* Initiate list of I/O requests.  */
148 #ifndef __USE_FILE_OFFSET64
149 extern int lio_listio __P ((int __mode, struct aiocb *__const __list[],
150                             int __nent, struct sigevent *__sig));
151 #else
152 extern int lio_listio __P ((int __mode, struct aiocb *__const __list[],
153                             int __nent, struct sigevent *__sig))
154      __asm__ ("lio_listio64");
155 #endif
156 #ifdef __USE_LARGEFILE64
157 extern int lio_listio64 __P ((int __mode, struct aiocb64 *__const __list[],
158                               int __nent, struct sigevent *__sig));
159 #endif
160
161
162 /* Retrieve error status associated with AIOCBP.  */
163 #ifndef __USE_FILE_OFFSET64
164 extern int aio_error __P ((__const struct aiocb *__aiocbp));
165 #else
166 extern int aio_error __P ((__const struct aiocb *__aiocbp))
167      __asm__ ("aio_error64");;
168 #endif
169 #ifdef __USE_LARGEFILE64
170 extern int aio_error64 __P ((__const struct aiocb64 *__aiocbp));
171 #endif
172
173
174 /* Return status associated with AIOCBP.  */
175 #ifndef __USE_FILE_OFFSET64
176 extern __ssize_t aio_return __P ((struct aiocb *__aiocbp));
177 #else
178 extern __ssize_t aio_return __P ((struct aiocb *__aiocbp))
179      __asm__ ("aio_return64");
180 #endif
181 #ifdef __USE_LARGEFILE64
182 extern __ssize_t aio_return64 __P ((struct aiocb64 *__aiocbp));
183 #endif
184
185
186 /* Try to cancel asynchronous I/O requests outstanding against file
187    descriptot FILDES.  */
188 #ifndef __USE_FILE_OFFSET64
189 extern int aio_cancel __P ((int __fildes, struct aiocb *__aiocbp));
190 #else
191 extern int aio_cancel __P ((int __fildes, struct aiocb *__aiocbp))
192      __asm__ ("aio_cancel64");
193 #endif
194 #ifdef __USE_LARGEFILE64
195 extern int aio_cancel64 __P ((int __fildes, struct aiocb64 *__aiocbp));
196 #endif
197
198
199 /* Suspend calling thread until at least one of the asynchronous I/O
200    operations referenced by LIST has completed.  */
201 #ifndef __USE_FILE_OFFSET64
202 extern int aio_suspend __P ((__const struct aiocb *__const __list[],
203                              int __nent, __const struct timespec *__timeout));
204 #else
205 extern int aio_suspend __P ((__const struct aiocb *__const __list[],
206                              int __nent, __const struct timespec *__timeout))
207      __asm__ ("aio_suspend64");
208 #endif
209 #ifdef __USE_LARGEFILE64
210 extern int aio_suspend64 __P ((__const struct aiocb64 *__const __list[],
211                                int __nent,
212                                __const struct timespec *__timeout));
213 #endif
214
215
216 /* Force all operations associated with file desriptor described by
217    `aio_fildes' member of AIOCBP.  */
218 #ifndef __USE_FILE_OFFSET64
219 extern int aio_fsync __P ((int __op, struct aiocb *__aiocbp));
220 #else
221 extern int aio_fsync __P ((int __op, struct aiocb *__aiocbp))
222      __asm__ ("aio_fsync64");
223 #endif
224 #ifdef __USE_LARGEFILE64
225 extern int aio_fsync64 __P ((int __op, struct aiocb64 *__aiocbp));
226 #endif
227
228
229 __END_DECLS
230
231 #endif /* aio.h */