unistd.h 3.1 KB

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