comparison druntime/import/core/sys/posix/fcntl.d @ 1458:e0b2d67cfe7c

Added druntime (this should be removed once it works).
author Robert Clipsham <robert@octarineparrot.com>
date Tue, 02 Jun 2009 17:43:06 +0100
parents
children
comparison
equal deleted inserted replaced
1456:7b218ec1044f 1458:e0b2d67cfe7c
1 /**
2 * D header file for POSIX.
3 *
4 * Copyright: Copyright Sean Kelly 2005 - 2009.
5 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
6 * Authors: Sean Kelly
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8 *
9 * Copyright Sean Kelly 2005 - 2009.
10 * Distributed under the Boost Software License, Version 1.0.
11 * (See accompanying file LICENSE_1_0.txt or copy at
12 * http://www.boost.org/LICENSE_1_0.txt)
13 */
14 module core.sys.posix.fcntl;
15
16 private import core.sys.posix.config;
17 private import core.stdc.stdint;
18 public import core.stdc.stddef; // for size_t
19 public import core.sys.posix.sys.types; // for off_t, mode_t
20 public import core.sys.posix.sys.stat; // for S_IFMT, etc.
21
22 extern (C):
23
24 //
25 // Required
26 //
27 /*
28 F_DUPFD
29 F_GETFD
30 F_SETFD
31 F_GETFL
32 F_SETFL
33 F_GETLK
34 F_SETLK
35 F_SETLKW
36 F_GETOWN
37 F_SETOWN
38
39 FD_CLOEXEC
40
41 F_RDLCK
42 F_UNLCK
43 F_WRLCK
44
45 O_CREAT
46 O_EXCL
47 O_NOCTTY
48 O_TRUNC
49
50 O_APPEND
51 O_DSYNC
52 O_NONBLOCK
53 O_RSYNC
54 O_SYNC
55
56 O_ACCMODE
57 O_RDONLY
58 O_RDWR
59 O_WRONLY
60
61 struct flock
62 {
63 short l_type;
64 short l_whence;
65 off_t l_start;
66 off_t l_len;
67 pid_t l_pid;
68 }
69
70 int creat(in char*, mode_t);
71 int fcntl(int, int, ...);
72 int open(in char*, int, ...);
73 */
74 version( linux )
75 {
76 enum F_DUPFD = 0;
77 enum F_GETFD = 1;
78 enum F_SETFD = 2;
79 enum F_GETFL = 3;
80 enum F_SETFL = 4;
81 static if( __USE_FILE_OFFSET64 )
82 {
83 enum F_GETLK = 12;
84 enum F_SETLK = 13;
85 enum F_SETLKW = 14;
86 }
87 else
88 {
89 enum F_GETLK = 5;
90 enum F_SETLK = 6;
91 enum F_SETLKW = 7;
92 }
93 enum F_GETOWN = 9;
94 enum F_SETOWN = 8;
95
96 enum FD_CLOEXEC = 1;
97
98 enum F_RDLCK = 0;
99 enum F_UNLCK = 2;
100 enum F_WRLCK = 1;
101
102 enum O_CREAT = 0100;
103 enum O_EXCL = 0200;
104 enum O_NOCTTY = 0400;
105 enum O_TRUNC = 01000;
106
107 enum O_APPEND = 02000;
108 enum O_NONBLOCK = 04000;
109 enum O_SYNC = 010000;
110 enum O_DSYNC = O_SYNC;
111 enum O_RSYNC = O_SYNC;
112
113 enum O_ACCMODE = 0003;
114 enum O_RDONLY = 00;
115 enum O_WRONLY = 01;
116 enum O_RDWR = 02;
117
118 struct flock
119 {
120 short l_type;
121 short l_whence;
122 off_t l_start;
123 off_t l_len;
124 pid_t l_pid;
125 }
126
127 static if( __USE_LARGEFILE64 )
128 {
129 int creat64(in char*, mode_t);
130 alias creat64 creat;
131
132 int open64(in char*, int, ...);
133 alias open64 open;
134 }
135 else
136 {
137 int creat(in char*, mode_t);
138 int open(in char*, int, ...);
139 }
140 }
141 else version( OSX )
142 {
143 enum F_DUPFD = 0;
144 enum F_GETFD = 1;
145 enum F_SETFD = 2;
146 enum F_GETFL = 3;
147 enum F_SETFL = 4;
148 enum F_GETOWN = 5;
149 enum F_SETOWN = 6;
150 enum F_GETLK = 7;
151 enum F_SETLK = 8;
152 enum F_SETLKW = 9;
153
154 enum FD_CLOEXEC = 1;
155
156 enum F_RDLCK = 1;
157 enum F_UNLCK = 2;
158 enum F_WRLCK = 3;
159
160 enum O_CREAT = 0x0200;
161 enum O_EXCL = 0x0800;
162 enum O_NOCTTY = 0;
163 enum O_TRUNC = 0x0400;
164
165 enum O_RDONLY = 0x0000;
166 enum O_WRONLY = 0x0001;
167 enum O_RDWR = 0x0002;
168 enum O_ACCMODE = 0x0003;
169
170 enum O_NONBLOCK = 0x0004;
171 enum O_APPEND = 0x0008;
172 enum O_SYNC = 0x0080;
173 //enum O_DSYNC
174 //enum O_RSYNC
175
176 struct flock
177 {
178 off_t l_start;
179 off_t l_len;
180 pid_t l_pid;
181 short l_type;
182 short l_whence;
183 }
184
185 int creat(in char*, mode_t);
186 int open(in char*, int, ...);
187 }
188 else version( freebsd )
189 {
190 enum F_DUPFD = 0;
191 enum F_GETFD = 1;
192 enum F_SETFD = 2;
193 enum F_GETFL = 3;
194 enum F_SETFL = 4;
195 enum F_GETOWN = 5;
196 enum F_SETOWN = 6;
197 enum F_GETLK = 7;
198 enum F_SETLK = 8;
199 enum F_SETLKW = 9;
200
201 enum FD_CLOEXEC = 1;
202
203 enum F_RDLCK = 1;
204 enum F_UNLCK = 2;
205 enum F_WRLCK = 3;
206
207 enum O_CREAT = 0x0200;
208 enum O_EXCL = 0x0800;
209 enum O_NOCTTY = 0;
210 enum O_TRUNC = 0x0400;
211
212 enum O_RDONLY = 0x0000;
213 enum O_WRONLY = 0x0001;
214 enum O_RDWR = 0x0002;
215 enum O_ACCMODE = 0x0003;
216
217 enum O_NONBLOCK = 0x0004;
218 enum O_APPEND = 0x0008;
219 enum O_SYNC = 0x0080;
220 //enum O_DSYNC
221 //enum O_RSYNC
222
223 struct flock
224 {
225 off_t l_start;
226 off_t l_len;
227 pid_t l_pid;
228 short l_type;
229 short l_whence;
230 }
231
232 int creat(in char*, mode_t);
233 int open(in char*, int, ...);
234 }
235
236 //int creat(in char*, mode_t);
237 int fcntl(int, int, ...);
238 //int open(in char*, int, ...);
239
240 //
241 // Advisory Information (ADV)
242 //
243 /*
244 POSIX_FADV_NORMAL
245 POSIX_FADV_SEQUENTIAL
246 POSIX_FADV_RANDOM
247 POSIX_FADV_WILLNEED
248 POSIX_FADV_DONTNEED
249 POSIX_FADV_NOREUSE
250
251 int posix_fadvise(int, off_t, off_t, int);
252 int posix_fallocate(int, off_t, off_t);
253 */