00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _ABLE_CLIB_FCNTL_H
00031 #define _ABLE_CLIB_FCNTL_H 1
00032
00033 #include <stdarg.h>
00034
00035 #define __FILEFLAG(x) ((x) << 16)
00036
00037 #define O_CREAT __FILEFLAG(1)
00038 #define O_EXCL __FILEFLAG(2)
00039 #define O_NOCTY __FILEFLAG(4)
00040 #define O_TRUNC __FILEFLAG(8)
00041 #define O_APPEND __FILEFLAG(16)
00042 #define O_NONBLOCK __FILEFLAG(32)
00043 #define O_NDELAY O_NONBLOCK
00044 #define O_SYNC __FILEFLAG(64)
00045 #define O_DIRECTORY __FILEFLAG(128)
00046
00047 #define O_LOCAL __FILEFLAG(1<<14)
00048 #define O_GLOBAL __FILEFLAG(1<<15)
00050 #define O_RDONLY (1 << 14)
00051 #define O_WRONLY (2 << 14)
00052 #define O_RDWR (3 << 14)
00053
00054 #define O_STDSHIFT (24)
00055 #define O_STDMASK (15 << O_STDSHIFT )
00056 #define O_STDIN (1 << O_STDSHIFT)
00057 #define O_STDOUT (2 << O_STDSHIFT)
00058 #define O_STDERR (3 << O_STDSHIFT)
00059
00060 extern int open(const char *file, int oflag, ...);
00061 extern int creat(const char *pathname, mode_t mode);
00062
00063 extern int vfcntl(int fd, va_list va);
00064
00073 extern int fcntl(int fd, ...);
00074
00075 #define F_GETFL (1)
00076 #define F_SETFL (2)
00077 #define F_SETOPT (3)
00078 #define F_SENDMSG (4)
00079 #define F_SUBMODE (5)
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 #if !defined(FIONREAD) || !defined(FIONBIO)
00090 #define IOCPARM_MASK 0x7fU
00091 #define IOC_VOID 0x20000000UL
00092 #define IOC_OUT 0x40000000UL
00093 #define IOC_IN 0x80000000UL
00094 #define IOC_INOUT (IOC_IN|IOC_OUT)
00095
00096
00097
00098 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
00099
00100 #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
00101
00102 #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
00103 #endif
00104
00105 #ifndef FIONREAD
00106 #define FIONREAD _IOR('f', 127, unsigned long)
00107 #endif
00108 #ifndef FIONBIO
00109 #define FIONBIO _IOW('f', 126, unsigned long)
00110 #endif
00111
00112 #endif