sparc64: add basic support
[uclibc-ng.git] / libc / sysdeps / linux / sparc64 / bits / fcntl.h
blobdad3470b8075ab14b03af9c442c729f5e819d469
1 /* O_*, F_*, FD_* bit values for Linux/SPARC64.
2 Copyright (C) 1995-2017 Free Software Foundation, Inc.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #ifndef _FCNTL_H
19 # error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
20 #endif
22 #include <sys/types.h>
23 #ifdef __USE_GNU
24 # include <bits/uio.h>
25 #endif
27 /* open/fcntl - O_SYNC is only implemented on blocks devices and on files
28 located on an ext2 file system */
29 #define O_RDONLY 0x0000
30 #define O_WRONLY 0x0001
31 #define O_RDWR 0x0002
32 #define O_ACCMODE 0x0003
33 #define O_APPEND 0x0008
34 #define O_ASYNC 0x0040
35 #define O_CREAT 0x0200 /* not fcntl */
36 #define O_TRUNC 0x0400 /* not fcntl */
37 #define O_EXCL 0x0800 /* not fcntl */
38 #define O_SYNC 0x2000
39 #define O_NONBLOCK 0x4000
40 #define O_NDELAY (0x0004 | O_NONBLOCK)
41 #define O_NOCTTY 0x8000 /* not fcntl */
43 #ifdef __USE_GNU
44 # define O_DIRECTORY 0x10000 /* must be a directory */
45 # define O_NOFOLLOW 0x20000 /* don't follow links */
46 # define O_DIRECT 0x100000 /* direct disk access hint */
47 # define O_NOATIME 0x200000 /* Do not set atime. */
48 # define O_CLOEXEC 0x400000 /* Set close_on_exit. */
49 # define O_PATH 0x1000000 /* Resolve pathname but do not open file. */
50 #endif
52 #ifdef __USE_LARGEFILE64
53 # define O_LARGEFILE 0
54 #endif
56 /* For now Linux has no synchronisity options for data and read
57 operations. We define the symbols here but let them do the same as
58 O_SYNC since this is a superset. */
59 #if defined __USE_POSIX199309 || defined __USE_UNIX98
60 # define O_DSYNC O_SYNC /* Synchronize data. */
61 # define O_RSYNC O_SYNC /* Synchronize read operations. */
62 #endif
64 /* For now Linux has synchronisity options for data and read operations.
65 We define the symbols here but let them do the same as O_SYNC since
66 this is a superset. */
67 #if defined __USE_POSIX199309 || defined __USE_UNIX98
68 # define O_DSYNC O_SYNC /* Synchronize data. */
69 # define O_RSYNC O_SYNC /* Synchronize read operations. */
70 #endif
72 /* Values for the second argument to `fcntl'. */
73 #define F_DUPFD 0 /* Duplicate file descriptor. */
74 #define F_GETFD 1 /* Get file descriptor flags. */
75 #define F_SETFD 2 /* Set file descriptor flags. */
76 #define F_GETFL 3 /* Get file status flags. */
77 #define F_SETFL 4 /* Set file status flags. */
78 #if defined __USE_BSD || defined __USE_UNIX98
79 # define F_GETOWN 5 /* Get owner of socket (receiver of SIGIO). */
80 # define F_SETOWN 6 /* Set owner of socket (receiver of SIGIO). */
81 #endif
82 #ifndef __USE_FILE_OFFSET64
83 # define F_GETLK 7 /* Get record locking info. */
84 # define F_SETLK 8 /* Set record locking info (non-blocking). */
85 # define F_SETLKW 9 /* Set record locking info (blocking). */
86 #else
87 # define F_GETLK F_GETLK64 /* Get record locking info. */
88 # define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/
89 # define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
90 #endif
92 #ifdef __USE_GNU
93 # define F_SETSIG 10 /* Set number of signal to be sent. */
94 # define F_GETSIG 11 /* Get number of signal to be sent. */
95 #endif
97 #ifdef __USE_GNU
98 # define F_SETLEASE 1024 /* Set a lease. */
99 # define F_GETLEASE 1025 /* Enquire what lease is active. */
100 # define F_NOTIFY 1026 /* Request notfications on a directory. */
101 # define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
102 close-on-exit set on new fd. */
103 # define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
104 # define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
105 #endif
107 #define F_GETLK64 7 /* Get record locking info. */
108 #define F_SETLK64 8 /* Set record locking info (non-blocking). */
109 #define F_SETLKW64 9 /* Set record locking info (blocking). */
111 /* for F_[GET|SET]FD */
112 #define FD_CLOEXEC 1 /* actually anything with low bit set goes */
114 /* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
115 #define F_RDLCK 1 /* Read lock. */
116 #define F_WRLCK 2 /* Write lock. */
117 #define F_UNLCK 3 /* Remove lock. */
119 /* for old implementation of bsd flock () */
120 #define F_EXLCK 4 /* or 3 */
121 #define F_SHLCK 8 /* or 4 */
123 #ifdef __USE_BSD
124 /* Operations for bsd flock(), also used by the kernel implementation */
125 # define LOCK_SH 1 /* shared lock */
126 # define LOCK_EX 2 /* exclusive lock */
127 # define LOCK_NB 4 /* or'd with one of the above to prevent
128 blocking */
129 # define LOCK_UN 8 /* remove lock */
130 #endif
132 #ifdef __USE_GNU
133 # define LOCK_MAND 32 /* This is a mandatory flock: */
134 # define LOCK_READ 64 /* ... which allows concurrent read operations. */
135 # define LOCK_WRITE 128 /* ... which allows concurrent write operations. */
136 # define LOCK_RW 192 /* ... Which allows concurrent read & write operations. */
137 #endif
139 #ifdef __USE_GNU
140 /* Types of directory notifications that may be requested with F_NOTIFY. */
141 # define DN_ACCESS 0x00000001 /* File accessed. */
142 # define DN_MODIFY 0x00000002 /* File modified. */
143 # define DN_CREATE 0x00000004 /* File created. */
144 # define DN_DELETE 0x00000008 /* File removed. */
145 # define DN_RENAME 0x00000010 /* File renamed. */
146 # define DN_ATTRIB 0x00000020 /* File changed attibutes. */
147 # define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
148 #endif
150 struct flock
152 short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
153 short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
154 #ifndef __USE_FILE_OFFSET64
155 __off_t l_start; /* Offset where the lock begins. */
156 __off_t l_len; /* Size of the locked area; zero means until EOF. */
157 #else
158 __off64_t l_start; /* Offset where the lock begins. */
159 __off64_t l_len; /* Size of the locked area; zero means until EOF. */
160 #endif
161 __pid_t l_pid; /* Process holding the lock. */
162 short int __unused;
165 #ifdef __USE_LARGEFILE64
166 struct flock64
168 short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
169 short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
170 __off64_t l_start; /* Offset where the lock begins. */
171 __off64_t l_len; /* Size of the locked area; zero means until EOF. */
172 __pid_t l_pid; /* Process holding the lock. */
173 short int __unused;
175 #endif
177 /* Define some more compatibility macros to be backward compatible with
178 BSD systems which did not managed to hide these kernel macros. */
179 #ifdef __USE_BSD
180 # define FAPPEND O_APPEND
181 # define FFSYNC O_FSYNC
182 # define FASYNC O_ASYNC
183 # define FNONBLOCK O_NONBLOCK
184 # define FNDELAY O_NDELAY
185 #endif /* Use BSD. */
187 /* Advise to `posix_fadvise'. */
188 #ifdef __USE_XOPEN2K
189 # define POSIX_FADV_NORMAL 0 /* No further special treatment. */
190 # define POSIX_FADV_RANDOM 1 /* Expect random page references. */
191 # define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
192 # define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
193 # define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
194 # define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
195 #endif
198 #if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
199 /* Flags for SYNC_FILE_RANGE. */
200 # define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
201 in the range before performing the
202 write. */
203 # define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those
204 dirty pages in the range which are
205 not presently under writeback. */
206 # define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
207 the range after performing the
208 write. */
210 /* Flags for SPLICE and VMSPLICE. */
211 # define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
212 # define SPLICE_F_NONBLOCK 2 /* Don't block on the pipe splicing
213 (but we may still block on the fd
214 we splice from/to). */
215 # define SPLICE_F_MORE 4 /* Expect more data. */
216 # define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */
217 #endif
219 __BEGIN_DECLS
221 #if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
223 /* Provide kernel hint to read ahead. */
224 extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
225 __THROW;
228 /* Selective file content synch'ing. */
229 extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
230 unsigned int __flags);
232 /* Splice address range into a pipe. */
233 extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
234 size_t __count, unsigned int __flags);
236 /* Splice two files together. */
237 extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout,
238 __off64_t *__offout, size_t __len,
239 unsigned int __flags);
241 /* In-kernel implementation of tee for pipe buffers. */
242 extern ssize_t tee (int __fdin, int __fdout, size_t __len,
243 unsigned int __flags);
245 #endif
246 __END_DECLS