xref: /illumos-gate/usr/src/head/fcntl.h (revision 60a3f738d56f92ae8b80e4b62a2331c6e1f2311f)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*	Copyright (c) 1988 AT&T	*/
27 /*	  All Rights Reserved  	*/
28 
29 
30 #ifndef	_FCNTL_H
31 #define	_FCNTL_H
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.6.1.7 */
34 
35 #include <sys/feature_tests.h>
36 #if defined(__EXTENSIONS__) || defined(_XPG4)
37 #include <sys/stat.h>
38 #endif
39 #include <sys/types.h>
40 #include <sys/fcntl.h>
41 
42 #ifdef	__cplusplus
43 extern "C" {
44 #endif
45 
46 #if defined(__EXTENSIONS__) || defined(_XPG4)
47 
48 /* Symbolic constants for the "lseek" routine. */
49 
50 #ifndef	SEEK_SET
51 #define	SEEK_SET	0	/* Set file pointer to "offset" */
52 #endif
53 
54 #ifndef	SEEK_CUR
55 #define	SEEK_CUR	1	/* Set file pointer to current plus "offset" */
56 #endif
57 
58 #ifndef	SEEK_END
59 #define	SEEK_END	2	/* Set file pointer to EOF plus "offset" */
60 #endif
61 #endif /* defined(__EXTENSIONS__) || defined(_XPG4) */
62 
63 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
64 #ifndef	SEEK_DATA
65 #define	SEEK_DATA	3	/* Set file pointer to next data past offset */
66 #endif
67 
68 #ifndef	SEEK_HOLE
69 #define	SEEK_HOLE	4	/* Set file pointer to next hole past offset */
70 #endif
71 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
72 
73 
74 /* large file compilation environment setup */
75 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
76 #ifdef __PRAGMA_REDEFINE_EXTNAME
77 #pragma redefine_extname	open	open64
78 #pragma redefine_extname	creat	creat64
79 #if defined(__EXTENSIONS__) || defined(_XPG6) || !defined(__XOPEN_OR_POSIX)
80 #pragma redefine_extname	posix_fallocate posix_fallocate64
81 #endif /* defined(__EXTENSIONS__) || defined(_XPG6) ||  ... */
82 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
83 	defined(_ATFILE_SOURCE)
84 #pragma redefine_extname	openat	openat64
85 #pragma	redefine_extname	attropen attropen64
86 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
87 #else
88 #define	open			open64
89 #define	creat			creat64
90 #if defined(__EXTENSIONS__) || defined(_XPG6) || !defined(__XOPEN_OR_POSIX)
91 #define	posix_fallocate		posix_fallocate64
92 #endif /* defined(__EXTENSIONS__) || defined(_XPG6) ||  ... */
93 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
94 	defined(_ATFILE_SOURCE)
95 #define	openat			openat64
96 #define	attropen		attropen64
97 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
98 #endif
99 #endif	/* !_LP64 && _FILE_OFFSET_BITS == 64 */
100 
101 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
102 #ifdef __PRAGMA_REDEFINE_EXTNAME
103 #pragma	redefine_extname	open64	open
104 #pragma	redefine_extname	creat64	creat
105 #if defined(__EXTENSIONS__) || defined(_XPG6) || !defined(__XOPEN_OR_POSIX)
106 #pragma redefine_extname	posix_fallocate64 posix_fallocate
107 #endif /* defined(__EXTENSIONS__) || defined(_XPG6) ||  ... */
108 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
109 	defined(_ATFILE_SOURCE)
110 #pragma	redefine_extname	openat64	openat
111 #pragma	redefine_extname	attropen64	attropen
112 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
113 #else
114 #define	open64				open
115 #define	creat64				creat
116 #if defined(__EXTENSIONS__) || defined(_XPG6) || !defined(__XOPEN_OR_POSIX)
117 #define	posix_fallocate64		posix_fallocate
118 #endif /* defined(__EXTENSIONS__) || defined(_XPG6) ||  ... */
119 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
120 	defined(_ATFILE_SOURCE)
121 #define	openat64			openat
122 #define	attropen64			attropen
123 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
124 #endif
125 #endif	/* _LP64 && _LARGEFILE64_SOURCE */
126 
127 #if defined(__STDC__)
128 
129 extern int fcntl(int, int, ...);
130 extern int open(const char *, int, ...);
131 extern int creat(const char *, mode_t);
132 #if defined(__EXTENSIONS__) || defined(_XPG6) || !defined(__XOPEN_OR_POSIX)
133 extern int posix_fallocate(int, off_t, off_t);
134 #endif /* defined(__EXTENSIONS__) || defined(_XPG6) || ... */
135 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
136 	defined(_ATFILE_SOURCE)
137 extern int openat(int, const char *, int, ...);
138 extern int attropen(const char *, const char *, int, ...);
139 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
140 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
141 extern int directio(int, int);
142 #endif
143 
144 /* transitional large file interface versions */
145 #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
146 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
147 extern int open64(const char *, int, ...);
148 extern int creat64(const char *, mode_t);
149 #if defined(__EXTENSIONS__) || defined(_XPG6) || !defined(__XOPEN_OR_POSIX)
150 extern int posix_fallocate64(int, off64_t, off64_t);
151 #endif /* defined(__EXTENSIONS__) || defined(_XPG6) || ... */
152 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
153 	defined(_ATFILE_SOURCE)
154 extern int openat64(int, const char *, int, ...);
155 extern int attropen64(const char *, const char *, int, ...);
156 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
157 #endif
158 
159 #else	/* defined(__STDC__) */
160 
161 extern int fcntl();
162 extern int open();
163 extern int creat();
164 #if defined(__EXTENSIONS__) || defined(_XPG6) || !defined(__XOPEN_OR_POSIX)
165 extern int posix_fallocate();
166 #endif /* defined(__EXTENSIONS__) || defined(_XPG6) || ... */
167 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
168 	defined(_ATFILE_SOURCE)
169 extern int openat();
170 extern int attropen();
171 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
172 
173 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
174 extern int directio();
175 #endif
176 
177 /* transitional large file interface versions */
178 #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
179 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
180 extern int open64();
181 extern int creat64();
182 #if defined(__EXTENSIONS__) || defined(_XPG6) || !defined(__XOPEN_OR_POSIX)
183 extern int posix_fallocate64();
184 #endif /* defined(__EXTENSIONS__) || defined(_XPG6) || ... */
185 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
186 	defined(_ATFILE_SOURCE)
187 extern int openat64();
188 extern int attropen64();
189 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
190 #endif
191 
192 #endif	/* defined(__STDC__) */
193 
194 #ifdef	__cplusplus
195 }
196 #endif
197 
198 #endif	/* _FCNTL_H */
199