unistd.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * unistd.h - standard system calls
  3. */
  4. /* $Id$ */
  5. #ifndef _UNISTD_H
  6. #define _UNISTD_H
  7. #include <stddef.h>
  8. /* Types */
  9. typedef int pid_t;
  10. typedef int mode_t;
  11. /* Constants for file access (open and friends) */
  12. enum
  13. {
  14. O_ACCMODE = 0x3,
  15. O_RDONLY = 0,
  16. O_WRONLY = 1,
  17. O_RDWR = 2,
  18. O_CREAT = 0100,
  19. O_TRUNC = 01000,
  20. O_APPEND = 02000,
  21. O_NONBLOCK = 04000
  22. };
  23. /* Special variables */
  24. extern char** environ;
  25. /* Implemented system calls */
  26. extern void _exit(int);
  27. extern pid_t getpid(void);
  28. extern void* sbrk(intptr_t increment);
  29. extern int isatty(int d);
  30. extern off_t lseek(int fildes, off_t offset, int whence);
  31. extern int close(int d);
  32. extern int open(const char* path, int access, ...);
  33. extern int creat(const char* path, mode_t mode);
  34. extern int read(int fd, void* buffer, size_t count);
  35. extern int write(int fd, void* buffer, size_t count);
  36. /* Unimplemented system calls (these are just prototypes to let the library
  37. * compile). */
  38. extern int fcntl(int fd, int op, ...);
  39. /* Signal handling */
  40. typedef int sig_atomic_t;
  41. #define SIG_ERR ((sighandler_t) -1) /* Error return. */
  42. #define SIG_DFL ((sighandler_t) 0) /* Default action. */
  43. #define SIG_IGN ((sighandler_t) 1) /* Ignore signal. */
  44. #define SIGABRT 6 /* Abort (ANSI) */
  45. #define SIGILL 11 /* Illegal instruction */
  46. #define _NSIG 32 /* Biggest signal number + 1
  47. (not including real-time signals). */
  48. typedef void (*sighandler_t)(int);
  49. extern sighandler_t signal(int signum, sighandler_t handler);
  50. extern int raise(int signum);
  51. #endif