xref: /illumos-gate/usr/src/head/aio.h (revision 2d08521bd15501c8370ba2153b9cca4f094979d0)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _AIO_H
28 #define	_AIO_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/feature_tests.h>
33 #include <sys/types.h>
34 #include <sys/fcntl.h>
35 #include <sys/siginfo.h>
36 #include <sys/aiocb.h>
37 #include <time.h>
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 #if	(_POSIX_C_SOURCE - 0 > 0) && (_POSIX_C_SOURCE - 0 <= 2)
44 #error	"POSIX Asynchronous I/O is not supported in POSIX.1-1990"
45 #endif
46 
47 /* large file compilation environment setup */
48 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
49 #ifdef __PRAGMA_REDEFINE_EXTNAME
50 #pragma	redefine_extname	aio_read	aio_read64
51 #pragma	redefine_extname	aio_write	aio_write64
52 #pragma	redefine_extname	lio_listio	lio_listio64
53 #pragma	redefine_extname	aio_error	aio_error64
54 #pragma	redefine_extname	aio_return	aio_return64
55 #pragma	redefine_extname	aio_cancel	aio_cancel64
56 #pragma	redefine_extname	aio_suspend	aio_suspend64
57 #pragma	redefine_extname	aio_fsync	aio_fsync64
58 #pragma	redefine_extname	aio_waitn	aio_waitn64
59 #else
60 #define	aiocb		aiocb64
61 #define	aiocb_t		aiocb64_t
62 #define	aio_read	aio_read64
63 #define	aio_write	aio_write64
64 #define	lio_listio	lio_listio64
65 #define	aio_error	aio_error64
66 #define	aio_return	aio_return64
67 #define	aio_cancel	aio_cancel64
68 #define	aio_suspend	aio_suspend64
69 #define	aio_fsync	aio_fsync64
70 #define	aio_waitn	aio_waitn64
71 #endif
72 #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */
73 
74 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
75 /*
76  * In the LP64 compilation environment, map the 64-bit-explicit versions
77  * back to the generic versions: all i/o operations are already "large file"
78  */
79 #ifdef __PRAGMA_REDEFINE_EXTNAME
80 #pragma	redefine_extname	aio_read64	aio_read
81 #pragma	redefine_extname	aio_write64	aio_write
82 #pragma	redefine_extname	lio_listio64	lio_listio
83 #pragma	redefine_extname	aio_error64	aio_error
84 #pragma	redefine_extname	aio_return64	aio_return
85 #pragma	redefine_extname	aio_cancel64	aio_cancel
86 #pragma	redefine_extname	aio_suspend64	aio_suspend
87 #pragma	redefine_extname	aio_fsync64	aio_fsync
88 #pragma	redefine_extname	aio_waitn64	aio_waitn
89 #else
90 #define	aiocb64		aiocb
91 #define	aiocb64_t	aiocb_t
92 #define	aio_read64	aio_read
93 #define	aio_write64	aio_write
94 #define	lio_listio64	lio_listio
95 #define	aio_error64	aio_error
96 #define	aio_return64	aio_return
97 #define	aio_cancel64	aio_cancel
98 #define	aio_suspend64	aio_suspend
99 #define	aio_fsync64	aio_fsync
100 #define	aio_waitn64	aio_waitn
101 #endif
102 #endif	/* _LP64 && _LARGEFILE64_SOURCE */
103 
104 /*
105  * function prototypes
106  */
107 #if	defined(__STDC__)
108 extern int	aio_read(aiocb_t *);
109 extern int	aio_write(aiocb_t *);
110 extern int	lio_listio(int,
111 		    aiocb_t *_RESTRICT_KYWD const *_RESTRICT_KYWD,
112 		    int, struct sigevent *_RESTRICT_KYWD);
113 extern int	aio_error(const aiocb_t *);
114 extern ssize_t	aio_return(aiocb_t *);
115 extern int	aio_cancel(int, aiocb_t *);
116 extern int	aio_suspend(const aiocb_t *const[], int,
117 		    const struct timespec *);
118 extern int	aio_fsync(int, aiocb_t *);
119 extern int	aio_waitn(aiocb_t *[], uint_t, uint_t *,
120 		    const struct timespec *);
121 
122 
123 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
124 	!defined(__PRAGMA_REDEFINE_EXTNAME))
125 extern int	aio_read64(aiocb64_t *);
126 extern int	aio_write64(aiocb64_t *);
127 extern int	lio_listio64(int,
128 			aiocb64_t *_RESTRICT_KYWD const *_RESTRICT_KYWD,
129 			int, struct sigevent *_RESTRICT_KYWD);
130 extern int	aio_error64(const aiocb64_t *);
131 extern ssize_t	aio_return64(aiocb64_t *);
132 extern int	aio_cancel64(int, aiocb64_t *);
133 extern int	aio_suspend64(const aiocb64_t *const[], int,
134 			const struct timespec *);
135 extern int	aio_fsync64(int, aiocb64_t *);
136 extern int	aio_waitn64(aiocb64_t *[], uint_t, uint_t *,
137 		    const struct timespec *);
138 #endif	/* _LARGEFILE64_SOURCE */
139 
140 #else
141 extern int	aio_read();
142 extern int	aio_write();
143 extern int	lio_listio();
144 extern int	aio_error();
145 extern ssize_t	aio_return();
146 extern int	aio_cancel();
147 extern int	aio_suspend();
148 extern int	aio_fsync();
149 extern int	aio_waitn();
150 
151 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
152 	!defined(__PRAGMA_REDEFINE_EXTNAME))
153 extern int	aio_read64();
154 extern int	aio_write64();
155 extern int	lio_listio64();
156 extern int	aio_error64();
157 extern ssize_t	aio_return64();
158 extern int	aio_cancel64();
159 extern int	aio_suspend64();
160 extern int	aio_fsync64();
161 extern int	aio_waitn64();
162 #endif	/* _LARGEFILE64_SOURCE */
163 
164 #endif	/* __STDC__ */
165 
166 #ifdef	__cplusplus
167 }
168 #endif
169 
170 #endif	/* _AIO_H */
171