syscall_linux_mips64x.go 6.1 KB

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