syscall_linux_mips64x.go 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build linux
  5. // +build mips64 mips64le
  6. package unix
  7. //sys Dup2(oldfd int, newfd int) (err error)
  8. //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
  9. //sys Fchown(fd int, uid int, gid int) (err error)
  10. //sys Fstatfs(fd int, buf *Statfs_t) (err error)
  11. //sys Ftruncate(fd int, length int64) (err error)
  12. //sysnb Getegid() (egid int)
  13. //sysnb Geteuid() (euid int)
  14. //sysnb Getgid() (gid int)
  15. //sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
  16. //sysnb Getuid() (uid int)
  17. //sys Lchown(path string, uid int, gid int) (err error)
  18. //sys Listen(s int, n int) (err error)
  19. //sys Pause() (err error)
  20. //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
  21. //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
  22. //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
  23. func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
  24. ts := Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000}
  25. return Pselect(nfd, r, w, e, &ts, nil)
  26. }
  27. //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
  28. //sys Setfsgid(gid int) (err error)
  29. //sys Setfsuid(uid int) (err error)
  30. //sysnb Setregid(rgid int, egid int) (err error)
  31. //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
  32. //sysnb Setresuid(ruid int, euid int, suid int) (err error)
  33. //sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
  34. //sysnb Setreuid(ruid int, euid int) (err error)
  35. //sys Shutdown(fd int, how int) (err error)
  36. //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
  37. //sys Statfs(path string, buf *Statfs_t) (err error)
  38. //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
  39. //sys Truncate(path string, length int64) (err error)
  40. //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
  41. //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
  42. //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
  43. //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
  44. //sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
  45. //sysnb setgroups(n int, list *_Gid_t) (err error)
  46. //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
  47. //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
  48. //sysnb socket(domain int, typ int, proto int) (fd int, err error)
  49. //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
  50. //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
  51. //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
  52. //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
  53. //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
  54. //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
  55. //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
  56. //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
  57. //sysnb Gettimeofday(tv *Timeval) (err error)
  58. func Time(t *Time_t) (tt Time_t, err error) {
  59. var tv Timeval
  60. err = Gettimeofday(&tv)
  61. if err != nil {
  62. return 0, err
  63. }
  64. if t != nil {
  65. *t = Time_t(tv.Sec)
  66. }
  67. return Time_t(tv.Sec), nil
  68. }
  69. //sys Utime(path string, buf *Utimbuf) (err error)
  70. func setTimespec(sec, nsec int64) Timespec {
  71. return Timespec{Sec: sec, Nsec: nsec}
  72. }
  73. func setTimeval(sec, usec int64) Timeval {
  74. return Timeval{Sec: sec, Usec: usec}
  75. }
  76. func Pipe(p []int) (err error) {
  77. if len(p) != 2 {
  78. return EINVAL
  79. }
  80. var pp [2]_C_int
  81. err = pipe2(&pp, 0)
  82. p[0] = int(pp[0])
  83. p[1] = int(pp[1])
  84. return
  85. }
  86. //sysnb pipe2(p *[2]_C_int, flags int) (err error)
  87. func Pipe2(p []int, flags int) (err error) {
  88. if len(p) != 2 {
  89. return EINVAL
  90. }
  91. var pp [2]_C_int
  92. err = pipe2(&pp, flags)
  93. p[0] = int(pp[0])
  94. p[1] = int(pp[1])
  95. return
  96. }
  97. func Ioperm(from int, num int, on int) (err error) {
  98. return ENOSYS
  99. }
  100. func Iopl(level int) (err error) {
  101. return ENOSYS
  102. }
  103. type stat_t struct {
  104. Dev uint32
  105. Pad0 [3]int32
  106. Ino uint64
  107. Mode uint32
  108. Nlink uint32
  109. Uid uint32
  110. Gid uint32
  111. Rdev uint32
  112. Pad1 [3]uint32
  113. Size int64
  114. Atime uint32
  115. Atime_nsec uint32
  116. Mtime uint32
  117. Mtime_nsec uint32
  118. Ctime uint32
  119. Ctime_nsec uint32
  120. Blksize uint32
  121. Pad2 uint32
  122. Blocks int64
  123. }
  124. //sys fstat(fd int, st *stat_t) (err error)
  125. //sys lstat(path string, st *stat_t) (err error)
  126. //sys stat(path string, st *stat_t) (err error)
  127. func Fstat(fd int, s *Stat_t) (err error) {
  128. st := &stat_t{}
  129. err = fstat(fd, st)
  130. fillStat_t(s, st)
  131. return
  132. }
  133. func Lstat(path string, s *Stat_t) (err error) {
  134. st := &stat_t{}
  135. err = lstat(path, st)
  136. fillStat_t(s, st)
  137. return
  138. }
  139. func Stat(path string, s *Stat_t) (err error) {
  140. st := &stat_t{}
  141. err = stat(path, st)
  142. fillStat_t(s, st)
  143. return
  144. }
  145. func fillStat_t(s *Stat_t, st *stat_t) {
  146. s.Dev = st.Dev
  147. s.Ino = st.Ino
  148. s.Mode = st.Mode
  149. s.Nlink = st.Nlink
  150. s.Uid = st.Uid
  151. s.Gid = st.Gid
  152. s.Rdev = st.Rdev
  153. s.Size = st.Size
  154. s.Atim = Timespec{int64(st.Atime), int64(st.Atime_nsec)}
  155. s.Mtim = Timespec{int64(st.Mtime), int64(st.Mtime_nsec)}
  156. s.Ctim = Timespec{int64(st.Ctime), int64(st.Ctime_nsec)}
  157. s.Blksize = st.Blksize
  158. s.Blocks = st.Blocks
  159. }
  160. func (r *PtraceRegs) PC() uint64 { return r.Epc }
  161. func (r *PtraceRegs) SetPC(pc uint64) { r.Epc = pc }
  162. func (iov *Iovec) SetLen(length int) {
  163. iov.Len = uint64(length)
  164. }
  165. func (msghdr *Msghdr) SetControllen(length int) {
  166. msghdr.Controllen = uint64(length)
  167. }
  168. func (cmsg *Cmsghdr) SetLen(length int) {
  169. cmsg.Len = uint64(length)
  170. }
  171. //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
  172. func Poll(fds []PollFd, timeout int) (n int, err error) {
  173. if len(fds) == 0 {
  174. return poll(nil, 0, timeout)
  175. }
  176. return poll(&fds[0], len(fds), timeout)
  177. }