github.com/sean-/go@v0.0.0-20151219100004-97f854cd7bb6/src/syscall/syscall_linux_mips64x.go (about) 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 // +build linux 6 // +build mips64 mips64le 7 8 package syscall 9 10 const ( 11 _SYS_dup = SYS_DUP2 12 13 // Linux introduced getdents64 syscall for N64 ABI only in 3.10 14 // (May 21 2013, rev dec33abaafc89bcbd78f85fad0513170415a26d5), 15 // to support older kernels, we have to use getdents for mips64. 16 // Also note that struct dirent is different for these two. 17 // Lookup linux_dirent{,64} in kernel source code for details. 18 _SYS_getdents = SYS_GETDENTS 19 ) 20 21 //sys Dup2(oldfd int, newfd int) (err error) 22 //sys Fchown(fd int, uid int, gid int) (err error) 23 //sys Fstatfs(fd int, buf *Statfs_t) (err error) 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 Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 34 //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 35 //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 36 //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS_PSELECT6 37 //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 38 //sys Setfsgid(gid int) (err error) 39 //sys Setfsuid(uid int) (err error) 40 //sysnb Setregid(rgid int, egid int) (err error) 41 //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 42 //sysnb Setresuid(ruid int, euid int, suid int) (err error) 43 //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 44 //sysnb Setreuid(ruid int, euid int) (err error) 45 //sys Shutdown(fd int, how int) (err error) 46 //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 47 //sys Statfs(path string, buf *Statfs_t) (err error) 48 //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 49 //sys Truncate(path string, length int64) (err error) 50 //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 51 //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 52 //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 53 //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 54 //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 55 //sysnb setgroups(n int, list *_Gid_t) (err error) 56 //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 57 //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 58 //sysnb socket(domain int, typ int, proto int) (fd int, err error) 59 //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 60 //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 61 //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 62 //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 63 //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 64 //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 65 //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 66 //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 67 68 func Getpagesize() int { return 65536 } 69 70 //sysnb Gettimeofday(tv *Timeval) (err error) 71 72 func Time(t *Time_t) (tt Time_t, err error) { 73 var tv Timeval 74 err = Gettimeofday(&tv) 75 if err != nil { 76 return 0, err 77 } 78 if t != nil { 79 *t = Time_t(tv.Sec) 80 } 81 return Time_t(tv.Sec), nil 82 } 83 84 func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 85 86 func NsecToTimespec(nsec int64) (ts Timespec) { 87 ts.Sec = nsec / 1e9 88 ts.Nsec = nsec % 1e9 89 return 90 } 91 92 func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 93 94 func NsecToTimeval(nsec int64) (tv Timeval) { 95 nsec += 999 // round up to microsecond 96 tv.Sec = nsec / 1e9 97 tv.Usec = nsec % 1e9 / 1e3 98 return 99 } 100 101 func Pipe(p []int) (err error) { 102 if len(p) != 2 { 103 return EINVAL 104 } 105 var pp [2]_C_int 106 err = pipe2(&pp, 0) 107 p[0] = int(pp[0]) 108 p[1] = int(pp[1]) 109 return 110 } 111 112 //sysnb pipe2(p *[2]_C_int, flags int) (err error) 113 114 func Pipe2(p []int, flags int) (err error) { 115 if len(p) != 2 { 116 return EINVAL 117 } 118 var pp [2]_C_int 119 err = pipe2(&pp, flags) 120 p[0] = int(pp[0]) 121 p[1] = int(pp[1]) 122 return 123 } 124 125 func Ioperm(from int, num int, on int) (err error) { 126 return ENOSYS 127 } 128 129 func Iopl(level int) (err error) { 130 return ENOSYS 131 } 132 133 type stat_t struct { 134 Dev uint32 135 Pad0 [3]int32 136 Ino uint64 137 Mode uint32 138 Nlink uint32 139 Uid uint32 140 Gid uint32 141 Rdev uint32 142 Pad1 [3]uint32 143 Size int64 144 Atime uint32 145 Atime_nsec uint32 146 Mtime uint32 147 Mtime_nsec uint32 148 Ctime uint32 149 Ctime_nsec uint32 150 Blksize uint32 151 Pad2 uint32 152 Blocks int64 153 } 154 155 //sys fstat(fd int, st *stat_t) (err error) 156 //sys lstat(path string, st *stat_t) (err error) 157 //sys stat(path string, st *stat_t) (err error) 158 159 func Fstat(fd int, s *Stat_t) (err error) { 160 st := &stat_t{} 161 err = fstat(fd, st) 162 fillStat_t(s, st) 163 return 164 } 165 166 func Lstat(path string, s *Stat_t) (err error) { 167 st := &stat_t{} 168 err = lstat(path, st) 169 fillStat_t(s, st) 170 return 171 } 172 173 func Stat(path string, s *Stat_t) (err error) { 174 st := &stat_t{} 175 err = stat(path, st) 176 fillStat_t(s, st) 177 return 178 } 179 180 func fillStat_t(s *Stat_t, st *stat_t) { 181 s.Dev = st.Dev 182 s.Ino = st.Ino 183 s.Mode = st.Mode 184 s.Nlink = st.Nlink 185 s.Uid = st.Uid 186 s.Gid = st.Gid 187 s.Rdev = st.Rdev 188 s.Size = st.Size 189 s.Atim = Timespec{int64(st.Atime), int64(st.Atime_nsec)} 190 s.Mtim = Timespec{int64(st.Mtime), int64(st.Mtime_nsec)} 191 s.Ctim = Timespec{int64(st.Ctime), int64(st.Ctime_nsec)} 192 s.Blksize = st.Blksize 193 s.Blocks = st.Blocks 194 } 195 196 func (r *PtraceRegs) PC() uint64 { return r.Regs[64] } 197 198 func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = pc } 199 200 func (iov *Iovec) SetLen(length int) { 201 iov.Len = uint64(length) 202 } 203 204 func (msghdr *Msghdr) SetControllen(length int) { 205 msghdr.Controllen = uint64(length) 206 } 207 208 func (cmsg *Cmsghdr) SetLen(length int) { 209 cmsg.Len = uint64(length) 210 }