Source file src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go
1 // Copyright 2016 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 && (mips || mipsle) 6 // +build linux 7 // +build mips mipsle 8 9 package unix 10 11 import ( 12 "syscall" 13 "unsafe" 14 ) 15 16 func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 17 18 //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 19 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 20 //sys Fchown(fd int, uid int, gid int) (err error) 21 //sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64 22 //sysnb Getegid() (egid int) 23 //sysnb Geteuid() (euid int) 24 //sysnb Getgid() (gid int) 25 //sysnb Getuid() (uid int) 26 //sys Lchown(path string, uid int, gid int) (err error) 27 //sys Listen(s int, n int) (err error) 28 //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 29 //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 30 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) 31 //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT 32 //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64 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 Setreuid(ruid int, euid int) (err error) 39 //sys Shutdown(fd int, how int) (err error) 40 //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) 41 //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 42 //sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64 43 //sys Ustat(dev int, ubuf *Ustat_t) (err error) 44 //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 45 //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 46 //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 47 //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 48 //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 49 //sysnb setgroups(n int, list *_Gid_t) (err error) 50 //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 51 //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 52 //sysnb socket(domain int, typ int, proto int) (fd int, err error) 53 //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 54 //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 55 //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 56 //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 57 //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 58 //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 59 //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 60 61 //sys Ioperm(from int, num int, on int) (err error) 62 //sys Iopl(level int) (err error) 63 64 //sys futimesat(dirfd int, path string, times *[2]Timeval) (err error) 65 //sysnb Gettimeofday(tv *Timeval) (err error) 66 //sysnb Time(t *Time_t) (tt Time_t, err error) 67 //sys Utime(path string, buf *Utimbuf) (err error) 68 //sys utimes(path string, times *[2]Timeval) (err error) 69 70 //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 71 //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 72 //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 73 //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 74 75 //sys Pause() (err error) 76 77 func Fstatfs(fd int, buf *Statfs_t) (err error) { 78 _, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf))) 79 if e != 0 { 80 err = errnoErr(e) 81 } 82 return 83 } 84 85 func Statfs(path string, buf *Statfs_t) (err error) { 86 p, err := BytePtrFromString(path) 87 if err != nil { 88 return err 89 } 90 _, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(p)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf))) 91 if e != 0 { 92 err = errnoErr(e) 93 } 94 return 95 } 96 97 func Seek(fd int, offset int64, whence int) (off int64, err error) { 98 _, _, e := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offset>>32), uintptr(offset), uintptr(unsafe.Pointer(&off)), uintptr(whence), 0) 99 if e != 0 { 100 err = errnoErr(e) 101 } 102 return 103 } 104 105 func setTimespec(sec, nsec int64) Timespec { 106 return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 107 } 108 109 func setTimeval(sec, usec int64) Timeval { 110 return Timeval{Sec: int32(sec), Usec: int32(usec)} 111 } 112 113 //sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) 114 115 func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { 116 page := uintptr(offset / 4096) 117 if offset != int64(page)*4096 { 118 return 0, EINVAL 119 } 120 return mmap2(addr, length, prot, flags, fd, page) 121 } 122 123 const rlimInf32 = ^uint32(0) 124 const rlimInf64 = ^uint64(0) 125 126 type rlimit32 struct { 127 Cur uint32 128 Max uint32 129 } 130 131 //sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_GETRLIMIT 132 133 func Getrlimit(resource int, rlim *Rlimit) (err error) { 134 err = Prlimit(0, resource, nil, rlim) 135 if err != ENOSYS { 136 return err 137 } 138 139 rl := rlimit32{} 140 err = getrlimit(resource, &rl) 141 if err != nil { 142 return 143 } 144 145 if rl.Cur == rlimInf32 { 146 rlim.Cur = rlimInf64 147 } else { 148 rlim.Cur = uint64(rl.Cur) 149 } 150 151 if rl.Max == rlimInf32 { 152 rlim.Max = rlimInf64 153 } else { 154 rlim.Max = uint64(rl.Max) 155 } 156 return 157 } 158 159 //sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT 160 161 func Setrlimit(resource int, rlim *Rlimit) (err error) { 162 err = Prlimit(0, resource, rlim, nil) 163 if err != ENOSYS { 164 return err 165 } 166 167 rl := rlimit32{} 168 if rlim.Cur == rlimInf64 { 169 rl.Cur = rlimInf32 170 } else if rlim.Cur < uint64(rlimInf32) { 171 rl.Cur = uint32(rlim.Cur) 172 } else { 173 return EINVAL 174 } 175 if rlim.Max == rlimInf64 { 176 rl.Max = rlimInf32 177 } else if rlim.Max < uint64(rlimInf32) { 178 rl.Max = uint32(rlim.Max) 179 } else { 180 return EINVAL 181 } 182 183 return setrlimit(resource, &rl) 184 } 185 186 func (r *PtraceRegs) PC() uint64 { return r.Epc } 187 188 func (r *PtraceRegs) SetPC(pc uint64) { r.Epc = pc } 189 190 func (iov *Iovec) SetLen(length int) { 191 iov.Len = uint32(length) 192 } 193 194 func (msghdr *Msghdr) SetControllen(length int) { 195 msghdr.Controllen = uint32(length) 196 } 197 198 func (msghdr *Msghdr) SetIovlen(length int) { 199 msghdr.Iovlen = uint32(length) 200 } 201 202 func (cmsg *Cmsghdr) SetLen(length int) { 203 cmsg.Len = uint32(length) 204 } 205 206 func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) { 207 rsa.Service_name_len = uint32(length) 208 } 209