mod.rs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. use super::types::*;
  2. use c_str::CStr;
  3. use header::dirent::dirent;
  4. //use header::sys_resource::rusage;
  5. use header::sys_select::fd_set;
  6. use header::sys_stat::stat;
  7. use header::sys_time::{itimerval, timeval, timezone};
  8. //use header::sys_times::tms;
  9. use header::sys_utsname::utsname;
  10. use header::termios::termios;
  11. use header::time::timespec;
  12. pub use self::signal::PalSignal;
  13. mod signal;
  14. pub use self::socket::PalSocket;
  15. mod socket;
  16. pub trait Pal {
  17. fn access(path: &CStr, mode: c_int) -> c_int;
  18. fn brk(addr: *mut c_void) -> *mut c_void;
  19. fn chdir(path: &CStr) -> c_int;
  20. fn chmod(path: &CStr, mode: mode_t) -> c_int;
  21. fn chown(path: &CStr, owner: uid_t, group: gid_t) -> c_int;
  22. fn clock_gettime(clk_id: clockid_t, tp: *mut timespec) -> c_int;
  23. fn close(fildes: c_int) -> c_int;
  24. fn dup(fildes: c_int) -> c_int;
  25. fn dup2(fildes: c_int, fildes2: c_int) -> c_int;
  26. unsafe fn execve(path: &CStr, argv: *const *mut c_char, envp: *const *mut c_char) -> c_int;
  27. fn exit(status: c_int) -> !;
  28. fn fchdir(fildes: c_int) -> c_int;
  29. fn fchmod(fildes: c_int, mode: mode_t) -> c_int;
  30. fn fchown(fildes: c_int, owner: uid_t, group: gid_t) -> c_int;
  31. fn flock(fd: c_int, operation: c_int) -> c_int;
  32. fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
  33. fn fcntl(fildes: c_int, cmd: c_int, arg: c_int) -> c_int;
  34. fn fork() -> pid_t;
  35. fn fsync(fildes: c_int) -> c_int;
  36. fn ftruncate(fildes: c_int, length: off_t) -> c_int;
  37. fn futimens(fd: c_int, times: *const timespec) -> c_int;
  38. fn utimens(path: &CStr, times: *const timespec) -> c_int;
  39. fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char;
  40. fn getdents(fd: c_int, dirents: *mut dirent, bytes: usize) -> c_int;
  41. fn getegid() -> gid_t;
  42. fn geteuid() -> uid_t;
  43. fn getgid() -> gid_t;
  44. fn gethostname(name: *mut c_char, len: size_t) -> c_int;
  45. fn getpgid(pid: pid_t) -> pid_t;
  46. fn getpid() -> pid_t;
  47. fn getppid() -> pid_t;
  48. fn gettimeofday(tp: *mut timeval, tzp: *mut timezone) -> c_int;
  49. fn getuid() -> uid_t;
  50. fn isatty(fd: c_int) -> c_int;
  51. fn link(path1: &CStr, path2: &CStr) -> c_int;
  52. fn lseek(fildes: c_int, offset: off_t, whence: c_int) -> off_t;
  53. fn mkdir(path: &CStr, mode: mode_t) -> c_int;
  54. fn mkfifo(path: &CStr, mode: mode_t) -> c_int;
  55. unsafe fn mmap(
  56. addr: *mut c_void,
  57. len: usize,
  58. prot: c_int,
  59. flags: c_int,
  60. fildes: c_int,
  61. off: off_t,
  62. ) -> *mut c_void;
  63. unsafe fn munmap(addr: *mut c_void, len: usize) -> c_int;
  64. fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int;
  65. fn open(path: &CStr, oflag: c_int, mode: mode_t) -> c_int;
  66. fn pipe(fildes: &mut [c_int]) -> c_int;
  67. fn read(fildes: c_int, buf: &mut [u8]) -> ssize_t;
  68. //fn readlink(pathname: &CStr, out: &mut [u8]) -> ssize_t;
  69. fn realpath(pathname: &CStr, out: &mut [u8]) -> c_int;
  70. fn rename(old: &CStr, new: &CStr) -> c_int;
  71. fn rmdir(path: &CStr) -> c_int;
  72. fn select(
  73. nfds: c_int,
  74. readfds: *mut fd_set,
  75. writefds: *mut fd_set,
  76. exceptfds: *mut fd_set,
  77. timeout: *mut timeval,
  78. ) -> c_int;
  79. fn setpgid(pid: pid_t, pgid: pid_t) -> c_int;
  80. fn setregid(rgid: gid_t, egid: gid_t) -> c_int;
  81. fn setreuid(ruid: uid_t, euid: uid_t) -> c_int;
  82. fn tcgetattr(fd: c_int, out: *mut termios) -> c_int;
  83. fn tcsetattr(fd: c_int, act: c_int, value: *const termios) -> c_int;
  84. fn unlink(path: &CStr) -> c_int;
  85. fn waitpid(pid: pid_t, stat_loc: *mut c_int, options: c_int) -> pid_t;
  86. fn write(fildes: c_int, buf: &[u8]) -> ssize_t;
  87. }