khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame] | 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 | |
khenaidoo | d948f77 | 2021-08-11 17:49:24 -0400 | [diff] [blame^] | 5 | //go:build sparc64 && linux |
khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame] | 6 | // +build sparc64,linux |
| 7 | |
| 8 | package unix |
| 9 | |
| 10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) |
| 11 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 |
Andrea Campanella | 3614a92 | 2021-02-25 12:40:42 +0100 | [diff] [blame] | 12 | //sys dup2(oldfd int, newfd int) (err error) |
khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame] | 13 | //sys Fchown(fd int, uid int, gid int) (err error) |
| 14 | //sys Fstat(fd int, stat *Stat_t) (err error) |
| 15 | //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 |
| 16 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) |
| 17 | //sys Ftruncate(fd int, length int64) (err error) |
| 18 | //sysnb Getegid() (egid int) |
| 19 | //sysnb Geteuid() (euid int) |
| 20 | //sysnb Getgid() (gid int) |
| 21 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) |
| 22 | //sysnb Getuid() (uid int) |
| 23 | //sysnb InotifyInit() (fd int, err error) |
| 24 | //sys Lchown(path string, uid int, gid int) (err error) |
| 25 | //sys Listen(s int, n int) (err error) |
| 26 | //sys Lstat(path string, stat *Stat_t) (err error) |
| 27 | //sys Pause() (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 |
Stephane Barbarie | 260a563 | 2019-02-26 16:12:49 -0500 | [diff] [blame] | 30 | //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) |
khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame] | 31 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK |
| 32 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) |
| 33 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) |
Andrea Campanella | 3614a92 | 2021-02-25 12:40:42 +0100 | [diff] [blame] | 34 | //sys setfsgid(gid int) (prev int, err error) |
| 35 | //sys setfsuid(uid int) (prev int, err error) |
khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame] | 36 | //sysnb Setregid(rgid int, egid int) (err error) |
| 37 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) |
| 38 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) |
| 39 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) |
| 40 | //sysnb Setreuid(ruid int, euid int) (err error) |
| 41 | //sys Shutdown(fd int, how int) (err error) |
| 42 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) |
| 43 | //sys Stat(path string, stat *Stat_t) (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 accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, 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 | //sysnb setgroups(n int, list *_Gid_t) (err error) |
| 53 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) |
| 54 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) |
| 55 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) |
| 56 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) |
| 57 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) |
| 58 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) |
| 59 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) |
| 60 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) |
| 61 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) |
| 62 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) |
| 63 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) |
| 64 | |
| 65 | func Ioperm(from int, num int, on int) (err error) { |
| 66 | return ENOSYS |
| 67 | } |
| 68 | |
| 69 | func Iopl(level int) (err error) { |
| 70 | return ENOSYS |
| 71 | } |
| 72 | |
| 73 | //sys futimesat(dirfd int, path string, times *[2]Timeval) (err error) |
| 74 | //sysnb Gettimeofday(tv *Timeval) (err error) |
| 75 | |
| 76 | func Time(t *Time_t) (tt Time_t, err error) { |
| 77 | var tv Timeval |
| 78 | err = Gettimeofday(&tv) |
| 79 | if err != nil { |
| 80 | return 0, err |
| 81 | } |
| 82 | if t != nil { |
| 83 | *t = Time_t(tv.Sec) |
| 84 | } |
| 85 | return Time_t(tv.Sec), nil |
| 86 | } |
| 87 | |
| 88 | //sys Utime(path string, buf *Utimbuf) (err error) |
| 89 | //sys utimes(path string, times *[2]Timeval) (err error) |
| 90 | |
| 91 | func setTimespec(sec, nsec int64) Timespec { |
| 92 | return Timespec{Sec: sec, Nsec: nsec} |
| 93 | } |
| 94 | |
| 95 | func setTimeval(sec, usec int64) Timeval { |
| 96 | return Timeval{Sec: sec, Usec: int32(usec)} |
| 97 | } |
| 98 | |
| 99 | func (r *PtraceRegs) PC() uint64 { return r.Tpc } |
| 100 | |
| 101 | func (r *PtraceRegs) SetPC(pc uint64) { r.Tpc = pc } |
| 102 | |
| 103 | func (iov *Iovec) SetLen(length int) { |
| 104 | iov.Len = uint64(length) |
| 105 | } |
| 106 | |
| 107 | func (msghdr *Msghdr) SetControllen(length int) { |
| 108 | msghdr.Controllen = uint64(length) |
| 109 | } |
| 110 | |
Scott Baker | 8461e15 | 2019-10-01 14:44:30 -0700 | [diff] [blame] | 111 | func (msghdr *Msghdr) SetIovlen(length int) { |
| 112 | msghdr.Iovlen = uint64(length) |
| 113 | } |
| 114 | |
khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame] | 115 | func (cmsg *Cmsghdr) SetLen(length int) { |
| 116 | cmsg.Len = uint64(length) |
| 117 | } |
| 118 | |
khenaidoo | d948f77 | 2021-08-11 17:49:24 -0400 | [diff] [blame^] | 119 | func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) { |
| 120 | rsa.Service_name_len = uint64(length) |
| 121 | } |
| 122 | |
| 123 | //sysnb pipe(p *[2]_C_int) (err error) |
khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame] | 124 | |
| 125 | func Pipe(p []int) (err error) { |
| 126 | if len(p) != 2 { |
| 127 | return EINVAL |
| 128 | } |
| 129 | var pp [2]_C_int |
| 130 | err = pipe(&pp) |
| 131 | p[0] = int(pp[0]) |
| 132 | p[1] = int(pp[1]) |
| 133 | return |
| 134 | } |
| 135 | |
khenaidoo | d948f77 | 2021-08-11 17:49:24 -0400 | [diff] [blame^] | 136 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) |
khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame] | 137 | |
| 138 | func Pipe2(p []int, flags int) (err error) { |
| 139 | if len(p) != 2 { |
| 140 | return EINVAL |
| 141 | } |
| 142 | var pp [2]_C_int |
| 143 | err = pipe2(&pp, flags) |
| 144 | p[0] = int(pp[0]) |
| 145 | p[1] = int(pp[1]) |
| 146 | return |
| 147 | } |
| 148 | |
| 149 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) |
| 150 | |
| 151 | func Poll(fds []PollFd, timeout int) (n int, err error) { |
| 152 | if len(fds) == 0 { |
| 153 | return poll(nil, 0, timeout) |
| 154 | } |
| 155 | return poll(&fds[0], len(fds), timeout) |
| 156 | } |