Source file src/syscall/syscall_linux_riscv64.go

     1  // Copyright 2019 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	Getuid() (uid int)
    31  //sys	Listen(s int, n int) (err error)
    32  //sys	pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
    33  //sys	pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
    34  //sys	renameat2(olddirfd int, oldpath string, newdirfd int, newpath string, flags uint) (err error)
    35  //sys	Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
    36  //sys	sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
    37  //sys	Setfsgid(gid int) (err error)
    38  //sys	Setfsuid(uid int) (err error)
    39  //sys	Shutdown(fd int, how int) (err error)
    40  //sys	Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
    41  
    42  func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
    43  	return renameat2(olddirfd, oldpath, newdirfd, newpath, 0)
    44  }
    45  
    46  func Stat(path string, stat *Stat_t) (err error) {
    47  	return fstatat(_AT_FDCWD, path, stat, 0)
    48  }
    49  
    50  func Lchown(path string, uid int, gid int) (err error) {
    51  	return Fchownat(_AT_FDCWD, path, uid, gid, _AT_SYMLINK_NOFOLLOW)
    52  }
    53  
    54  func Lstat(path string, stat *Stat_t) (err error) {
    55  	return fstatat(_AT_FDCWD, path, stat, _AT_SYMLINK_NOFOLLOW)
    56  }
    57  
    58  //sys	Statfs(path string, buf *Statfs_t) (err error)
    59  //sys	SyncFileRange(fd int, off int64, n int64, flags int) (err error)
    60  //sys	Truncate(path string, length int64) (err error)
    61  //sys	accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
    62  //sys	bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    63  //sys	connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    64  //sysnb	getgroups(n int, list *_Gid_t) (nn int, err error)
    65  //sys	getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
    66  //sys	setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
    67  //sysnb	socket(domain int, typ int, proto int) (fd int, err error)
    68  //sysnb	socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
    69  //sysnb	getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    70  //sysnb	getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    71  //sys	recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
    72  //sys	sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
    73  //sys	recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
    74  //sys	sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
    75  //sys	mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
    76  
    77  type sigset_t struct {
    78  	X__val [16]uint64
    79  }
    80  
    81  //sys	pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *sigset_t) (n int, err error) = SYS_PSELECT6
    82  
    83  func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
    84  	var ts *Timespec
    85  	if timeout != nil {
    86  		ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000}
    87  	}
    88  	return pselect(nfd, r, w, e, ts, nil)
    89  }
    90  
    91  //sysnb	Gettimeofday(tv *Timeval) (err error)
    92  
    93  func setTimespec(sec, nsec int64) Timespec {
    94  	return Timespec{Sec: sec, Nsec: nsec}
    95  }
    96  
    97  func setTimeval(sec, usec int64) Timeval {
    98  	return Timeval{Sec: sec, Usec: usec}
    99  }
   100  
   101  func futimesat(dirfd int, path string, tv *[2]Timeval) (err error) {
   102  	if tv == nil {
   103  		return utimensat(dirfd, path, nil, 0)
   104  	}
   105  
   106  	ts := []Timespec{
   107  		NsecToTimespec(TimevalToNsec(tv[0])),
   108  		NsecToTimespec(TimevalToNsec(tv[1])),
   109  	}
   110  	return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
   111  }
   112  
   113  func Time(t *Time_t) (Time_t, error) {
   114  	var tv Timeval
   115  	err := Gettimeofday(&tv)
   116  	if err != nil {
   117  		return 0, err
   118  	}
   119  	if t != nil {
   120  		*t = Time_t(tv.Sec)
   121  	}
   122  	return Time_t(tv.Sec), nil
   123  }
   124  
   125  func Utime(path string, buf *Utimbuf) error {
   126  	tv := []Timeval{
   127  		{Sec: buf.Actime},
   128  		{Sec: buf.Modtime},
   129  	}
   130  	return Utimes(path, tv)
   131  }
   132  
   133  func utimes(path string, tv *[2]Timeval) (err error) {
   134  	if tv == nil {
   135  		return utimensat(_AT_FDCWD, path, nil, 0)
   136  	}
   137  
   138  	ts := []Timespec{
   139  		NsecToTimespec(TimevalToNsec(tv[0])),
   140  		NsecToTimespec(TimevalToNsec(tv[1])),
   141  	}
   142  	return utimensat(_AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
   143  }
   144  
   145  func (r *PtraceRegs) PC() uint64 { return r.Pc }
   146  
   147  func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc }
   148  
   149  func (iov *Iovec) SetLen(length int) {
   150  	iov.Len = uint64(length)
   151  }
   152  
   153  func (msghdr *Msghdr) SetControllen(length int) {
   154  	msghdr.Controllen = uint64(length)
   155  }
   156  
   157  func (cmsg *Cmsghdr) SetLen(length int) {
   158  	cmsg.Len = uint64(length)
   159  }
   160  
   161  func InotifyInit() (fd int, err error) {
   162  	return InotifyInit1(0)
   163  }
   164  
   165  //sys	ppoll(fds *pollFd, nfds int, timeout *Timespec, sigmask *sigset_t) (n int, err error)
   166  
   167  func Pause() error {
   168  	_, err := ppoll(nil, 0, nil, nil)
   169  	return err
   170  }
   171  

View as plain text