Source file src/syscall/syscall_linux_mips64x.go
1 // Copyright 2009 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 5 //go:build linux && (mips64 || mips64le) 6 7 package syscall 8 9 import ( 10 "unsafe" 11 ) 12 13 const ( 14 _SYS_setgroups = SYS_SETGROUPS 15 _SYS_clone3 = 5435 16 _SYS_faccessat2 = 5439 17 _SYS_fchmodat2 = 5452 18 ) 19 20 //sys Dup2(oldfd int, newfd int) (err error) 21 //sys Fchown(fd int, uid int, gid int) (err error) 22 //sys Fstatfs(fd int, buf *Statfs_t) (err error) 23 //sys fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT 24 //sys Ftruncate(fd int, length int64) (err error) 25 //sysnb Getegid() (egid int) 26 //sysnb Geteuid() (euid int) 27 //sysnb Getgid() (gid int) 28 //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 29 //sysnb Getuid() (uid int) 30 //sysnb InotifyInit() (fd int, err error) 31 //sys Lchown(path string, uid int, gid int) (err error) 32 //sys Listen(s int, n int) (err error) 33 //sys Pause() (err error) 34 //sys pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 35 //sys pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 36 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) 37 //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 38 //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 39 //sys Setfsgid(gid int) (err error) 40 //sys Setfsuid(uid int) (err error) 41 //sysnb setrlimit(resource int, rlim *Rlimit) (err error) = SYS_SETRLIMIT 42 //sys Shutdown(fd int, how int) (err error) 43 //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 44 //sys Statfs(path string, buf *Statfs_t) (err error) 45 //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 46 //sys Truncate(path string, length int64) (err error) 47 //sys Ustat(dev int, ubuf *Ustat_t) (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 //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 EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 64 65 type sigset_t struct { 66 X__val [16]uint64 67 } 68 69 //sys pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *sigset_t) (n int, err error) = SYS_PSELECT6 70 71 func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { 72 var ts *Timespec 73 if timeout != nil { 74 ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000} 75 } 76 return pselect(nfd, r, w, e, ts, nil) 77 } 78 79 //sys futimesat(dirfd int, path string, times *[2]Timeval) (err error) 80 //sysnb Gettimeofday(tv *Timeval) (err error) 81 82 func Time(t *Time_t) (tt Time_t, err error) { 83 var tv Timeval 84 err = Gettimeofday(&tv) 85 if err != nil { 86 return 0, err 87 } 88 if t != nil { 89 *t = Time_t(tv.Sec) 90 } 91 return Time_t(tv.Sec), nil 92 } 93 94 //sys Utime(path string, buf *Utimbuf) (err error) 95 //sys utimes(path string, times *[2]Timeval) (err error) 96 97 //go:nosplit 98 func rawSetrlimit(resource int, rlim *Rlimit) Errno { 99 _, _, errno := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) 100 return errno 101 } 102 103 func setTimespec(sec, nsec int64) Timespec { 104 return Timespec{Sec: sec, Nsec: nsec} 105 } 106 107 func setTimeval(sec, usec int64) Timeval { 108 return Timeval{Sec: sec, Usec: usec} 109 } 110 111 func Ioperm(from int, num int, on int) (err error) { 112 return ENOSYS 113 } 114 115 func Iopl(level int) (err error) { 116 return ENOSYS 117 } 118 119 type stat_t struct { 120 Dev uint32 121 Pad0 [3]int32 122 Ino uint64 123 Mode uint32 124 Nlink uint32 125 Uid uint32 126 Gid uint32 127 Rdev uint32 128 Pad1 [3]uint32 129 Size int64 130 Atime uint32 131 Atime_nsec uint32 132 Mtime uint32 133 Mtime_nsec uint32 134 Ctime uint32 135 Ctime_nsec uint32 136 Blksize uint32 137 Pad2 uint32 138 Blocks int64 139 } 140 141 //sys fstat(fd int, st *stat_t) (err error) 142 //sys lstat(path string, st *stat_t) (err error) 143 //sys stat(path string, st *stat_t) (err error) 144 145 func Fstat(fd int, s *Stat_t) (err error) { 146 st := &stat_t{} 147 err = fstat(fd, st) 148 fillStat_t(s, st) 149 return 150 } 151 152 func Lstat(path string, s *Stat_t) (err error) { 153 st := &stat_t{} 154 err = lstat(path, st) 155 fillStat_t(s, st) 156 return 157 } 158 159 func Stat(path string, s *Stat_t) (err error) { 160 st := &stat_t{} 161 err = stat(path, st) 162 fillStat_t(s, st) 163 return 164 } 165 166 func fillStat_t(s *Stat_t, st *stat_t) { 167 s.Dev = st.Dev 168 s.Ino = st.Ino 169 s.Mode = st.Mode 170 s.Nlink = st.Nlink 171 s.Uid = st.Uid 172 s.Gid = st.Gid 173 s.Rdev = st.Rdev 174 s.Size = st.Size 175 s.Atim = Timespec{int64(st.Atime), int64(st.Atime_nsec)} 176 s.Mtim = Timespec{int64(st.Mtime), int64(st.Mtime_nsec)} 177 s.Ctim = Timespec{int64(st.Ctime), int64(st.Ctime_nsec)} 178 s.Blksize = st.Blksize 179 s.Blocks = st.Blocks 180 } 181 182 func (r *PtraceRegs) PC() uint64 { return r.Regs[64] } 183 184 func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = pc } 185 186 func (iov *Iovec) SetLen(length int) { 187 iov.Len = uint64(length) 188 } 189 190 func (msghdr *Msghdr) SetControllen(length int) { 191 msghdr.Controllen = uint64(length) 192 } 193 194 func (cmsg *Cmsghdr) SetLen(length int) { 195 cmsg.Len = uint64(length) 196 } 197