xref: /illumos-gate/usr/src/head/fcntl.h (revision 88f8b78a88cbdc6d8c1af5c3e54bc49d25095c98)
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(__XOPEN_OR_POSIX) || \
81 	defined(_ATFILE_SOURCE)
82 #pragma redefine_extname	openat	openat64
83 #pragma	redefine_extname	attropen attropen64
84 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
85 #else
86 #define	open			open64
87 #define	creat			creat64
88 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
89 	defined(_ATFILE_SOURCE)
90 #define	openat			openat64
91 #define	attropen		attropen64
92 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
93 #endif
94 #endif	/* !_LP64 && _FILE_OFFSET_BITS == 64 */
95 
96 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
97 #ifdef __PRAGMA_REDEFINE_EXTNAME
98 #pragma	redefine_extname	open64	open
99 #pragma	redefine_extname	creat64	creat
100 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
101 	defined(_ATFILE_SOURCE)
102 #pragma	redefine_extname	openat64	openat
103 #pragma	redefine_extname	attropen64	attropen
104 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
105 #else
106 #define	open64				open
107 #define	creat64				creat
108 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
109 	defined(_ATFILE_SOURCE)
110 #define	openat64			openat
111 #define	attropen64			attropen
112 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
113 #endif
114 #endif	/* _LP64 && _LARGEFILE64_SOURCE */
115 
116 #if defined(__STDC__)
117 
118 extern int fcntl(int, int, ...);
119 extern int open(const char *, int, ...);
120 extern int creat(const char *, mode_t);
121 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
122 	defined(_ATFILE_SOURCE)
123 extern int openat(int, const char *, int, ...);
124 extern int attropen(const char *, const char *, int, ...);
125 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
126 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
127 extern int directio(int, int);
128 #endif
129 
130 /* transitional large file interface versions */
131 #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
132 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
133 extern int open64(const char *, int, ...);
134 extern int creat64(const char *, mode_t);
135 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
136 	defined(_ATFILE_SOURCE)
137 extern int openat64(int, const char *, int, ...);
138 extern int attropen64(const char *, const char *, int, ...);
139 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
140 #endif
141 
142 #else	/* defined(__STDC__) */
143 
144 extern int fcntl();
145 extern int open();
146 extern int creat();
147 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
148 	defined(_ATFILE_SOURCE)
149 extern int openat();
150 extern int attropen();
151 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
152 
153 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
154 extern int directio();
155 #endif
156 
157 /* transitional large file interface versions */
158 #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
159 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
160 extern int open64();
161 extern int creat64();
162 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
163 	defined(_ATFILE_SOURCE)
164 extern int openat64();
165 extern int attropen64();
166 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
167 #endif
168 
169 #endif	/* defined(__STDC__) */
170 
171 #ifdef	__cplusplus
172 }
173 #endif
174 
175 #endif	/* _FCNTL_H */
176