xref: /illumos-gate/usr/src/head/aio.h (revision d2a70789f056fc6c9ce3ab047b52126d80b0e3da)
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 2014 Garrett D'Amore <garrett@damore.org>
24  *
25  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms.
27  */
28 
29 #ifndef _AIO_H
30 #define	_AIO_H
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 extern int	aio_read(aiocb_t *);
108 extern int	aio_write(aiocb_t *);
109 extern int	lio_listio(int,
110 		    aiocb_t *_RESTRICT_KYWD const *_RESTRICT_KYWD,
111 		    int, struct sigevent *_RESTRICT_KYWD);
112 extern int	aio_error(const aiocb_t *);
113 extern ssize_t	aio_return(aiocb_t *);
114 extern int	aio_cancel(int, aiocb_t *);
115 extern int	aio_suspend(const aiocb_t *const[], int,
116 		    const struct timespec *);
117 extern int	aio_fsync(int, aiocb_t *);
118 extern int	aio_waitn(aiocb_t *[], uint_t, uint_t *,
119 		    const struct timespec *);
120 
121 
122 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
123 	!defined(__PRAGMA_REDEFINE_EXTNAME))
124 extern int	aio_read64(aiocb64_t *);
125 extern int	aio_write64(aiocb64_t *);
126 extern int	lio_listio64(int,
127 			aiocb64_t *_RESTRICT_KYWD const *_RESTRICT_KYWD,
128 			int, struct sigevent *_RESTRICT_KYWD);
129 extern int	aio_error64(const aiocb64_t *);
130 extern ssize_t	aio_return64(aiocb64_t *);
131 extern int	aio_cancel64(int, aiocb64_t *);
132 extern int	aio_suspend64(const aiocb64_t *const[], int,
133 			const struct timespec *);
134 extern int	aio_fsync64(int, aiocb64_t *);
135 extern int	aio_waitn64(aiocb64_t *[], uint_t, uint_t *,
136 		    const struct timespec *);
137 #endif	/* _LARGEFILE64_SOURCE */
138 
139 #ifdef	__cplusplus
140 }
141 #endif
142 
143 #endif	/* _AIO_H */
144