unistd.mh

来自「开放源码的编译器open watcom 1.6.0版的源代码」· MH 代码 · 共 294 行

MH
294
字号
/*
 *  unistd.h
 *
:include crwatqnx.sp
 */
#ifndef _UNISTD_H_INCLUDED
#define _UNISTD_H_INCLUDED
:include readonly.sp
:include cpluspro.sp

#ifndef _COMDEF_H_INCLUDED
 #include <_comdef.h>
#endif
:segment DOS
#ifndef _IO_H_INCLUDED
 #include <io.h>
#endif

#if defined(__OS2__) && defined(__386__) && defined(__TCPIP_HEADERS)
 #include <tcpustd.h>   /* unistd.h conflicts with OS/2 TCP/IP headers */
#endif

:endsegment
:include wchar_t.sp

:segment !DOS
#ifndef __TYPES_H_INCLUDED
 #include <sys/types.h>
#endif

:include null.sp

/* Symbolic constants for the access() function */

#define R_OK    4       /*  Test for read permission    */
#define W_OK    2       /*  Test for write permission   */
#define X_OK    1       /*  Test for execute permission */
#define F_OK    0       /*  Test for existence of file  */

/* Symbolic constants for the lseek() function */

#ifndef _SEEKPOS_DEFINED_       /* If not already defined, define them  */
#define SEEK_SET    0           /* Seek relative to the start of file   */
#define SEEK_CUR    1           /* Seek relative to current position    */
#define SEEK_END    2           /* Seek relative to the end of the file */
#define _SEEKPOS_DEFINED_
#endif

/* Symbolic constants for stream I/O */

#define STDIN_FILENO    0
#define STDOUT_FILENO   1
#define STDERR_FILENO   2

:segment QNX | LINUX
/* Compile-time Symbolic Constants for Portability Specifications */

#undef  _POSIX_JOB_CONTROL              /* no job control                   */
#define _POSIX_SAVED_IDS    1           /* no saved-set user-ID & group-ID  */
#define _POSIX_VERSION      198808L     /* YYYYmm of POSIX std approval     */
#define _POSIX_PROCESS_SCHEDULING   1
#define _POSIX_TIMERS   1

/* Symbolic constants for sysconf */
/* caution: the module sysconf.c bound checks _SC_ARG_MAX ... _SC_PAGESIZE */
#define _SC_ARG_MAX         1
#define _SC_CHILD_MAX       2
#define _SC_CLK_TCK         3
#define _SC_NGROUPS_MAX     4
#define _SC_OPEN_MAX        5
#define _SC_JOB_CONTROL     6
#define _SC_SAVED_IDS       7
#define _SC_VERSION         8
#define _SC_STREAM_MAX      9
#define _SC_TZNAME_MAX      10
#define _SC_PAGESIZE        11
/* Execution-time Symbolic Constants for Portability Specifications */

#define _POSIX_CHOWN_RESTRICTED 0       /* restricted use of chown() */
#define _POSIX_NO_TRUNC         0       /* pathname components > NAME_MAX */
#define _POSIX_VDISABLE         0x00    /* terminal special chars can be disabled */

/* Symbolic constants for pathconf, fpathconf */

#define _PC_LINK_MAX            1
#define _PC_MAX_CANON           2
#define _PC_MAX_INPUT           3
#define _PC_NAME_MAX            4
#define _PC_PATH_MAX            5
#define _PC_PIPE_BUF            6
#define _PC_CHOWN_RESTRICTED    7
#define _PC_NO_TRUNC            8
#define _PC_VDISABLE            9
#define _PC_DOS_SHARE           10  /* test for dos share support   */
#define _PC_DOS_LOCKS           11  /* test for dos locking support */

:include posix.sp

_WCRTDATA extern int    optind;     /*  index of current option being scanned */
_WCRTDATA extern char   *optarg;    /*  points to optional argument */
_WCRTDATA extern int    opterr;     /*  print|don't print error message */
_WCRTDATA extern int    optopt;     /*  offending letter when error detected */

/* Symbolic constants for confstr */

#define _CS_PATH            1

#endif
:endsegment

/*
 *  POSIX 1003.1 Prototypes
 */

:segment QNX
#if defined(_POSIX_SOURCE) || defined(_QNX_SOURCE) || !defined(NO_EXT_KEYS)
_WCRTLINK extern void   _exit( int __status );
#endif
:endsegment
:segment LINUX
#if defined(_POSIX_SOURCE) || defined(_LINUX_SOURCE) || !defined(NO_EXT_KEYS)
_WCRTLINK extern void   _exit( int __status );
#endif
:endsegment

