unistd.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. /* pathconf argument */
  59. #define _PC_LINK_MAX 1
  60. #define _PC_MAX_CANON 2
  61. #define _PC_MAX_INPUT 3
  62. #define _PC_NAME_MAX 4
  63. #define _PC_PATH_MAX 5
  64. #define _PC_PIPE_BUF 6
  65. #define _PC_CHOWN_RESTRICTED 7
  66. #define _PC_NO_TRUNC 8
  67. #define _PC_VDISABLE 9
  68. /* standard filenos */
  69. #define STDIN_FILENO 0
  70. #define STDOUT_FILENO 1
  71. #define STDERR_FILENO 2
  72. #ifdef __cplusplus
  73. extern "C" {
  74. #endif
  75. /* process primitives */
  76. extern int execl(const char *, const char *, ...);
  77. extern int execv(const char *, const char **);
  78. extern int execle(const char *, const char *, const char *, ...);
  79. extern int execve(const char *, const char **, const char **);
  80. extern int execlp(const char *, const char *, ...);
  81. extern int execvp(const char *, const char **);
  82. extern void _exit(int);
  83. extern unsigned int alarm(unsigned int);
  84. extern int pause(void);
  85. extern unsigned int sleep(unsigned int);
  86. #ifdef __TYPES_H
  87. extern pid_t fork(void);
  88. #endif
  89. /* process environment */
  90. extern char *getlogin(void);
  91. extern char *cuserid(char *);
  92. extern char *ttyname(int);
  93. extern int isatty(int);
  94. extern long sysconf(int);
  95. #ifdef __TYPES_H
  96. extern pid_t getpid(void);
  97. extern pid_t getppid(void);
  98. extern uid_t getuid(void);
  99. extern uid_t geteuid(void);
  100. extern gid_t getgid(void);
  101. extern gid_t getegid(void);
  102. extern int setuid(uid_t);
  103. extern int setgid(gid_t);
  104. extern int getgroups(int, gid_t *);
  105. extern pid_t getpgrp(void);
  106. extern int setpgid(pid_t, pid_t);
  107. extern pid_t setsid(void);
  108. #endif
  109. /* files and directories */
  110. extern int chdir(const char *);
  111. extern int link(const char *, const char *);
  112. extern char *getcwd(char *, size_t);
  113. extern int unlink(const char *);
  114. extern int rmdir(const char *);
  115. extern int rename(const char *, const char *);
  116. extern int access(const char *, int);
  117. extern long pathconf(const char *, int);
  118. extern long fpathconf(int, int);
  119. #ifdef __TYPES_H
  120. extern int chown(const char *, uid_t, gid_t);
  121. #endif
  122. /* input and output primitives */
  123. extern int pipe(int *);
  124. extern int dup(int);
  125. extern int dup2(int, int);
  126. extern int close(int);
  127. extern ssize_t read(int, void *, size_t);
  128. extern ssize_t write(int, const void *, size_t);
  129. #ifdef __TYPES_H
  130. extern off_t lseek(int, off_t, int);
  131. #endif
  132. /* device- and class-specific functions */
  133. #ifdef __TYPES_H
  134. extern pid_t tcgetpgrp(int);
  135. extern int tcsetpgrp(int, pid_t);
  136. #endif
  137. /* berkeley specific functions */
  138. #ifdef _BSD_EXTENSION
  139. #include <bsd.h>
  140. #endif
  141. #ifdef __cplusplus
  142. }
  143. #endif
  144. #endif