1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
27 * generate POSIX fcntl.h
30 #include <sys/types.h>
32 #include "FEATURE/lib"
34 #define getdtablesize ______getdtablesize
35 #define getpagesize ______getpagesize
36 #define ioctl ______ioctl
60 #include "FEATURE/tty"
74 printf("#pragma prototyped\n");
76 printf("#if _typ_off64_t\n");
77 printf("#undef off_t\n");
78 printf("#ifdef __STDC__\n");
79 printf("#define off_t off_t\n");
83 printf("#include <ast_fs.h>\n");
85 printf("#if _typ_off64_t\n");
86 printf("#undef off_t\n");
87 printf("#ifdef __STDC__\n");
88 printf("#define off_t off_t\n");
92 printf("#include <fcntl.h>\n");
94 printf("#include <mman.h>\n");
97 printf("#include <sys/mman.h>\n");
102 printf("#define FD_CLOEXEC 1\n");
109 if (F_DUPFD
> f_local
) f_local
= F_DUPFD
;
114 if (F_GETFD
> f_local
) f_local
= F_GETFD
;
119 if (F_GETFL
> f_local
) f_local
= F_GETFL
;
124 if (F_GETLK
> f_local
) f_local
= F_GETLK
;
130 if (F_RDLCK
> f_lck
) f_lck
= F_RDLCK
;
135 if (F_SETFD
> f_local
) f_local
= F_SETFD
;
140 if (F_SETFL
> f_local
) f_local
= F_SETFL
;
145 if (F_SETLK
> f_local
) f_local
= F_SETLK
;
150 if (F_SETLKW
> f_local
) f_local
= F_SETLKW
;
156 if (F_UNLCK
> f_lck
) f_lck
= F_UNLCK
;
162 if (F_WRLCK
> f_lck
) f_lck
= F_WRLCK
;
166 printf("#define fcntl _ast_fcntl\n");
168 printf("#define _lib_fcntl 1\n");
170 printf("#define _ast_F_LOCAL %d\n", f_local
+ 1);
172 printf("#define F_DUPFD %d\n", ++f_local
);
175 printf("#define F_GETFD %d\n", ++f_local
);
178 printf("#define F_GETFL %d\n", ++f_local
);
181 printf("#define F_GETLK %d\n", ++f_local
);
184 printf("#define F_SETFD %d\n", ++f_local
);
187 printf("#define F_SETFL %d\n", ++f_local
);
190 printf("#define F_SETLK %d\n", ++f_local
);
193 printf("#define F_SETLKW %d\n", ++f_local
);
198 printf("#define F_RDLCK %d\n", f_lck
++);
201 printf("#define F_WRLCK %d\n", f_lck
++);
204 printf("#define F_UNLCK %d\n", f_lck
++);
210 printf("struct flock\n");
212 printf(" short l_type;\n");
213 printf(" short l_whence;\n");
214 printf(" off_t l_start;\n");
215 printf(" off_t l_len;\n");
216 printf(" short l_pid;\n");
226 if (O_APPEND
> o_local
) o_local
= O_APPEND
;
231 if (O_CREAT
> o_local
) o_local
= O_CREAT
;
236 if (O_EXCL
> o_local
) o_local
= O_EXCL
;
243 if (O_NOCTTY
> o_local
) o_local
= O_NOCTTY
;
250 if (O_NONBLOCK
> o_local
) o_local
= O_NONBLOCK
;
261 if (O_TRUNC
> o_local
) o_local
= O_TRUNC
;
268 printf("#define open _ast_open\n");
269 printf("#define _ast_O_LOCAL 0%o\n", o_local
<<1);
271 printf("#define O_RDONLY 0\n");
274 printf("#define O_WRONLY 1\n");
277 printf("#define O_RDWR 2\n");
280 printf("#define O_APPEND 0%o\n", o_local
<<= 1);
283 printf("#define O_CREAT 0%o\n", o_local
<<= 1);
286 printf("#define O_EXCL 0%o\n", o_local
<<= 1);
290 printf("#define O_NOCTTY 0%o\n", o_local
<<= 1);
295 printf("#define O_NONBLOCK 0%o\n", o_local
<<= 1);
299 printf("#define O_TRUNC 0%o\n", o_local
<<= 1);
303 printf("#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)\n");
307 printf("#define O_NOCTTY 0\n");
312 printf("#define O_NONBLOCK O_NDELAY\n");
316 printf("#define O_BINARY 0\n");
319 printf("#define O_TEMPORARY 0\n");
322 printf("#define O_TEXT 0\n");
327 printf("extern int fcntl(int, int, ...);\n");
330 printf("extern int open(const char*, int, ...);\n");
334 printf("#include <ast_fs.h>\n");
335 printf("#if _typ_off64_t\n");
336 printf("#undef off_t\n");
337 printf("#define off_t off64_t\n");
339 printf("#if _lib_fstat64\n");
340 printf("#define fstat fstat64\n");
342 printf("#if _lib_lstat64\n");
343 printf("#define lstat lstat64\n");
345 printf("#if _lib_stat64\n");
346 printf("#define stat stat64\n");
348 printf("#if _lib_creat64\n");
349 printf("#define creat creat64\n");
351 printf("#if _lib_mmap64\n");
352 printf("#define mmap mmap64\n");
354 printf("#if _lib_open64\n");
355 printf("#undef open\n");
356 printf("#define open open64\n");