Source file src/cmd/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go

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

View as plain text