unistd.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #ifndef __UNISTD_H
  2. #define __UNISTD_H
  3. #ifndef _POSIX_SOURCE
  4. This header file is not defined in pure ANSI
  5. #endif
  6. #pragma lib "/$M/lib/ape/libap.a"
  7. #define _POSIX_VERSION 199309L
  8. #define _POSIX_ASYNC_IO -1
  9. #define _POSIX_CHOWN_RESTRICTED 1
  10. #define _POSIX_NO_TRUNC 1
  11. #define _POSIX_PRIO_IO -1
  12. #define _POSIX_SYNC_IO -1
  13. #define _POSIX_VDISABLE -1
  14. #ifndef _SIZE_T
  15. #define _SIZE_T
  16. typedef unsigned long size_t;
  17. #endif
  18. #ifndef _SSIZE_T
  19. #define _SSIZE_T
  20. typedef long ssize_t;
  21. #endif
  22. #ifndef NULL
  23. #ifndef NULL
  24. #ifdef __cplusplus
  25. #define NULL 0
  26. #else
  27. #define NULL ((void*)0)
  28. #endif
  29. #endif
  30. #endif
  31. /* access */
  32. #define R_OK 4
  33. #define W_OK 2
  34. #define X_OK 1
  35. #define F_OK 0 /* test for existence */
  36. /* lockf */
  37. #define F_ULOCK 0 /* unlock a previously locked region */
  38. #define F_LOCK 1 /* lock a region for exclusive use */
  39. #define F_TLOCK 2 /* test and lock a region for exclusive use */
  40. #define F_TEST 3 /* test a region for a previous lock */
  41. /* lseek */
  42. #ifndef SEEK_SET /* also defined in stdio.h */
  43. #define SEEK_SET 0
  44. #define SEEK_CUR 1
  45. #define SEEK_END 2
  46. #endif
  47. /* sysconf argument */
  48. #define _SC_ARG_MAX 1 /* max chars in args to exec */
  49. #define _SC_CHILD_MAX 2 /* max child process per process */
  50. #define _SC_CLK_TCK 3 /* number of clock() units per second */
  51. #define _SC_NGROUPS_MAX 4 /* max supplementary groups per process */
  52. #define _SC_OPEN_MAX 5
  53. #define _SC_STREAM_MAX 6
  54. #define _SC_TZNAME_MAX 7
  55. #define _SC_JOB_CONTROL 8 /* posix job control */
  56. #define _SC_SAVED_IDS 9 /* saved suid/sgid per process */
  57. #define _SC_VERSION 10 /* this version */
  58. #define _SC_LOGIN_NAME_MAX 11 /* max length of a login name */
  59. /* pathconf argument */
  60. #define _PC_LINK_MAX 1
  61. #define _PC_MAX_CANON 2
  62. #define _PC_MAX_INPUT 3
  63. #define _PC_NAME_MAX 4
  64. #define _PC_PATH_MAX 5
  65. #define _PC_PIPE_BUF 6
  66. #define _PC_CHOWN_RESTRICTED 7
  67. #define _PC_NO_TRUNC 8
  68. #define _PC_VDISABLE 9
  69. /* standard filenos */
  70. #define STDIN_FILENO 0
  71. #define STDOUT_FILENO 1
  72. #define STDERR_FILENO 2
  73. #ifdef __cplusplus
  74. extern "C" {
  75. #endif
  76. /* process primitives */
  77. extern int execl(const char *, const char *, ...);
  78. extern int execv(const char *, const char **);
  79. extern int execle(const char *, const char *, const char *, ...);
  80. extern int execve(const char *, const char **, const char **);
  81. extern int execlp(const char *, const char *, ...);
  82. extern int execvp(const char *, const char **);
  83. extern void _exit(int);
  84. extern unsigned int alarm(unsigned int);
  85. extern int pause(void);
  86. extern unsigned int sleep(unsigned int);
  87. #ifdef __TYPES_H
  88. extern pid_t fork(void);
  89. #endif
  90. /* process environment */
  91. extern char *getlogin(void);
  92. extern char *cuserid(char *);
  93. extern char *ttyname(int);
  94. extern int isatty(int);
  95. extern long sysconf(int);
  96. #ifdef __TYPES_H
  97. extern pid_t getpid(void);
  98. extern pid_t getppid(void);
  99. extern uid_t getuid(void);
  100. extern uid_t geteuid(void);
  101. extern gid_t getgid(void);
  102. extern gid_t getegid(void);
  103. extern int setuid(uid_t);
  104. extern int setgid(gid_t);
  105. extern int getgroups(int, gid_t *);
  106. extern pid_t getpgrp(void);
  107. extern int setpgid(pid_t, pid_t);
  108. extern pid_t setsid(void);
  109. #endif
  110. /* files and directories */
  111. extern int chdir(const char *);
  112. extern int link(const char *, const char *);
  113. extern char *getcwd(char *, size_t);
  114. extern int unlink(const char *);
  115. extern int rmdir(const char *);
  116. extern int rename(const char *, const char *);
  117. extern int access(const char *, int);
  118. extern long pathconf(const char *, int);
  119. extern long fpathconf(int, int);
  120. #ifdef __TYPES_H
  121. extern int chown(const char *, uid_t, gid_t);
  122. #endif
  123. /* input and output primitives */
  124. extern int pipe(int *);
  125. extern int dup(int);
  126. extern int dup2(int, int);
  127. extern int close(int);
  128. extern ssize_t read(int, void *, size_t);
  129. extern ssize_t write(int, const void *, size_t);
  130. #ifdef __TYPES_H
  131. extern int ftruncate(int, off_t);
  132. extern off_t lseek(int, off_t, int);
  133. #endif
  134. /* device- and class-specific functions */
  135. #ifdef __TYPES_H
  136. extern pid_t tcgetpgrp(int);
  137. extern int tcsetpgrp(int, pid_t);
  138. #endif
  139. #ifdef _REENTRANT_SOURCE
  140. extern char *getlogin_r(char *, int);
  141. #endif
  142. /* berkeley specific functions */
  143. #ifdef _BSD_EXTENSION
  144. #include <bsd.h>
  145. #endif
  146. #ifdef __cplusplus
  147. }
  148. #endif
  149. #endif