unistd.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* unistd.h <ndf@linux.mit.edu> */
  2. #include <features.h>
  3. #include <sys/types.h>
  4. #ifndef __UNISTD_H
  5. #define __UNISTD_H
  6. #include <errno.h>
  7. #ifdef __mc68000__
  8. #include <asm/unistd.h>
  9. #endif
  10. #define STDIN_FILENO 0
  11. #define STDOUT_FILENO 1
  12. #define STDERR_FILENO 2
  13. /* NULL-terminated array of "NAME=VALUE" environment variables. */
  14. extern char **__environ;
  15. extern char **environ;
  16. extern int close __P ((int));
  17. extern size_t read __P ((int __fd, char * __buf, size_t __nbytes));
  18. extern size_t write __P ((int __fd, __const char * __buf, size_t __n));
  19. extern off_t lseek __P ((int __fd, off_t __n, int __whence));
  20. extern int pipe __P ((int __pipedes[2]));
  21. extern unsigned int alarm __P ((unsigned int __seconds));
  22. extern int sleep __P ((unsigned int __seconds));
  23. extern void usleep __P ((unsigned long __microseconds));
  24. extern int pause __P ((void));
  25. extern char* crypt __P((__const char *__key, __const char *__salt));
  26. extern int isatty __P ((int __fd));
  27. extern int readlink __P ((__const char *__path, char *__buf, size_t __len));
  28. extern int link __P ((__const char *__from, __const char *__to));
  29. extern int symlink __P ((__const char *__from, __const char *__to));
  30. extern int readlink __P ((__const char *__path, char *__buf, size_t __len));
  31. extern int unlink __P ((__const char *__name));
  32. extern char *getcwd __P ((char *__buf, size_t __size));
  33. extern int fchdir __P ((int __fd));
  34. extern int chdir __P ((__const char *__path));
  35. extern int chown __P ((__const char *__file,
  36. uid_t __owner, gid_t __group));
  37. extern int fchown __P ((int __fd,
  38. uid_t __owner, gid_t __group));
  39. extern int fsync __P ((int __fd));
  40. extern int sync __P ((void));
  41. extern int rmdir __P ((__const char *__path));
  42. extern int rename __P((__const char* _old, __const char* _new));
  43. extern int access __P ((__const char *__name, int __type));
  44. extern int reboot __P ((int __magic, int __magic_too, int __flag));
  45. extern int mkstemp __P ((char * __template));
  46. extern char * mktemp __P ((char * __template));
  47. extern int _clone __P ((int (*fn)(void *arg), void *child_stack, int flags, void *arg));
  48. #if 0
  49. #ifndef SYS_fork
  50. #define SYS_fork 2
  51. #endif
  52. #define vfork() ({ \
  53. register long __res __asm__ ("%d0"); \
  54. __asm__ __volatile__ ("trap #0" \
  55. : "=g" (__res) \
  56. : "0" (SYS_fork) \
  57. : "%d0"); \
  58. __res; \
  59. })
  60. #endif
  61. #ifdef __mc68000__
  62. #define vfork() ({ \
  63. register unsigned long __res __asm__ ("%d0") = __NR_fork; \
  64. __asm__ __volatile__ ("trap #0" \
  65. : "=g" (__res) \
  66. : "0" (__res) \
  67. : "%d0"); \
  68. if (__res >= (unsigned long)-4096) { \
  69. errno = -__res; \
  70. __res = (pid_t)-1; \
  71. } \
  72. (pid_t)__res; \
  73. })
  74. #define fork fork_not_available_use_vfork
  75. #define clone clone_not_available_use__clone
  76. #endif
  77. #ifndef SEEK_SET
  78. #define SEEK_SET 0
  79. #define SEEK_CUR 1
  80. #define SEEK_END 2
  81. #endif
  82. #ifndef R_OK
  83. #define R_OK 4 /* Test for read permission. */
  84. #define W_OK 2 /* Test for write permission. */
  85. #define X_OK 1 /* Test for execute permission. */
  86. #define F_OK 0 /* Test for existence. */
  87. #endif
  88. #endif /* __UNISTD_H */