2005-12-27 Roland McGrath <roland@redhat.com>
[glibc-ports.git] / sysdeps / unix / sysv / aix / bits / fcntl.h
blobc65b8beeb4bfcace1085afdfc57e9d83ec4abc51
1 /* O_*, F_*, FD_* bit values for Linux.
2 Copyright (C) 1995-1999, 2000, 2004 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #ifndef _FCNTL_H
21 # error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
22 #endif
25 #include <sys/types.h>
27 /* open/fcntl. */
28 #define O_ACCMODE 0003
29 #define O_RDONLY 00
30 #define O_WRONLY 01
31 #define O_RDWR 02
32 #define O_NONBLOCK 04
33 #define O_NDELAY O_NONBLOCK
34 #define O_APPEND 010
35 #define O_SYNC 020
36 #define O_FSYNC O_SYNC
37 #define O_CREAT 0400 /* not fcntl */
38 #define O_TRUNC 01000 /* not fcntl */
39 #define O_EXCL 02000 /* not fcntl */
40 #define O_NOCTTY 04000 /* not fcntl */
41 #define O_ASYNC 0400000
43 #ifdef __USE_LARGEFILE64
44 # define O_LARGEFILE 0400000000
45 #endif
47 /* For now Linux has synchronisity options for data and read operations.
48 We define the symbols here but let them do the same as O_SYNC since
49 this is a superset. */
50 #if defined __USE_POSIX199309 || defined __USE_UNIX98
51 # define O_DSYNC 020000000 /* Synchronize data. */
52 # define O_RSYNC 010000000 /* Synchronize read operations. */
53 #endif
55 /* Values for the second argument to `fcntl'. */
56 #define F_DUPFD 0 /* Duplicate file descriptor. */
57 #define F_GETFD 1 /* Get file descriptor flags. */
58 #define F_SETFD 2 /* Set file descriptor flags. */
59 #define F_GETFL 3 /* Get file status flags. */
60 #define F_SETFL 4 /* Set file status flags. */
61 #ifndef __USE_FILE_OFFSET64
62 # define F_GETLK 5 /* Get record locking info. */
63 # define F_SETLK 6 /* Set record locking info (non-blocking). */
64 # define F_SETLKW 7 /* Set record locking info (blocking). */
65 #else
66 # define F_GETLK 11 /* Get record locking info. */
67 # define F_SETLK 12 /* Set record locking info (non-blocking). */
68 # define F_SETLKW 13 /* Set record locking info (blocking). */
69 #endif
71 #ifdef __USE_LARGEFILE64
72 # define F_GETLK64 11 /* Get record locking info. */
73 # define F_SETLK64 12 /* Set record locking info (non-blocking). */
74 # define F_SETLKW64 13 /* Set record locking info (blocking). */
75 #endif
77 #if defined __USE_BSD || defined __USE_UNIX98
78 # define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */
79 # define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */
80 #endif
82 /* For F_[GET|SET]FL. */
83 #define FD_CLOEXEC 1 /* actually anything with low bit set goes */
85 /* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
86 #define F_RDLCK 1 /* Read lock. */
87 #define F_WRLCK 2 /* Write lock. */
88 #define F_UNLCK 3 /* Remove lock. */
90 #ifdef __USE_BSD
91 /* Operations for bsd flock(), also used by the kernel implementation */
92 # define LOCK_SH 1 /* shared lock */
93 # define LOCK_EX 2 /* exclusive lock */
94 # define LOCK_NB 4 /* or'd with one of the above to prevent
95 blocking */
96 # define LOCK_UN 8 /* remove lock */
97 #endif
99 struct flock
101 short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
102 short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
103 #ifndef __USE_FILE_OFFSET64
104 __off_t l_start; /* Offset where the lock begins. */
105 __off_t l_len; /* Size of the locked area; zero means until EOF. */
106 #endif
107 unsigned int l_sysid;
108 __pid_t l_pid; /* Process holding the lock. */
109 int l_vfs;
110 #ifdef __USE_FILE_OFFSET64
111 __off64_t l_start; /* Offset where the lock begins. */
112 __off64_t l_len; /* Size of the locked area; zero means until EOF. */
113 #endif
116 #ifdef __USE_LARGEFILE64
117 struct flock64
119 short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
120 short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
121 unsigned int l_sysid;
122 __pid_t l_pid; /* Process holding the lock. */
123 int l_vfs;
124 __off64_t l_start; /* Offset where the lock begins. */
125 __off64_t l_len; /* Size of the locked area; zero means until EOF. */
127 #endif
129 /* Define some more compatibility macros to be backward compatible with
130 BSD systems which did not managed to hide these kernel macros. */
131 #ifdef __USE_BSD
132 # define FAPPEND O_APPEND
133 # define FFSYNC O_FSYNC
134 # define FASYNC O_ASYNC
135 # define FNONBLOCK O_NONBLOCK
136 # define FNDELAY O_NDELAY
137 #endif /* Use BSD. */