syscall_linux_mips64x.go 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT
  13. //sys Fstatfs(fd int, buf *Statfs_t) (err error)
  14. //sys Ftruncate(fd int, length int64) (err error)
  15. //sysnb Getegid() (egid int)
  16. //sysnb Geteuid() (euid int)
  17. //sysnb Getgid() (gid int)
  18. //sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
  19. //sysnb Getuid() (uid int)
  20. //sys Lchown(path string, uid int, gid int) (err error)
  21. //sys Listen(s int, n int) (err error)
  22. //sys Pause() (err error)
  23. //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
  24. //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
  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 lstat(path string, st *stat_t) (err error)
  135. //sys stat(path string, st *stat_t) (err error)
  136. func Fstat(fd int, s *Stat_t) (err error) {
  137. st := &stat_t{}
  138. err = fstat(fd, st)
  139. fillStat_t(s, st)
  140. return
  141. }
  142. func Lstat(path string, s *Stat_t) (err error) {
  143. st := &stat_t{}
  144. err = lstat(path, st)
  145. fillStat_t(s, st)
  146. return
  147. }
  148. func Stat(path string, s *Stat_t) (err error) {
  149. st := &stat_t{}
  150. err = stat(path, st)
  151. fillStat_t(s, st)
  152. return
  153. }
  154. func fillStat_t(s *Stat_t, st *stat_t) {
  155. s.Dev = st.Dev
  156. s.Ino = st.Ino
  157. s.Mode = st.Mode
  158. s.Nlink = st.Nlink
  159. s.Uid = st.Uid
  160. s.Gid = st.Gid
  161. s.Rdev = st.Rdev
  162. s.Size = st.Size
  163. s.Atim = Timespec{int64(st.Atime), int64(st.Atime_nsec)}
  164. s.Mtim = Timespec{int64(st.Mtime), int64(st.Mtime_nsec)}
  165. s.Ctim = Timespec{int64(st.Ctime), int64(st.Ctime_nsec)}
  166. s.Blksize = st.Blksize
  167. s.Blocks = st.Blocks
  168. }
  169. func (r *PtraceRegs) PC() uint64 { return r.Epc }
  170. func (r *PtraceRegs) SetPC(pc uint64) { r.Epc = pc }
  171. func (iov *Iovec) SetLen(length int) {
  172. iov.Len = uint64(length)
  173. }
  174. func (msghdr *Msghdr) SetControllen(length int) {
  175. msghdr.Controllen = uint64(length)
  176. }
  177. func (cmsg *Cmsghdr) SetLen(length int) {
  178. cmsg.Len = uint64(length)
  179. }
  180. //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
  181. func Poll(fds []PollFd, timeout int) (n int, err error) {
  182. if len(fds) == 0 {
  183. return poll(nil, 0, timeout)
  184. }
  185. return poll(&fds[0], len(fds), timeout)
  186. }