_WCRTLINK extern int    access( const char *__path, int __mode );
:segment QNX
#if defined(__386__)
:endsegment
:segment QNX | LINUX
_WCRTLINK extern int    brk(void *endds);
_WCRTLINK extern void   _WCNEAR *sbrk(int incr);
:endsegment
:segment QNX
#endif
:endsegment
_WCRTLINK extern int    chdir( const char *__path );
_WCRTLINK extern int    close( int __fildes );
_WCRTLINK extern int    dup( int __fildes );
_WCRTLINK extern char   *getcwd( char *__buf, size_t __size );
_WCRTLINK extern char   *_getcwd( char *__buf, size_t __size );
_WCRTLINK extern pid_t  getpid( void );
_WCRTLINK extern int    isatty( int __fildes );
_WCRTLINK extern off_t  lseek( int __fildes, off_t __offset, int __whence );
_WCRTLINK extern ssize_t read( int __fildes, void *__buffer, size_t __len );
_WCRTLINK extern int    rmdir( const char *__path );
:segment QNX | LINUX
#if !(defined(SYSV) || defined(BSD) || defined(XENIX) || defined(_UNIX_H_INCLUDED))
:endsegment
_WCRTLINK extern int    setmode( int __handle, int __mode );
:segment QNX | LINUX
#endif
:endsegment
_WCRTLINK extern unsigned int sleep( unsigned int __seconds );
_WCRTLINK extern int    unlink( const char *__path );
_WCRTLINK extern ssize_t write( int __fildes, const void *__buf, size_t __len );
:segment QNX | LINUX
_WCRTLINK extern unsigned alarm( unsigned int __seconds );
_WCRTLINK extern int    chown( const char *__path, uid_t __owner, gid_t __group );
_WCRTLINK extern int    chroot(const char *__path);
_WCRTLINK extern int    dup2( int __fildes, int __fildes2 );
_WCRTLINK extern int    fchown( int __fildes, uid_t __owner, gid_t __group );
_WCRTLINK extern int    fdatasync( int __fildes );
_WCRTLINK extern int    fsync( int __fildes );
_WCRTLINK extern pid_t  fork( void );
_WCRTLINK extern long   fpathconf( int __fildes, int __name );
_WCRTLINK extern gid_t  getegid( void );
_WCRTLINK extern uid_t  geteuid( void );
_WCRTLINK extern gid_t  getgid( void );
_WCRTLINK extern int    getgroups( int __gidsetsize, gid_t __grouplist[] );
_WCRTLINK extern char   *getlogin( void );
_WCRTLINK extern pid_t  getpgrp( void );
_WCRTLINK extern pid_t  getppid( void );
_WCRTLINK extern pid_t  getsid(pid_t __pid);
_WCRTLINK extern uid_t  getuid( void );
_WCRTLINK extern int    link( const char *__path1, const char *__path2 );
_WCRTLINK extern long   pathconf( const char *__path, int __name );
_WCRTLINK extern int    pause( void );
_WCRTLINK extern int    pipe( int __fildes[2] );
_WCRTLINK extern int    readlink( const char *__path, char *__buf, size_t __bufsiz );
_WCRTLINK extern int    setegid( gid_t __newegroup );
_WCRTLINK extern int    seteuid( uid_t __newuserid );
_WCRTLINK extern int    setgid( gid_t __newgroup );
_WCRTLINK extern int    setpgid( pid_t __pid, pid_t __pgroupid );
_WCRTLINK extern int    setregid(gid_t real, uid_t effective);
_WCRTLINK extern int    setreuid(uid_t real, uid_t effective);
_WCRTLINK extern pid_t  setsid( void );
_WCRTLINK extern int    setuid( uid_t __newuserid );
_WCRTLINK extern int    symlink( const char *__pname, const char *__slink );
_WCRTLINK extern void   sync( void );
_WCRTLINK extern long   sysconf( int __name );
_WCRTLINK extern pid_t  tcgetpgrp( int __fildes );
_WCRTLINK extern int    tcsetpgrp( int __fildes, pid_t __pgrp_id );
_WCRTLINK extern char   *ttyname( int __fildes );
:endsegment
:segment QNX
_WCRTLINK extern int    mkdir( const char *__path, mode_t __mode );
_WCRTLINK extern int    mknod( const char *__path, mode_t __mode, int __dev );
_WCRTLINK extern int    mount( const char *__special, const char *__dir, int __rwflag );
_WCRTLINK extern int    tcsetct( int __fildes, pid_t pid );
_WCRTLINK extern int    umount( const char *__special );
:endsegment
:segment LINUX
_WCRTLINK extern int    truncate( const char *__path, off_t __length );
_WCRTLINK extern int    ftruncate( int __fd, off_t __length );

