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 2008 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 #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(__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 #if defined(__STDC__)
 132 
 133 extern int fcntl(int, int, ...);
 134 extern int open(const char *, int, ...);
 135 extern int creat(const char *, mode_t);
 136 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
 137 extern int posix_fadvise(int, off_t, off_t, int);
 138 extern int posix_fallocate(int, off_t, off_t);
 139 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */
 140 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
 141         defined(_ATFILE_SOURCE)
 142 extern int openat(int, const char *, int, ...);
 143 extern int attropen(const char *, const char *, int, ...);
 144 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
 145 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
 146 extern int directio(int, int);
 147 #endif
 148 
 149 /* transitional large file interface versions */
 150 #if     defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
 151             !defined(__PRAGMA_REDEFINE_EXTNAME))
 152 extern int open64(const char *, int, ...);
 153 extern int creat64(const char *, mode_t);
 154 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
 155 extern int posix_fadvise64(int, off64_t, off64_t, int);
 156 extern int posix_fallocate64(int, off64_t, off64_t);
 157 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */
 158 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
 159         defined(_ATFILE_SOURCE)
 160 extern int openat64(int, const char *, int, ...);
 161 extern int attropen64(const char *, const char *, int, ...);
 162 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
 163 #endif
 164 
 165 #else   /* defined(__STDC__) */
 166 
 167 extern int fcntl();
 168 extern int open();
 169 extern int creat();
 170 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
 171 extern int posix_fadvise();
 172 extern int posix_fallocate();
 173 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */
 174 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
 175         defined(_ATFILE_SOURCE)
 176 extern int openat();
 177 extern int attropen();
 178 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
 179 
 180 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
 181 extern int directio();
 182 #endif
 183 
 184 /* transitional large file interface versions */
 185 #if     defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
 186             !defined(__PRAGMA_REDEFINE_EXTNAME))
 187 extern int open64();
 188 extern int creat64();
 189 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
 190 extern int posix_fadvise64();
 191 extern int posix_fallocate64();
 192 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */
 193 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
 194         defined(_ATFILE_SOURCE)
 195 extern int openat64();
 196 extern int attropen64();
 197 #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
 198 #endif
 199 
 200 #endif  /* defined(__STDC__) */
 201 
 202 #ifdef  __cplusplus
 203 }
 204 #endif
 205 
 206 #endif  /* _FCNTL_H */