Source file src/syscall/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  package syscall
     6  
     7  import "unsafe"
     8  
     9  const (
    10  	_SYS_setgroups  = SYS_SETGROUPS
    11  	_SYS_clone3     = 435
    12  	_SYS_faccessat2 = 439
    13  	_SYS_fchmodat2  = 452
    14  )
    15  
    16  //sys	EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT
    17  //sys	Fchown(fd int, uid int, gid int) (err error)
    18  //sys	Fstat(fd int, stat *Stat_t) (err error)
    19  //sys	fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error)
    20  
    21  func Fstatat(fd int, path string, stat *Stat_t, flags int) error {
    22  	return fstatat(fd, path, stat, flags)
    23  }
    24  
    25  //sys	Fstatfs(fd int, buf *Statfs_t) (err error)
    26  //sys	Ftruncate(fd int, length int64) (err error)
    27  //sysnb	Getegid() (egid int)
    28  //sysnb	Geteuid() (euid int)
    29  //sysnb	Getgid() (gid int)
    30  //sysnb	getrlimit(resource int, rlim *Rlimit) (err error)
    31  //sysnb	Getuid() (uid int)
    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	Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
    36  //sys	Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
    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	setrlimit1(resource int, rlim *Rlimit) (err error) = SYS_SETRLIMIT
    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  
    44  func Stat(path string, stat *Stat_t) (err error) {
    45  	return fstatat(_AT_FDCWD, path, stat, 0)
    46  }
    47  
    48  func Lchown(path string, uid int, gid int) (err error) {
    49  	return Fchownat(_AT_FDCWD, path, uid, gid, _AT_SYMLINK_NOFOLLOW)
    50  }
    51  
    52  func Lstat(path string, stat *Stat_t) (err error) {
    53  	return fstatat(_AT_FDCWD, path, stat, _AT_SYMLINK_NOFOLLOW)
    54  }
    55  
    56  //sys	Statfs(path string, buf *Statfs_t) (err error)
    57  //sys	SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2
    58  //sys	Truncate(path string, length int64) (err error)
    59  //sys	accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
    60  //sys	bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    61  //sys	connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    62  //sysnb	getgroups(n int, list *_Gid_t) (nn int, err error)
    63  //sys	getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
    64  //sys	setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
    65  //sysnb	socket(domain int, typ int, proto int) (fd int, err error)
    66  //sysnb	socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
    67  //sysnb	getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    68  //sysnb	getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    69  //sys	recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
    70  //sys	sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
    71  //sys	recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
    72  //sys	sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
    73  //sys	mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
    74  
    75  type sigset_t struct {
    76  	X__val [16]uint64
    77  }
    78  
    79  //sys	pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *sigset_t) (n int, err error) = SYS_PSELECT6
    80  
    81  func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
    82  	var ts *Timespec
    83  	if timeout != nil {
    84  		ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000}
    85  	}
    86  	return pselect(nfd, r, w, e, ts, nil)
    87  }
    88  
    89  //sysnb	Gettimeofday(tv *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: usec}
    97  }
    98  
    99  func futimesat(dirfd int, path string, tv *[2]Timeval) (err error) {
   100  	if tv == nil {
   101  		return utimensat(dirfd, path, nil, 0)
   102  	}
   103  
   104  	ts := []Timespec{
   105  		NsecToTimespec(TimevalToNsec(tv[0])),
   106  		NsecToTimespec(TimevalToNsec(tv[1])),
   107  	}
   108  	return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
   109  }
   110  
   111  func Time(t *Time_t) (Time_t, error) {
   112  	var tv Timeval
   113  	err := Gettimeofday(&tv)
   114  	if err != nil {
   115  		return 0, err
   116  	}
   117  	if t != nil {
   118  		*t = Time_t(tv.Sec)
   119  	}
   120  	return Time_t(tv.Sec), nil
   121  }
   122  
   123  func Utime(path string, buf *Utimbuf) error {
   124  	tv := []Timeval{
   125  		{Sec: buf.Actime},
   126  		{Sec: buf.Modtime},
   127  	}
   128  	return Utimes(path, tv)
   129  }
   130  
   131  func utimes(path string, tv *[2]Timeval) (err error) {
   132  	if tv == nil {
   133  		return utimensat(_AT_FDCWD, path, nil, 0)
   134  	}
   135  
   136  	ts := []Timespec{
   137  		NsecToTimespec(TimevalToNsec(tv[0])),
   138  		NsecToTimespec(TimevalToNsec(tv[1])),
   139  	}
   140  	return utimensat(_AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
   141  }
   142  
   143  // Getrlimit prefers the prlimit64 system call. See issue 38604.
   144  func Getrlimit(resource int, rlim *Rlimit) error {
   145  	err := prlimit(0, resource, nil, rlim)
   146  	if err != ENOSYS {
   147  		return err
   148  	}
   149  	return getrlimit(resource, rlim)
   150  }
   151  
   152  // setrlimit prefers the prlimit64 system call. See issue 38604.
   153  func setrlimit(resource int, rlim *Rlimit) error {
   154  	err := prlimit(0, resource, rlim, nil)
   155  	if err != ENOSYS {
   156  		return err
   157  	}
   158  	return setrlimit1(resource, rlim)
   159  }
   160  
   161  //go:nosplit
   162  func rawSetrlimit(resource int, rlim *Rlimit) Errno {
   163  	_, _, errno := RawSyscall6(SYS_PRLIMIT64, 0, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0, 0, 0)
   164  	if errno != ENOSYS {
   165  		return errno
   166  	}
   167  	_, _, errno = RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
   168  	return errno
   169  }
   170  
   171  func (r *PtraceRegs) PC() uint64 { return r.Pc }
   172  
   173  func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc }
   174  
   175  func (iov *Iovec) SetLen(length int) {
   176  	iov.Len = uint64(length)
   177  }
   178  
   179  func (msghdr *Msghdr) SetControllen(length int) {
   180  	msghdr.Controllen = uint64(length)
   181  }
   182  
   183  func (cmsg *Cmsghdr) SetLen(length int) {
   184  	cmsg.Len = uint64(length)
   185  }
   186  
   187  func InotifyInit() (fd int, err error) {
   188  	return InotifyInit1(0)
   189  }
   190  
   191  //sys	ppoll(fds *pollFd, nfds int, timeout *Timespec, sigmask *sigset_t) (n int, err error)
   192  
   193  func Pause() error {
   194  	_, err := ppoll(nil, 0, nil, nil)
   195  	return err
   196  }
   197  

View as plain text