/* the following are also in process.h, but they are expected to be here */
_WCRTLINK extern int    execl( const char *__path, const char *__arg0, ... );
_WCRTLINK extern int    execle( const char *__path, const char *__arg0, ... );
_WCRTLINK extern int    execlp( const char *__file, const char *__arg0, ... );
_WCRTLINK extern int    execv( const char *__path, const char *const __argv[] );
_WCRTLINK extern int    execve( const char *__path, const char *const __argv[],
                            const char *const __envp[] );
_WCRTLINK extern int    execvp( const char *__file, const char *const __argv[] );

:endsegment

:include ext.sp

_WCRTLINK extern int    chsize( int __fildes, long __size );
_WCRTLINK extern int    eof( int __fildes );
_WCRTLINK extern long   filelength( int __fildes );
_WCRTLINK extern off_t  tell( int __fildes );
:segment QNX
_WCRTLINK extern nid_t  getnid( void );
_WCRTLINK extern int    lock( int __fildes, long __offset, long __nbytes );
_WCRTLINK extern void   qnx_display_msg( const char *__text );
_WCRTLINK extern void   qnx_display_hex( unsigned __value );
_WCRTLINK extern char   *qnx_fullpath( char *__fullpath, const char *__path );

struct _psinfo2; /* for C++ */

_WCRTLINK extern int    qnx_getids( pid_t pid, struct _psinfo2 *info);
_WCRTLINK extern int    qnx_setids( pid_t pid, int id, unsigned subtype );
_WCRTLINK extern int    qnx_sync( nid_t nid );
_WCRTLINK extern int    unlock( int __fildes, long __offset, long __nbytes );
:endsegment

#endif

:segment QNX | LINUX
:include posix.sp
_WCRTLINK extern int    getopt( int __argc, char * const __argv[], const char *__optstring );
_WCRTLINK extern char   *basename( char *__fname );
_WCRTLINK extern size_t confstr( int, char*, size_t );
_WCRTLINK extern int    fnmatch( const char *__pattern, const char *__string, int __flag );
_WCRTLINK extern off_t  ltrunc( int __fildes, off_t __offset, int __origin );
_WCRTLINK extern int    putenv( const char *__estring );

/* Globals used and set by getopt() */
_WCRTDATA extern char   *optarg;
:: split into three separate lines because of a bug in stupid C++ compiler
_WCRTDATA extern int    optind;
_WCRTDATA extern int    opterr;
_WCRTDATA extern int    optopt;
#endif

:endsegment
:segment LINUX
/* These are Linux specific */

_WCRTLINK extern int    ioperm( unsigned long __from, unsigned long __num, int __turn_on );
_WCRTLINK extern int    iopl( int __level );
_WCRTLINK extern int    nice( int __val );
_WCRTLINK extern void   usleep( unsigned long __usec );
_WCRTLINK extern int    _llseek( unsigned int __fildes, unsigned long __hi, unsigned long __lo, loff_t *__res, unsigned int __whence);
:endsegment
:segment QNX
#if defined(__386__)
#define __far_read read
#define __far_write write
#else
extern ssize_t __far_read(int __fildes,void __far *__buffer,size_t __len);
extern ssize_t __far_write(int __fildes,void __far *__buffer,size_t __len);
#endif

:endsegment
:endsegment
:segment DOS
_WCRTLINK extern int    fsync( int __filedes );
_WCRTLINK extern int    getopt( int __argc, char * const __argv[], const char *__optstring );
_WCRTLINK extern unsigned int sleep( unsigned int __seconds );

/* Globals used and set by getopt() */
_WCRTDATA extern char   *optarg;
:: split into three separate lines because of a bug in stupid C++ compiler
_WCRTDATA extern int    optind;
_WCRTDATA extern int    opterr;
_WCRTDATA extern int    optopt;
:endsegment

:include cplusepi.sp
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?