source: trunk/libs/newlib/src/newlib/libc/include/sys/_default_fcntl.h @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 7.0 KB
Line 
1
2#ifndef _SYS__DEFAULT_FCNTL_H_
3#ifdef __cplusplus
4extern "C" {
5#endif
6#define _SYS__DEFAULT_FCNTL_H_
7#include <_ansi.h>
8#include <sys/cdefs.h>
9#define _FOPEN          (-1)    /* from sys/file.h, kernel use only */
10#define _FREAD          0x0001  /* read enabled */
11#define _FWRITE         0x0002  /* write enabled */
12#define _FAPPEND        0x0008  /* append (writes guaranteed at the end) */
13#define _FMARK          0x0010  /* internal; mark during gc() */
14#define _FDEFER         0x0020  /* internal; defer for next gc pass */
15#define _FASYNC         0x0040  /* signal pgrp when data ready */
16#define _FSHLOCK        0x0080  /* BSD flock() shared lock present */
17#define _FEXLOCK        0x0100  /* BSD flock() exclusive lock present */
18#define _FCREAT         0x0200  /* open with file create */
19#define _FTRUNC         0x0400  /* open with truncation */
20#define _FEXCL          0x0800  /* error on open if file exists */
21#define _FNBIO          0x1000  /* non blocking I/O (sys5 style) */
22#define _FSYNC          0x2000  /* do all writes synchronously */
23#define _FNONBLOCK      0x4000  /* non blocking I/O (POSIX style) */
24#define _FNDELAY        _FNONBLOCK      /* non blocking I/O (4.2 style) */
25#define _FNOCTTY        0x8000  /* don't assign a ctty on this open */
26
27#define O_ACCMODE       (O_RDONLY|O_WRONLY|O_RDWR)
28
29/*
30 * Flag values for open(2) and fcntl(2)
31 * The kernel adds 1 to the open modes to turn it into some
32 * combination of FREAD and FWRITE.
33 */
34#define O_RDONLY        0               /* +1 == FREAD */
35#define O_WRONLY        1               /* +1 == FWRITE */
36#define O_RDWR          2               /* +1 == FREAD|FWRITE */
37#define O_APPEND        _FAPPEND
38#define O_CREAT         _FCREAT
39#define O_TRUNC         _FTRUNC
40#define O_EXCL          _FEXCL
41#define O_SYNC          _FSYNC
42/*      O_NDELAY        _FNDELAY        set in include/fcntl.h */
43/*      O_NDELAY        _FNBIO          set in include/fcntl.h */
44#define O_NONBLOCK      _FNONBLOCK
45#define O_NOCTTY        _FNOCTTY
46/* For machines which care - */
47#if defined (__CYGWIN__)
48#define _FBINARY        0x10000
49#define _FTEXT          0x20000
50#define _FNOINHERIT     0x40000
51#define _FDIRECT        0x80000
52#define _FNOFOLLOW      0x100000
53#define _FDIRECTORY     0x200000
54#define _FEXECSRCH      0x400000
55#define _FTMPFILE       0x800000
56#define _FNOATIME       0x1000000
57
58#define O_BINARY        _FBINARY
59#define O_TEXT          _FTEXT
60#define O_DSYNC         _FSYNC
61#define O_RSYNC         _FSYNC
62#define O_EXEC          _FEXECSRCH
63#define O_SEARCH        _FEXECSRCH
64
65/* POSIX-1.2008 specific flags */
66#if __POSIX_VISIBLE >= 200809
67#define O_CLOEXEC       _FNOINHERIT
68#define O_NOFOLLOW      _FNOFOLLOW
69#define O_DIRECTORY     _FDIRECTORY
70#endif
71
72/* Linux-specific flags */
73#if __GNU_VISIBLE
74#define O_DIRECT        _FDIRECT
75#define O_TMPFILE       _FTMPFILE
76#define O_NOATIME       _FNOATIME
77#endif
78#endif
79
80#if __MISC_VISIBLE
81
82/*
83 * Flags that work for fcntl(fd, F_SETFL, FXXXX)
84 */
85#define FAPPEND         _FAPPEND
86#define FSYNC           _FSYNC
87#define FASYNC          _FASYNC
88#define FNBIO           _FNBIO
89#define FNONBIO         _FNONBLOCK      /* XXX fix to be NONBLOCK everywhere */
90#define FNDELAY         _FNDELAY
91
92/*
93 * Flags that are disallowed for fcntl's (FCNTLCANT);
94 * used for opens, internal state, or locking.
95 */
96#define FREAD           _FREAD
97#define FWRITE          _FWRITE
98#define FMARK           _FMARK
99#define FDEFER          _FDEFER
100#define FSHLOCK         _FSHLOCK
101#define FEXLOCK         _FEXLOCK
102
103/*
104 * The rest of the flags, used only for opens
105 */
106#define FOPEN           _FOPEN
107#define FCREAT          _FCREAT
108#define FTRUNC          _FTRUNC
109#define FEXCL           _FEXCL
110#define FNOCTTY         _FNOCTTY
111
112#endif  /* __MISC_VISIBLE */
113
114#if __BSD_VISIBLE
115#define FNONBLOCK       _FNONBLOCK
116#endif  /* __BSD_VISIBLE */
117
118/* XXX close on exec request; must match UF_EXCLOSE in user.h */
119#define FD_CLOEXEC      1       /* posix */
120
121/* fcntl(2) requests */
122#define F_DUPFD         0       /* Duplicate fildes */
123#define F_GETFD         1       /* Get fildes flags (close on exec) */
124#define F_SETFD         2       /* Set fildes flags (close on exec) */
125#define F_GETFL         3       /* Get file flags */
126#define F_SETFL         4       /* Set file flags */
127#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112
128#define F_GETOWN        5       /* Get owner - for ASYNC */
129#define F_SETOWN        6       /* Set owner - for ASYNC */
130#endif /* __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 */
131#define F_GETLK         7       /* Get record-locking information */
132#define F_SETLK         8       /* Set or Clear a record-lock (Non-Blocking) */
133#define F_SETLKW        9       /* Set or Clear a record-lock (Blocking) */
134#if __MISC_VISIBLE
135#define F_RGETLK        10      /* Test a remote lock to see if it is blocked */
136#define F_RSETLK        11      /* Set or unlock a remote lock */
137#define F_CNVT          12      /* Convert a fhandle to an open fd */
138#define F_RSETLKW       13      /* Set or Clear remote record-lock(Blocking) */
139#endif  /* __MISC_VISIBLE */
140#if __POSIX_VISIBLE >= 200809
141#define F_DUPFD_CLOEXEC 14      /* As F_DUPFD, but set close-on-exec flag */
142#endif
143
144/* fcntl(2) flags (l_type field of flock structure) */
145#define F_RDLCK         1       /* read lock */
146#define F_WRLCK         2       /* write lock */
147#define F_UNLCK         3       /* remove lock(s) */
148#if __MISC_VISIBLE
149#define F_UNLKSYS       4       /* remove remote locks for a given system */
150#endif  /* __MISC_VISIBLE */
151
152#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809
153/* Special descriptor value to denote the cwd in calls to openat(2) etc. */
154#define AT_FDCWD -2
155
156/* Flag values for faccessat2) et al. */
157#define AT_EACCESS              1
158#define AT_SYMLINK_NOFOLLOW     2
159#define AT_SYMLINK_FOLLOW       4
160#define AT_REMOVEDIR            8
161#endif
162
163#if __BSD_VISIBLE
164/* lock operations for flock(2) */
165#define LOCK_SH         0x01            /* shared file lock */
166#define LOCK_EX         0x02            /* exclusive file lock */
167#define LOCK_NB         0x04            /* don't block when locking */
168#define LOCK_UN         0x08            /* unlock file */
169#endif
170
171/*#include <sys/stdtypes.h>*/
172
173#ifndef __CYGWIN__
174/* file segment locking set data type - information passed to system by user */
175struct flock {
176        short   l_type;         /* F_RDLCK, F_WRLCK, or F_UNLCK */
177        short   l_whence;       /* flag to choose starting offset */
178        long    l_start;        /* relative offset, in bytes */
179        long    l_len;          /* length, in bytes; 0 means lock to EOF */
180        short   l_pid;          /* returned with F_GETLK */
181        short   l_xxx;          /* reserved for future use */
182};
183#endif /* __CYGWIN__ */
184
185#if __MISC_VISIBLE
186/* extended file segment locking set data type */
187struct eflock {
188        short   l_type;         /* F_RDLCK, F_WRLCK, or F_UNLCK */
189        short   l_whence;       /* flag to choose starting offset */
190        long    l_start;        /* relative offset, in bytes */
191        long    l_len;          /* length, in bytes; 0 means lock to EOF */
192        short   l_pid;          /* returned with F_GETLK */
193        short   l_xxx;          /* reserved for future use */
194        long    l_rpid;         /* Remote process id wanting this lock */
195        long    l_rsys;         /* Remote system id wanting this lock */
196};
197#endif  /* __MISC_VISIBLE */
198
199#include <sys/types.h>
200#include <sys/stat.h>           /* sigh. for the mode bits for open/creat */
201
202extern int open (const char *, int, ...);
203#if __ATFILE_VISIBLE
204extern int openat (int, const char *, int, ...);
205#endif
206extern int creat (const char *, mode_t);
207extern int fcntl (int, int, ...);
208#if __BSD_VISIBLE
209extern int flock (int, int);
210#endif
211#if __GNU_VISIBLE
212#include <sys/time.h>
213extern int futimesat (int, const char *, const struct timeval *);
214#endif
215
216/* Provide _<systemcall> prototypes for functions provided by some versions
217   of newlib.  */
218#ifdef _COMPILING_NEWLIB
219extern int _open (const char *, int, ...);
220extern int _fcntl (int, int, ...);
221#ifdef __LARGE64_FILES
222extern int _open64 (const char *, int, ...);
223#endif
224#endif
225
226#ifdef __cplusplus
227}
228#endif
229#endif  /* !_SYS__DEFAULT_FCNTL_H_ */
Note: See TracBrowser for help on using the repository browser.