Search
lxdream.org :: lxdream/test/include/sys/fcntl.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename test/include/sys/fcntl.h
changeset 185:6755a04c447f
author nkeynes
date Tue Jul 11 01:35:27 2006 +0000 (17 years ago)
permissions -rw-r--r--
last change First commit of system test framework. 3 initial test cases (incomplete):
testide, testmath, and testta
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test/include/sys/fcntl.h Tue Jul 11 01:35:27 2006 +0000
1.3 @@ -0,0 +1,178 @@
1.4 +
1.5 +#ifndef _FCNTL_
1.6 +#ifdef __cplusplus
1.7 +extern "C" {
1.8 +#endif
1.9 +#define _FCNTL_
1.10 +#include <_ansi.h>
1.11 +#define _FOPEN (-1) /* from sys/file.h, kernel use only */
1.12 +#define _FREAD 0x0001 /* read enabled */
1.13 +#define _FWRITE 0x0002 /* write enabled */
1.14 +#define _FNDELAY 0x0004 /* non blocking I/O (4.2 style) */
1.15 +#define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */
1.16 +#define _FMARK 0x0010 /* internal; mark during gc() */
1.17 +#define _FDEFER 0x0020 /* internal; defer for next gc pass */
1.18 +#define _FASYNC 0x0040 /* signal pgrp when data ready */
1.19 +#define _FSHLOCK 0x0080 /* BSD flock() shared lock present */
1.20 +#define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */
1.21 +#define _FCREAT 0x0200 /* open with file create */
1.22 +#define _FTRUNC 0x0400 /* open with truncation */
1.23 +#define _FEXCL 0x0800 /* error on open if file exists */
1.24 +#define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */
1.25 +#define _FSYNC 0x2000 /* do all writes synchronously */
1.26 +#define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */
1.27 +#define _FNOCTTY 0x8000 /* don't assign a ctty on this open */
1.28 +
1.29 +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
1.30 +
1.31 +/*
1.32 + * Flag values for open(2) and fcntl(2)
1.33 + * The kernel adds 1 to the open modes to turn it into some
1.34 + * combination of FREAD and FWRITE.
1.35 + */
1.36 +#define O_RDONLY 0 /* +1 == FREAD */
1.37 +#define O_WRONLY 1 /* +1 == FWRITE */
1.38 +#define O_RDWR 2 /* +1 == FREAD|FWRITE */
1.39 +#define O_APPEND _FAPPEND
1.40 +#define O_CREAT _FCREAT
1.41 +#define O_TRUNC _FTRUNC
1.42 +#define O_EXCL _FEXCL
1.43 +/* O_SYNC _FSYNC not posix, defined below */
1.44 +/* O_NDELAY _FNDELAY set in include/fcntl.h */
1.45 +/* O_NDELAY _FNBIO set in 5include/fcntl.h */
1.46 +#define O_NONBLOCK _FNONBLOCK
1.47 +#define O_NOCTTY _FNOCTTY
1.48 +/* For machines which care - */
1.49 +#if defined (_WIN32) || defined (__CYGWIN__)
1.50 +#define _FBINARY 0x10000
1.51 +#define _FTEXT 0x20000
1.52 +#define _FNOINHERIT 0x40000
1.53 +
1.54 +#define O_BINARY _FBINARY
1.55 +#define O_TEXT _FTEXT
1.56 +#define O_NOINHERIT _FNOINHERIT
1.57 +
1.58 +/* The windows header files define versions with a leading underscore. */
1.59 +#define _O_RDONLY O_RDONLY
1.60 +#define _O_WRONLY O_WRONLY
1.61 +#define _O_RDWR O_RDWR
1.62 +#define _O_APPEND O_APPEND
1.63 +#define _O_CREAT O_CREAT
1.64 +#define _O_TRUNC O_TRUNC
1.65 +#define _O_EXCL O_EXCL
1.66 +#define _O_TEXT O_TEXT
1.67 +#define _O_BINARY O_BINARY
1.68 +#define _O_RAW O_BINARY
1.69 +#define _O_NOINHERIT O_NOINHERIT
1.70 +#endif
1.71 +
1.72 +#ifndef _POSIX_SOURCE
1.73 +
1.74 +#define O_SYNC _FSYNC
1.75 +
1.76 +/*
1.77 + * Flags that work for fcntl(fd, F_SETFL, FXXXX)
1.78 + */
1.79 +#define FAPPEND _FAPPEND
1.80 +#define FSYNC _FSYNC
1.81 +#define FASYNC _FASYNC
1.82 +#define FNBIO _FNBIO
1.83 +#define FNONBIO _FNONBLOCK /* XXX fix to be NONBLOCK everywhere */
1.84 +#define FNDELAY _FNDELAY
1.85 +
1.86 +/*
1.87 + * Flags that are disallowed for fcntl's (FCNTLCANT);
1.88 + * used for opens, internal state, or locking.
1.89 + */
1.90 +#define FREAD _FREAD
1.91 +#define FWRITE _FWRITE
1.92 +#define FMARK _FMARK
1.93 +#define FDEFER _FDEFER
1.94 +#define FSHLOCK _FSHLOCK
1.95 +#define FEXLOCK _FEXLOCK
1.96 +
1.97 +/*
1.98 + * The rest of the flags, used only for opens
1.99 + */
1.100 +#define FOPEN _FOPEN
1.101 +#define FCREAT _FCREAT
1.102 +#define FTRUNC _FTRUNC
1.103 +#define FEXCL _FEXCL
1.104 +#define FNOCTTY _FNOCTTY
1.105 +
1.106 +#endif /* !_POSIX_SOURCE */
1.107 +
1.108 +/* XXX close on exec request; must match UF_EXCLOSE in user.h */
1.109 +#define FD_CLOEXEC 1 /* posix */
1.110 +
1.111 +/* fcntl(2) requests */
1.112 +#define F_DUPFD 0 /* Duplicate fildes */
1.113 +#define F_GETFD 1 /* Get fildes flags (close on exec) */
1.114 +#define F_SETFD 2 /* Set fildes flags (close on exec) */
1.115 +#define F_GETFL 3 /* Get file flags */
1.116 +#define F_SETFL 4 /* Set file flags */
1.117 +#ifndef _POSIX_SOURCE
1.118 +#define F_GETOWN 5 /* Get owner - for ASYNC */
1.119 +#define F_SETOWN 6 /* Set owner - for ASYNC */
1.120 +#endif /* !_POSIX_SOURCE */
1.121 +#define F_GETLK 7 /* Get record-locking information */
1.122 +#define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */
1.123 +#define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */
1.124 +#ifndef _POSIX_SOURCE
1.125 +#define F_RGETLK 10 /* Test a remote lock to see if it is blocked */
1.126 +#define F_RSETLK 11 /* Set or unlock a remote lock */
1.127 +#define F_CNVT 12 /* Convert a fhandle to an open fd */
1.128 +#define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */
1.129 +#endif /* !_POSIX_SOURCE */
1.130 +
1.131 +/* fcntl(2) flags (l_type field of flock structure) */
1.132 +#define F_RDLCK 1 /* read lock */
1.133 +#define F_WRLCK 2 /* write lock */
1.134 +#define F_UNLCK 3 /* remove lock(s) */
1.135 +#ifndef _POSIX_SOURCE
1.136 +#define F_UNLKSYS 4 /* remove remote locks for a given system */
1.137 +#endif /* !_POSIX_SOURCE */
1.138 +
1.139 +/*#include <sys/stdtypes.h>*/
1.140 +
1.141 +/* file segment locking set data type - information passed to system by user */
1.142 +struct flock {
1.143 + short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
1.144 + short l_whence; /* flag to choose starting offset */
1.145 + long l_start; /* relative offset, in bytes */
1.146 + long l_len; /* length, in bytes; 0 means lock to EOF */
1.147 + short l_pid; /* returned with F_GETLK */
1.148 + short l_xxx; /* reserved for future use */
1.149 +};
1.150 +
1.151 +#ifndef _POSIX_SOURCE
1.152 +/* extended file segment locking set data type */
1.153 +struct eflock {
1.154 + short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
1.155 + short l_whence; /* flag to choose starting offset */
1.156 + long l_start; /* relative offset, in bytes */
1.157 + long l_len; /* length, in bytes; 0 means lock to EOF */
1.158 + short l_pid; /* returned with F_GETLK */
1.159 + short l_xxx; /* reserved for future use */
1.160 + long l_rpid; /* Remote process id wanting this lock */
1.161 + long l_rsys; /* Remote system id wanting this lock */
1.162 +};
1.163 +#endif /* !_POSIX_SOURCE */
1.164 +
1.165 +
1.166 +#include <sys/types.h>
1.167 +#include <sys/stat.h> /* sigh. for the mode bits for open/creat */
1.168 +
1.169 +extern int open _PARAMS ((const char *, int, ...));
1.170 +extern int creat _PARAMS ((const char *, mode_t));
1.171 +extern int fcntl _PARAMS ((int, int, ...));
1.172 +
1.173 +/* Provide _<systemcall> prototypes for functions provided by some versions
1.174 + of newlib. */
1.175 +extern int _open _PARAMS ((const char *, int, ...));
1.176 +extern int _fcntl _PARAMS ((int, int, ...));
1.177 +
1.178 +#ifdef __cplusplus
1.179 +}
1.180 +#endif
1.181 +#endif /* !_FCNTL_ */
.