Source file src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go
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 5 //go:build arm64 && linux 6 // +build arm64,linux 7 8 package unix 9 10 import "unsafe" 11 12 //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT 13 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 14 //sys Fchown(fd int, uid int, gid int) (err error) 15 //sys Fstat(fd int, stat *Stat_t) (err error) 16 //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 17 //sys Fstatfs(fd int, buf *Statfs_t) (err error) 18 //sys Ftruncate(fd int, length int64) (err error) 19 //sysnb Getegid() (egid int) 20 //sysnb Geteuid() (euid int) 21 //sysnb Getgid() (gid int) 22 //sysnb getrlimit(resource int, rlim *Rlimit) (err error) 23 //sysnb Getuid() (uid int) 24 //sys Listen(s int, n int) (err error) 25 //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 26 //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 27 //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) 28 //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 29 30 func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { 31 var ts *Timespec 32 if timeout != nil { 33 ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000} 34 } 35 return Pselect(nfd, r, w, e, ts, nil) 36 } 37 38 //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 39 //sys setfsgid(gid int) (prev int, err error) 40 //sys setfsuid(uid int) (prev int, err error) 41 //sysnb Setregid(rgid int, egid int) (err error) 42 //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 43 //sysnb Setresuid(ruid int, euid int, suid int) (err error) 44 //sysnb setrlimit(resource int, rlim *Rlimit) (err error) 45 //sysnb Setreuid(ruid int, euid int) (err error) 46 //sys Shutdown(fd int, how int) (err error) 47 //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 48 49 func Stat(path string, stat *Stat_t) (err error) { 50 return Fstatat(AT_FDCWD, path, stat, 0) 51 } 52 53 func Lchown(path string, uid int, gid int) (err error) { 54 return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW) 55 } 56 57 func Lstat(path string, stat *Stat_t) (err error) { 58 return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW) 59 } 60 61 //sys Statfs(path string, buf *Statfs_t) (err error) 62 //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 63 //sys Truncate(path string, length int64) (err error) 64 65 func Ustat(dev int, ubuf *Ustat_t) (err error) { 66 return ENOSYS 67 } 68 69 //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 70 //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 71 //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 72 //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 73 //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 74 //sysnb setgroups(n int, list *_Gid_t) (err error) 75 //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 76 //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 77 //sysnb socket(domain int, typ int, proto int) (fd int, err error) 78 //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 79 //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 80 //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 81 //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 82 //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 83 //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 84 //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 85 //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 86 87 //sysnb Gettimeofday(tv *Timeval) (err error) 88 89 func setTimespec(sec, nsec int64) Timespec { 90 return Timespec{Sec: sec, Nsec: nsec} 91 } 92 93 func setTimeval(sec, usec int64) Timeval { 94 return Timeval{Sec: sec, Usec: usec} 95 } 96 97 func futimesat(dirfd int, path string, tv *[2]Timeval) (err error) { 98 if tv == nil { 99 return utimensat(dirfd, path, nil, 0) 100 } 101 102 ts := []Timespec{ 103 NsecToTimespec(TimevalToNsec(tv[0])), 104 NsecToTimespec(TimevalToNsec(tv[1])), 105 } 106 return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) 107 } 108 109 func Time(t *Time_t) (Time_t, error) { 110 var tv Timeval 111 err := Gettimeofday(&tv) 112 if err != nil { 113 return 0, err 114 } 115 if t != nil { 116 *t = Time_t(tv.Sec) 117 } 118 return Time_t(tv.Sec), nil 119 } 120 121 func Utime(path string, buf *Utimbuf) error { 122 tv := []Timeval{ 123 {Sec: buf.Actime}, 124 {Sec: buf.Modtime}, 125 } 126 return Utimes(path, tv) 127 } 128 129 func utimes(path string, tv *[2]Timeval) (err error) { 130 if tv == nil { 131 return utimensat(AT_FDCWD, path, nil, 0) 132 } 133 134 ts := []Timespec{ 135 NsecToTimespec(TimevalToNsec(tv[0])), 136 NsecToTimespec(TimevalToNsec(tv[1])), 137 } 138 return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) 139 } 140 141 // Getrlimit prefers the prlimit64 system call. See issue 38604. 142 func Getrlimit(resource int, rlim *Rlimit) error { 143 err := Prlimit(0, resource, nil, rlim) 144 if err != ENOSYS { 145 return err 146 } 147 return getrlimit(resource, rlim) 148 } 149 150 // Setrlimit prefers the prlimit64 system call. See issue 38604. 151 func Setrlimit(resource int, rlim *Rlimit) error { 152 err := Prlimit(0, resource, rlim, nil) 153 if err != ENOSYS { 154 return err 155 } 156 return setrlimit(resource, rlim) 157 } 158 159 func (r *PtraceRegs) PC() uint64 { return r.Pc } 160 161 func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc } 162 163 func (iov *Iovec) SetLen(length int) { 164 iov.Len = uint64(length) 165 } 166 167 func (msghdr *Msghdr) SetControllen(length int) { 168 msghdr.Controllen = uint64(length) 169 } 170 171 func (msghdr *Msghdr) SetIovlen(length int) { 172 msghdr.Iovlen = uint64(length) 173 } 174 175 func (cmsg *Cmsghdr) SetLen(length int) { 176 cmsg.Len = uint64(length) 177 } 178 179 func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) { 180 rsa.Service_name_len = uint64(length) 181 } 182 183 func Pause() error { 184 _, err := ppoll(nil, 0, nil, nil) 185 return err 186 } 187 188 //sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) 189 190 func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { 191 cmdlineLen := len(cmdline) 192 if cmdlineLen > 0 { 193 // Account for the additional NULL byte added by 194 // BytePtrFromString in kexecFileLoad. The kexec_file_load 195 // syscall expects a NULL-terminated string. 196 cmdlineLen++ 197 } 198 return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) 199 } 200