unistd.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * unistd.h - standard system calls
  3. */
  4. /* $Id$ */
  5. #ifndef _UNISTD_H
  6. #define _UNISTD_H
  7. #include <stddef.h>
  8. #include <time.h>
  9. /* Types */
  10. typedef int pid_t;
  11. typedef int mode_t;
  12. typedef long suseconds_t;
  13. /* Time handling. */
  14. struct timeval
  15. {
  16. time_t tv_sec;
  17. suseconds_t tv_usec;
  18. };
  19. struct timezone
  20. {
  21. int tz_minuteswest;
  22. int tz_dsttime;
  23. }; /* obsolete, unused */
  24. extern int gettimeofday(struct timeval* tv, struct timezone* tz);
  25. extern int settimeofday(const struct timeval* tv, const struct timezone* tz);
  26. /* File access. */
  27. enum
  28. {
  29. O_ACCMODE = 0x3,
  30. O_RDONLY = 0,
  31. O_WRONLY = 1,
  32. O_RDWR = 2,
  33. O_CREAT = 0x40,
  34. O_TRUNC = 0x200,
  35. O_APPEND = 0x400
  36. };
  37. extern int open(const char* path, int access, ...);
  38. extern int creat(const char* path, mode_t mode);
  39. extern int close(int d);
  40. extern int read(int fd, void* buffer, size_t count);
  41. extern int write(int fd, void* buffer, size_t count);
  42. extern off_t lseek(int fildes, off_t offset, int whence);
  43. extern int fcntl(int fd, int op, ...);
  44. extern int unlink(const char* path);
  45. extern int remove(const char* path);
  46. /* Special variables */
  47. extern char** environ;
  48. /* Implemented system calls */
  49. extern void _exit(int);
  50. extern pid_t getpid(void);
  51. extern int brk(void* ptr);
  52. extern void* sbrk(intptr_t increment);
  53. extern int isatty(int d);
  54. /* Signal handling */
  55. typedef int sig_atomic_t;
  56. #define SIG_ERR ((sighandler_t) -1) /* Error return. */
  57. #define SIG_DFL ((sighandler_t) 0) /* Default action. */
  58. #define SIG_IGN ((sighandler_t) 1) /* Ignore signal. */
  59. #define SIGHUP 1 /* Hangup (POSIX). */
  60. #define SIGINT 2 /* Interrupt (ANSI). */
  61. #define SIGQUIT 3 /* Quit (POSIX). */
  62. #define SIGILL 4 /* Illegal instruction (ANSI). */
  63. #define SIGTRAP 5 /* Trace trap (POSIX). */
  64. #define SIGABRT 6 /* Abort (ANSI). */
  65. #define SIGIOT 6 /* IOT trap (4.2 BSD). */
  66. #define SIGBUS 7 /* BUS error (4.2 BSD). */
  67. #define SIGFPE 8 /* Floating-point exception (ANSI). */
  68. #define SIGKILL 9 /* Kill, unblockable (POSIX). */
  69. #define SIGUSR1 10 /* User-defined signal 1 (POSIX). */
  70. #define SIGSEGV 11 /* Segmentation violation (ANSI). */
  71. #define SIGUSR2 12 /* User-defined signal 2 (POSIX). */
  72. #define SIGPIPE 13 /* Broken pipe (POSIX). */
  73. #define SIGALRM 14 /* Alarm clock (POSIX). */
  74. #define SIGTERM 15 /* Termination (ANSI). */
  75. #define SIGSTKFLT 16 /* Stack fault. */
  76. #define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */
  77. #define SIGCHLD 17 /* Child status has changed (POSIX). */
  78. #define SIGCONT 18 /* Continue (POSIX). */
  79. #define SIGSTOP 19 /* Stop, unblockable (POSIX). */
  80. #define SIGTSTP 20 /* Keyboard stop (POSIX). */
  81. #define SIGTTIN 21 /* Background read from tty (POSIX). */
  82. #define SIGTTOU 22 /* Background write to tty (POSIX). */
  83. #define SIGURG 23 /* Urgent condition on socket (4.2 BSD). */
  84. #define SIGXCPU 24 /* CPU limit exceeded (4.2 BSD). */
  85. #define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */
  86. #define SIGVTALRM 26 /* Virtual alarm clock (4.2 BSD). */
  87. #define SIGPROF 27 /* Profiling alarm clock (4.2 BSD). */
  88. #define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */
  89. #define SIGPOLL SIGIO /* Pollable event occurred (System V). */
  90. #define SIGIO 29 /* I/O now possible (4.2 BSD). */
  91. #define SIGPWR 30 /* Power failure restart (System V). */
  92. #define SIGSYS 31 /* Bad system call. */
  93. #define SIGUNUSED 31
  94. #define _NSIG 32 /* Biggest signal number + 1
  95. (not including real-time signals). */
  96. typedef void (*sighandler_t)(int);
  97. extern sighandler_t signal(int signum, sighandler_t handler);
  98. extern int raise(int signum);
  99. #endif