syscall_linux_mips64x.go 6.7 KB

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