xref: /titanic_41/usr/src/head/fcntl.h (revision a8c92b49f4e8de856d9e4775e15e4fa90a687664)
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 /*
23  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24  *
25  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms.
27  */
28 
29 /*	Copyright (c) 1988 AT&T	*/
30 /*	  All Rights Reserved  	*/
31 
32 #ifndef	_FCNTL_H
33 #define	_FCNTL_H
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(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
80 #pragma redefine_extname	posix_fadvise posix_fadvise64
81 #pragma redefine_extname	posix_fallocate posix_fallocate64
82 #endif /* !defined(__XOPEN_OR_POSIX) || 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(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
92 #define	posix_fadvise		posix_fadvise64
93 #define	posix_fallocate		posix_fallocate64
94 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */
95 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
96 	defined(_ATFILE_SOURCE)
97 #define	openat			openat64
98 #define	attropen		attropen64
99 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
100 #endif
101 #endif	/* !_LP64 && _FILE_OFFSET_BITS == 64 */
102 
103 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
104 #ifdef __PRAGMA_REDEFINE_EXTNAME
105 #pragma	redefine_extname	open64	open
106 #pragma	redefine_extname	creat64	creat
107 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
108 #pragma redefine_extname	posix_fadvise64 posix_fadvise
109 #pragma redefine_extname	posix_fallocate64 posix_fallocate
110 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */
111 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
112 	defined(_ATFILE_SOURCE)
113 #pragma	redefine_extname	openat64	openat
114 #pragma	redefine_extname	attropen64	attropen
115 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
116 #else
117 #define	open64				open
118 #define	creat64				creat
119 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
120 #define	posix_fadvise64			posix_fadvise
121 #define	posix_fallocate64		posix_fallocate
122 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */
123 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
124 	defined(_ATFILE_SOURCE)
125 #define	openat64			openat
126 #define	attropen64			attropen
127 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
128 #endif
129 #endif	/* _LP64 && _LARGEFILE64_SOURCE */
130 
131 extern int fcntl(int, int, ...);
132 extern int open(const char *, int, ...);
133 extern int creat(const char *, mode_t);
134 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
135 extern int posix_fadvise(int, off_t, off_t, int);
136 extern int posix_fallocate(int, off_t, off_t);
137 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */
138 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
139 	defined(_ATFILE_SOURCE)
140 extern int openat(int, const char *, int, ...);
141 extern int attropen(const char *, const char *, int, ...);
142 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
143 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
144 extern int directio(int, int);
145 #endif
146 
147 /* transitional large file interface versions */
148 #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
149 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
150 extern int open64(const char *, int, ...);
151 extern int creat64(const char *, mode_t);
152 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
153 extern int posix_fadvise64(int, off64_t, off64_t, int);
154 extern int posix_fallocate64(int, off64_t, off64_t);
155 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */
156 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
157 	defined(_ATFILE_SOURCE)
158 extern int openat64(int, const char *, int, ...);
159 extern int attropen64(const char *, const char *, int, ...);
160 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
161 #endif
162 
163 #ifdef	__cplusplus
164 }
165 #endif
166 
167 #endif	/* _FCNTL_H */
168