1: #ifndef _SYS_UNISTD_H 2: #define _SYS_UNISTD_H 3: 4: #ifdef __cplusplus 5: extern "C" { 6: #endif 7: 8: #include <_ansi.h> 9: #include <sys/types.h> 10: #include <sys/_types.h> 11: #define __need_size_t 12: #define __need_ptrdiff_t 13: #include <stddef.h> 14: 15: extern char **environ; 16: 17: void _EXFUN(_exit, (int __status ) _ATTRIBUTE ((noreturn))); 18: 19: int _EXFUN(access,(const char *__path, int __amode )); 20: unsigned _EXFUN(alarm, (unsigned __secs )); 21: int _EXFUN(chdir, (const char *__path )); 22: int _EXFUN(chmod, (const char *__path, mode_t __mode )); 23: #if !defined(__INSIDE_CYGWIN__) 24: int _EXFUN(chown, (const char *__path, uid_t __owner, gid_t __group )); 25: #endif 26: #if defined(__CYGWIN__) || defined(__rtems__) 27: int _EXFUN(chroot, (const char *__path )); 28: #endif 29: int _EXFUN(close, (int __fildes )); 30: char _EXFUN(*ctermid, (char *__s )); 31: char _EXFUN(*cuserid, (char *__s )); 32: #if defined(__CYGWIN__) 33: int _EXFUN(daemon, (int nochdir, int noclose)); 34: #endif 35: int _EXFUN(dup, (int __fildes )); 36: int _EXFUN(dup2, (int __fildes, int __fildes2 )); 37: #if defined(__CYGWIN__) 38: void _EXFUN(endusershell, (void)); 39: #endif 40: int _EXFUN(execl, (const char *__path, const char *, ... )); 41: int _EXFUN(execle, (const char *__path, const char *, ... )); 42: int _EXFUN(execlp, (const char *__file, const char *, ... )); 43: int _EXFUN(execv, (const char *__path, char * const __argv[] )); 44: int _EXFUN(execve, (const char *__path, char * const __argv[], char * const __envp[] )); 45: int _EXFUN(execvp, (const char *__file, char * const __argv[] )); 46: #if defined(__CYGWIN__) || defined(__rtems__) 47: int _EXFUN(fchdir, (int __fildes)); 48: #endif 49: int _EXFUN(fchmod, (int __fildes, mode_t __mode )); 50: #if !defined(__INSIDE_CYGWIN__) 51: int _EXFUN(fchown, (int __fildes, uid_t __owner, gid_t __group )); 52: #endif 53: pid_t _EXFUN(fork, (void )); 54: long _EXFUN(fpathconf, (int __fd, int __name )); 55: int _EXFUN(fsync, (int __fd)); 56: #ifndef __CYGWIN__ 57: int _EXFUN(fdatasync, (int __fd)); 58: #endif 59: char _EXFUN(*getcwd, (char *__buf, size_t __size )); 60: #if defined(__CYGWIN__) 61: int _EXFUN(getdomainname ,(char *__name, size_t __len)); 62: #endif 63: #if !defined(__INSIDE_CYGWIN__) 64: gid_t _EXFUN(getegid, (void )); 65: uid_t _EXFUN(geteuid, (void )); 66: gid_t _EXFUN(getgid, (void )); 67: #endif 68: int _EXFUN(getgroups, (int __gidsetsize, gid_t __grouplist[] )); 69: #if defined(__CYGWIN__) 70: long _EXFUN(gethostid, (void)); 71: #endif 72: char _EXFUN(*getlogin, (void )); 73: #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) 74: int _EXFUN(getlogin_r, (char *name, size_t namesize) ); 75: #endif 76: char _EXFUN(*getpass, (__const char *__prompt)); 77: size_t _EXFUN(getpagesize, (void)); 78: pid_t _EXFUN(getpgid, (pid_t)); 79: pid_t _EXFUN(getpgrp, (void )); 80: pid_t _EXFUN(getpid, (void )); 81: pid_t _EXFUN(getppid, (void )); 82: #ifdef __CYGWIN__ 83: pid_t _EXFUN(getsid, (pid_t)); 84: #endif 85: #if !defined(__INSIDE_CYGWIN__) 86: uid_t _EXFUN(getuid, (void )); 87: #endif 88: #ifdef __CYGWIN__ 89: char * _EXFUN(getusershell, (void)); 90: char _EXFUN(*getwd, (char *__buf )); 91: int _EXFUN(iruserok, (unsigned long raddr, int superuser, const char *ruser, const char *luser)); 92: #endif 93: int _EXFUN(isatty, (int __fildes )); 94: #if !defined(__INSIDE_CYGWIN__) 95: int _EXFUN(lchown, (const char *__path, uid_t __owner, gid_t __group )); 96: #endif 97: int _EXFUN(link, (const char *__path1, const char *__path2 )); 98: int _EXFUN(nice, (int __nice_value )); 99: #if !defined(__INSIDE_CYGWIN__) 100: off_t _EXFUN(lseek, (int __fildes, off_t __offset, int __whence )); 101: #endif 102: long _EXFUN(pathconf, (const char *__path, int __name )); 103: int _EXFUN(pause, (void )); 104: #ifdef __CYGWIN__ 105: int _EXFUN(pthread_atfork, (void (*)(void), void (*)(void), void (*)(void))); 106: #endif 107: int _EXFUN(pipe, (int __fildes[2] )); 108: ssize_t _EXFUN(pread, (int __fd, void *__buf, size_t __nbytes, off_t __offset)); 109: ssize_t _EXFUN(pwrite, (int __fd, const void *__buf, size_t __nbytes, off_t __offset)); 110: _READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte )); 111: #if defined(__CYGWIN__) 112: int _EXFUN(rresvport, (int *__alport)); 113: int _EXFUN(revoke, (char *__path)); 114: #endif 115: int _EXFUN(rmdir, (const char *__path )); 116: #if defined(__CYGWIN__) 117: int _EXFUN(ruserok, (const char *rhost, int superuser, const char *ruser, const char *luser)); 118: #endif 119: void * _EXFUN(sbrk, (ptrdiff_t __incr)); 120: #if !defined(__INSIDE_CYGWIN__) 121: #if defined(__CYGWIN__) 122: int _EXFUN(setegid, (gid_t __gid )); 123: int _EXFUN(seteuid, (uid_t __uid )); 124: #endif 125: int _EXFUN(setgid, (gid_t __gid )); 126: #endif 127: #if defined(__CYGWIN__) 128: int _EXFUN(setgroups, (int ngroups, const gid_t *grouplist )); 129: #endif 130: int _EXFUN(setpgid, (pid_t __pid, pid_t __pgid )); 131: int _EXFUN(setpgrp, (void )); 132: #if defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__) 133: int _EXFUN(setregid, (gid_t __rgid, gid_t __egid)); 134: int _EXFUN(setreuid, (uid_t __ruid, uid_t __euid)); 135: #endif 136: pid_t _EXFUN(setsid, (void )); 137: #if !defined(__INSIDE_CYGWIN__) 138: int _EXFUN(setuid, (uid_t __uid )); 139: #endif 140: #if defined(__CYGWIN__) 141: void _EXFUN(setusershell, (void)); 142: #endif 143: unsigned _EXFUN(sleep, (unsigned int __seconds )); 144: void _EXFUN(swab, (const void *, void *, ssize_t)); 145: long _EXFUN(sysconf, (int __name )); 146: pid_t _EXFUN(tcgetpgrp, (int __fildes )); 147: int _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id )); 148: char _EXFUN(*ttyname, (int __fildes )); 149: #if defined(__CYGWIN__) 150: int _EXFUN(ttyname_r, (int, char *, size_t)); 151: #endif 152: int _EXFUN(unlink, (const char *__path )); 153: int _EXFUN(vhangup, (void )); 154: _READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte )); 155: 156: #ifdef __CYGWIN__ 157: # define __UNISTD_GETOPT__ 158: # include <getopt.h> 159: # undef __UNISTD_GETOPT__ 160: #else 161: extern char *optarg; /* getopt(3) external variables */ 162: extern int optind, opterr, optopt; 163: int getopt(int, char * const [], const char *); 164: extern int optreset; /* getopt(3) external variable */ 165: #endif 166: 167: #ifndef _POSIX_SOURCE 168: pid_t _EXFUN(vfork, (void )); 169: 170: extern char *suboptarg; /* getsubopt(3) external variable */ 171: int getsubopt(char **, char * const *, char **); 172: #endif /* _POSIX_SOURCE */ 173: 174: #ifdef _COMPILING_NEWLIB 175: /* Provide prototypes for most of the _<systemcall> names that are 176: provided in newlib for some compilers. */ 177: int _EXFUN(_close, (int __fildes )); 178: pid_t _EXFUN(_fork, (void )); 179: pid_t _EXFUN(_getpid, (void )); 180: int _EXFUN(_link, (const char *__path1, const char *__path2 )); 181: _off_t _EXFUN(_lseek, (int __fildes, _off_t __offset, int __whence )); 182: #ifdef __LARGE64_FILES 183: _off64_t _EXFUN(_lseek64, (int __filedes, _off64_t __offset, int __whence )); 184: #endif 185: _READ_WRITE_RETURN_TYPE _EXFUN(_read, (int __fd, void *__buf, size_t __nbyte )); 186: void * _EXFUN(_sbrk, (ptrdiff_t __incr)); 187: int _EXFUN(_unlink, (const char *__path )); 188: _READ_WRITE_RETURN_TYPE _EXFUN(_write, (int __fd, const void *__buf, size_t __nbyte )); 189: int _EXFUN(_execve, (const char *__path, char * const __argv[], char * const __envp[] )); 190: #endif 191: 192: #if defined(__CYGWIN__) || defined(__rtems__) || defined(__sh__) 193: #if !defined(__INSIDE_CYGWIN__) 194: int _EXFUN(ftruncate, (int __fd, off_t __length)); 195: int _EXFUN(truncate, (const char *, off_t __length)); 196: #endif 197: #endif 198: #if defined(__CYGWIN__) || defined(__rtems__) 199: int _EXFUN(getdtablesize, (void)); 200: int _EXFUN(setdtablesize, (int)); 201: useconds_t _EXFUN(ualarm, (useconds_t __useconds, useconds_t __interval)); 202: unsigned _EXFUN(usleep, (unsigned int __useconds)); 203: #if !(defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) 204: /* winsock[2].h defines as __stdcall, and with int as 2nd arg */ 205: int _EXFUN(gethostname, (char *__name, size_t __len)); 206: #endif 207: char * _EXFUN(mktemp, (char *)); 208: #if defined(__CYGWIN__) 209: void _EXFUN(sync, (void)); 210: #else /* defined(__rtems__) */ 211: int _EXFUN(sync, (void)); 212: #endif 213: int _EXFUN(readlink, (const char *__path, char *__buf, int __buflen)); 214: int _EXFUN(symlink, (const char *__name1, const char *__name2)); 215: #endif 216: 217: #define F_OK 0 218: #define R_OK 4 219: #define W_OK 2 220: #define X_OK 1 221: 222: # define SEEK_SET 0 223: # define SEEK_CUR 1 224: # define SEEK_END 2 225: 226: #include <sys/features.h> 227: 228: #define STDIN_FILENO 0 /* standard input file descriptor */ 229: #define STDOUT_FILENO 1 /* standard output file descriptor */ 230: #define STDERR_FILENO 2 /* standard error file descriptor */ 231: 232: /* 233: * 4.8.1 Get Configurable System Variables, P1003.1b-1993, p. 96 234: * 235: * NOTE: Table 4-2, Configurable System Variables, p. 96 236: */ 237: 238: #define _SC_ARG_MAX 0 239: #define _SC_CHILD_MAX 1 240: #define _SC_CLK_TCK 2 241: #define _SC_NGROUPS_MAX 3 242: #define _SC_OPEN_MAX 4 243: /* no _SC_STREAM_MAX */ 244: #define _SC_JOB_CONTROL 5 245: #define _SC_SAVED_IDS 6 246: #define _SC_VERSION 7 247: #define _SC_PAGESIZE 8 248: /* CYGWIN-specific values .. do not touch */ 249: #define _SC_NPROCESSORS_CONF 9 250: #define _SC_NPROCESSORS_ONLN 10 251: #define _SC_PHYS_PAGES 11 252: #define _SC_AVPHYS_PAGES 12 253: /* end of CYGWIN-specific values */ 254: #define _SC_MQ_OPEN_MAX 13 255: #define _SC_MQ_PRIO_MAX 14 256: #define _SC_RTSIG_MAX 15 257: #define _SC_SEM_NSEMS_MAX 16 258: #define _SC_SEM_VALUE_MAX 17 259: #define _SC_SIGQUEUE_MAX 18 260: #define _SC_TIMER_MAX 19 261: #define _SC_TZNAME_MAX 20 262: 263: #define _SC_ASYNCHRONOUS_IO 21 264: #define _SC_FSYNC 22 265: #define _SC_MAPPED_FILES 23 266: #define _SC_MEMLOCK 24 267: #define _SC_MEMLOCK_RANGE 25 268: #define _SC_MEMORY_PROTECTION 26 269: #define _SC_MESSAGE_PASSING 27 270: #define _SC_PRIORITIZED_IO 28 271: #define _SC_REALTIME_SIGNALS 29 272: #define _SC_SEMAPHORES 30 273: #define _SC_SHARED_MEMORY_OBJECTS 31 274: #define _SC_SYNCHRONIZED_IO 32 275: #define _SC_TIMERS 33 276: #define _SC_AIO_LISTIO_MAX 34 277: #define _SC_AIO_MAX 35 278: #define _SC_AIO_PRIO_DELTA_MAX 36 279: #define _SC_DELAYTIMER_MAX 37 280: 281: /* 282: * P1003.1c/D10, p. 52 adds the following. 283: */ 284: 285: #define _SC_THREAD_KEYS_MAX 38 286: #define _SC_THREAD_STACK_MIN 39 287: #define _SC_THREAD_THREADS_MAX 40 288: #define _SC_TTY_NAME_MAX 41 289: 290: #define _SC_THREADS 42 291: #define _SC_THREAD_ATTR_STACKADDR 43 292: #define _SC_THREAD_ATTR_STACKSIZE 44 293: #define _SC_THREAD_PRIORITY_SCHEDULING 45 294: #define _SC_THREAD_PRIO_INHERIT 46 295: /* _SC_THREAD_PRIO_PROTECT was _SC_THREAD_PRIO_CEILING in early drafts */ 296: #define _SC_THREAD_PRIO_PROTECT 47 297: #define _SC_THREAD_PRIO_CEILING _SC_THREAD_PRIO_PROTECT 298: #define _SC_THREAD_PROCESS_SHARED 48 299: #define _SC_THREAD_SAFE_FUNCTIONS 49 300: #define _SC_GETGR_R_SIZE_MAX 50 301: #define _SC_GETPW_R_SIZE_MAX 51 302: #define _SC_LOGIN_NAME_MAX 52 303: #define _SC_THREAD_DESTRUCTOR_ITERATIONS 53 304: 305: #if !defined(__CYGWIN__) && !defined(__rtems__) 306: #define _SC_STREAM_MAX 100 307: #define _SC_PRIORITY_SCHEDULING 101 308: #endif 309: 310: # define _PC_LINK_MAX 0 311: # define _PC_MAX_CANON 1 312: # define _PC_MAX_INPUT 2 313: # define _PC_NAME_MAX 3 314: # define _PC_PATH_MAX 4 315: # define _PC_PIPE_BUF 5 316: # define _PC_CHOWN_RESTRICTED 6 317: # define _PC_NO_TRUNC 7 318: # define _PC_VDISABLE 8 319: # define _PC_ASYNC_IO 9 320: # define _PC_PRIO_IO 10 321: # define _PC_SYNC_IO 11 322: #ifdef __CYGWIN__ 323: /* Ask for POSIX permission bits support. */ 324: # define _PC_POSIX_PERMISSIONS 90 325: /* Ask for full POSIX permission support including uid/gid settings. */ 326: # define _PC_POSIX_SECURITY 91 327: #endif 328: 329: /* FIXME: This is temporary until winsup gets sorted out. */ 330: #ifdef __CYGWIN__ 331: #define MAXPATHLEN (260 - 1 /* NUL */) 332: #else 333: # define MAXPATHLEN 1024 334: #endif 335: 336: #ifdef __cplusplus 337: } 338: #endif 339: #endif /* _SYS_UNISTD_H */ 340: