unistd.h 4.5 KB

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