syscall_linux_mips64x.go 6.2 KB

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