Source file src/syscall/syscall_linux_arm64.go

Documentation: syscall

     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_dup       = SYS_DUP3
    11  	_SYS_setgroups = SYS_SETGROUPS
    12  )
    13  
    14  func EpollCreate(size int) (fd int, err error) {
    15  	if size <= 0 {
    16  		return -1, EINVAL
    17  	}
    18  	return EpollCreate1(0)
    19  }
    20  
    21  //sys	EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT
    22  //sys	Fchown(fd int, uid int, gid int) (err error)
    23  //sys	Fstat(fd int, stat *Stat_t) (err error)
    24  //sys	Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
    25  //sys	fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error)
    26  //sys	Fstatfs(fd int, buf *Statfs_t) (err error)
    27  //sys	Ftruncate(fd int, length int64) (err error)
    28  //sysnb	Getegid() (egid int)
    29  //sysnb	Geteuid() (euid int)
    30  //sysnb	Getgid() (gid int)
    31  //sysnb	Getrlimit(resource int, rlim *Rlimit) (err error)
    32  //sysnb	Getuid() (uid int)
    33  //sys	Listen(s int, n int) (err error)
    34  //sys	Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
    35  //sys	Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
    36  //sys	Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
    37  //sys	Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
    38  //sys	sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
    39  //sys	Setfsgid(gid int) (err error)
    40  //sys	Setfsuid(uid 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) = SYS_SYNC_FILE_RANGE2
    63  //sys	Truncate(path string, length int64) (err error)
    64  //sys	accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
    65  //sys	accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
    66  //sys	bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    67  //sys	connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    68  //sysnb	getgroups(n int, list *_Gid_t) (nn int, err error)
    69  //sysnb	setgroups(n int, list *_Gid_t) (err error)
    70  //sys	getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
    71  //sys	setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
    72  //sysnb	socket(domain int, typ int, proto int) (fd int, err error)
    73  //sysnb	socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
    74  //sysnb	getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    75  //sysnb	getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    76  //sys	recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
    77  //sys	sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
    78  //sys	recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
    79  //sys	sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
    80  //sys	mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
    81  
    82  type sigset_t struct {
    83  	X__val [16]uint64
    84  }
    85  
    86  //sys	pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *sigset_t) (n int, err error) = SYS_PSELECT6
    87  
    88  func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
    89  	var ts *Timespec
    90  	if timeout != nil {
    91  		ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000}
    92  	}
    93  	return pselect(nfd, r, w, e, ts, nil)
    94  }
    95  
    96  //sysnb	Gettimeofday(tv *Timeval) (err error)
    97  
    98  func setTimespec(sec, nsec int64) Timespec {
    99  	return Timespec{Sec: sec, Nsec: nsec}
   100  }
   101  
   102  func setTimeval(sec, usec int64) Timeval {
   103  	return Timeval{Sec: sec, Usec: usec}
   104  }
   105  
   106  func futimesat(dirfd int, path string, tv *[2]Timeval) (err error) {
   107  	if tv == nil {
   108  		return utimensat(dirfd, path, nil, 0)
   109  	}
   110  
   111  	ts := []Timespec{
   112  		NsecToTimespec(TimevalToNsec(tv[0])),
   113  		NsecToTimespec(TimevalToNsec(tv[1])),
   114  	}
   115  	return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
   116  }
   117  
   118  func Time(t *Time_t) (Time_t, error) {
   119  	var tv Timeval
   120  	err := Gettimeofday(&tv)
   121  	if err != nil {
   122  		return 0, err
   123  	}
   124  	if t != nil {
   125  		*t = Time_t(tv.Sec)
   126  	}
   127  	return Time_t(tv.Sec), nil
   128  }
   129  
   130  func Utime(path string, buf *Utimbuf) error {
   131  	tv := []Timeval{
   132  		{Sec: buf.Actime},
   133  		{Sec: buf.Modtime},
   134  	}
   135  	return Utimes(path, tv)
   136  }
   137  
   138  func utimes(path string, tv *[2]Timeval) (err error) {
   139  	if tv == nil {
   140  		return utimensat(_AT_FDCWD, path, nil, 0)
   141  	}
   142  
   143  	ts := []Timespec{
   144  		NsecToTimespec(TimevalToNsec(tv[0])),
   145  		NsecToTimespec(TimevalToNsec(tv[1])),
   146  	}
   147  	return utimensat(_AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
   148  }
   149  
   150  func Pipe(p []int) (err error) {
   151  	if len(p) != 2 {
   152  		return EINVAL
   153  	}
   154  	var pp [2]_C_int
   155  	err = pipe2(&pp, 0)
   156  	p[0] = int(pp[0])
   157  	p[1] = int(pp[1])
   158  	return
   159  }
   160  
   161  //sysnb pipe2(p *[2]_C_int, flags int) (err error)
   162  
   163  func Pipe2(p []int, flags int) (err error) {
   164  	if len(p) != 2 {
   165  		return EINVAL
   166  	}
   167  	var pp [2]_C_int
   168  	err = pipe2(&pp, flags)
   169  	p[0] = int(pp[0])
   170  	p[1] = int(pp[1])
   171  	return
   172  }
   173  
   174  func (r *PtraceRegs) PC() uint64 { return r.Pc }
   175  
   176  func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc }
   177  
   178  func (iov *Iovec) SetLen(length int) {
   179  	iov.Len = uint64(length)
   180  }
   181  
   182  func (msghdr *Msghdr) SetControllen(length int) {
   183  	msghdr.Controllen = uint64(length)
   184  }
   185  
   186  func (cmsg *Cmsghdr) SetLen(length int) {
   187  	cmsg.Len = uint64(length)
   188  }
   189  
   190  func InotifyInit() (fd int, err error) {
   191  	return InotifyInit1(0)
   192  }
   193  
   194  //sys	ppoll(fds *pollFd, nfds int, timeout *Timespec, sigmask *sigset_t) (n int, err error)
   195  
   196  func Pause() error {
   197  	_, err := ppoll(nil, 0, nil, nil)
   198  	return err
   199  }
   200  
   201  func rawVforkSyscall(trap, a1 uintptr) (r1 uintptr, err Errno)
   202  

View as plain text