xref: /illumos-gate/usr/src/head/fcntl.h (revision 43d18f1c320355e93c47399bea0b2e022fe06364)
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 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1988 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 
31 #ifndef	_FCNTL_H
32 #define	_FCNTL_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.6.1.7 */
35 
36 #include <sys/feature_tests.h>
37 #if defined(__EXTENSIONS__) || defined(_XPG4)
38 #include <sys/stat.h>
39 #endif
40 #include <sys/types.h>
41 #include <sys/fcntl.h>
42 
43 #ifdef	__cplusplus
44 extern "C" {
45 #endif
46 
47 #if defined(__EXTENSIONS__) || defined(_XPG4)
48 
49 /* Symbolic constants for the "lseek" routine. */
50 
51 #ifndef	SEEK_SET
52 #define	SEEK_SET	0	/* Set file pointer to "offset" */
53 #endif
54 
55 #ifndef	SEEK_CUR
56 #define	SEEK_CUR	1	/* Set file pointer to current plus "offset" */
57 #endif
58 
59 #ifndef	SEEK_END
60 #define	SEEK_END	2	/* Set file pointer to EOF plus "offset" */
61 #endif
62 #endif /* defined(__EXTENSIONS__) || defined(_XPG4) */
63 
64 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
65 #ifndef	SEEK_DATA
66 #define	SEEK_DATA	3	/* Set file pointer to next data past offset */
67 #endif
68 
69 #ifndef	SEEK_HOLE
70 #define	SEEK_HOLE	4	/* Set file pointer to next hole past offset */
71 #endif
72 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
73 
74 
75 /* large file compilation environment setup */
76 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
77 #ifdef __PRAGMA_REDEFINE_EXTNAME
78 #pragma redefine_extname	open	open64
79 #pragma redefine_extname	creat	creat64
80 #if defined(__EXTENSIONS__) || defined(_XPG6) || !defined(__XOPEN_OR_POSIX)
81 #pragma redefine_extname	posix_fallocate posix_fallocate64
82 #endif /* defined(__EXTENSIONS__) || defined(_XPG6) ||  ... */
83 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
84 	defined(_ATFILE_SOURCE)
85 #pragma redefine_extname	openat	openat64
86 #pragma	redefine_extname	attropen attropen64
87 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
88 #else
89 #define	open			open64
90 #define	creat			creat64
91 #if defined(__EXTENSIONS__) || defined(_XPG6) || !defined(__XOPEN_OR_POSIX)
92 #define	posix_fallocate		posix_fallocate64
93 #endif /* defined(__EXTENSIONS__) || defined(_XPG6) ||  ... */
94 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
95 	defined(_ATFILE_SOURCE)
96 #define	openat			openat64
97 #define	attropen		attropen64
98 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
99 #endif
100 #endif	/* !_LP64 && _FILE_OFFSET_BITS == 64 */
101 
102 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
103 #ifdef __PRAGMA_REDEFINE_EXTNAME
104 #pragma	redefine_extname	open64	open
105 #pragma	redefine_extname	creat64	creat
106 #if defined(__EXTENSIONS__) || defined(_XPG6) || !defined(__XOPEN_OR_POSIX)
107 #pragma redefine_extname	posix_fallocate64 posix_fallocate
108 #endif /* defined(__EXTENSIONS__) || defined(_XPG6) ||  ... */
109 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
110 	defined(_ATFILE_SOURCE)
111 #pragma	redefine_extname	openat64	openat
112 #pragma	redefine_extname	attropen64	attropen
113 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
114 #else
115 #define	open64				open
116 #define	creat64				creat
117 #if defined(__EXTENSIONS__) || defined(_XPG6) || !defined(__XOPEN_OR_POSIX)
118 #define	posix_fallocate64		posix_fallocate
119 #endif /* defined(__EXTENSIONS__) || defined(_XPG6) ||  ... */
120 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
121 	defined(_ATFILE_SOURCE)
122 #define	openat64			openat
123 #define	attropen64			attropen
124 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
125 #endif
126 #endif	/* _LP64 && _LARGEFILE64_SOURCE */
127 
128 #if defined(__STDC__)
129 
130 extern int fcntl(int, int, ...);
131 extern int open(const char *, int, ...);
132 extern int creat(const char *, mode_t);
133 #if defined(__EXTENSIONS__) || defined(_XPG6) || !defined(__XOPEN_OR_POSIX)
134 extern int posix_fallocate(int fd, off_t offset, off_t len);
135 #endif /* defined(__EXTENSIONS__) || defined(_XPG6) || ... */
136 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
137 	defined(_ATFILE_SOURCE)
138 extern int openat(int, const char *, int, ...);
139 extern int attropen(const char *, const char *, int, ...);
140 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
141 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
142 extern int directio(int, int);
143 #endif
144 
145 /* transitional large file interface versions */
146 #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
147 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
148 extern int open64(const char *, int, ...);
149 extern int creat64(const char *, mode_t);
150 #if defined(__EXTENSIONS__) || defined(_XPG6) || !defined(__XOPEN_OR_POSIX)
151 extern int posix_fallocate64(int fd, off64_t offset, off64_t len);
152 #endif /* defined(__EXTENSIONS__) || defined(_XPG6) || ... */
153 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
154 	defined(_ATFILE_SOURCE)
155 extern int openat64(int, const char *, int, ...);
156 extern int attropen64(const char *, const char *, int, ...);
157 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
158 #endif
159 
160 #else	/* defined(__STDC__) */
161 
162 extern int fcntl();
163 extern int open();
164 extern int creat();
165 #if defined(__EXTENSIONS__) || defined(_XPG6) || !defined(__XOPEN_OR_POSIX)
166 extern int posix_fallocate();
167 #endif /* defined(__EXTENSIONS__) || defined(_XPG6) || ... */
168 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
169 	defined(_ATFILE_SOURCE)
170 extern int openat();
171 extern int attropen();
172 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
173 
174 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
175 extern int directio();
176 #endif
177 
178 /* transitional large file interface versions */
179 #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
180 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
181 extern int open64();
182 extern int creat64();
183 #if defined(__EXTENSIONS__) || defined(_XPG6) || !defined(__XOPEN_OR_POSIX)
184 extern int posix_fallocate64();
185 #endif /* defined(__EXTENSIONS__) || defined(_XPG6) || ... */
186 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
187 	defined(_ATFILE_SOURCE)
188 extern int openat64();
189 extern int attropen64();
190 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
191 #endif
192 
193 #endif	/* defined(__STDC__) */
194 
195 #ifdef	__cplusplus
196 }
197 #endif
198 
199 #endif	/* _FCNTL_H */
200