...

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

Documentation: cmd/vendor/golang.org/x/sys/unix

     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  
     7  package unix
     8  
     9  import "unsafe"
    10  
    11  //sys	EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT
    12  //sys	Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
    13  //sys	Fchown(fd int, uid int, gid int) (err error)
    14  //sys	Fstat(fd int, stat *Stat_t) (err error)
    15  //sys	Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
    16  //sys	Fstatfs(fd int, buf *Statfs_t) (err error)
    17  //sys	Ftruncate(fd int, length int64) (err error)
    18  //sysnb	Getegid() (egid int)
    19  //sysnb	Geteuid() (euid int)
    20  //sysnb	Getgid() (gid int)
    21  //sysnb	Getrlimit(resource int, rlim *Rlimit) (err error)
    22  //sysnb	Getuid() (uid int)
    23  //sys	Listen(s int, n int) (err error)
    24  //sys	MemfdSecret(flags int) (fd 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 pselect6(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  //sys	Shutdown(fd int, how int) (err error)
    41  //sys	Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
    42  
    43  func Stat(path string, stat *Stat_t) (err error) {
    44  	return Fstatat(AT_FDCWD, path, stat, 0)
    45  }
    46  
    47  func Lchown(path string, uid int, gid int) (err error) {
    48  	return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW)
    49  }
    50  
    51  func Lstat(path string, stat *Stat_t) (err error) {
    52  	return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW)
    53  }
    54  
    55  //sys	Statfs(path string, buf *Statfs_t) (err error)
    56  //sys	SyncFileRange(fd int, off int64, n int64, flags int) (err error)
    57  //sys	Truncate(path string, length int64) (err error)
    58  
    59  func Ustat(dev int, ubuf *Ustat_t) (err error) {
    60  	return ENOSYS
    61  }
    62  
    63  //sys	accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
    64  //sys	bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    65  //sys	connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
    66  //sysnb	getgroups(n int, list *_Gid_t) (nn int, err error)
    67  //sysnb	setgroups(n int, list *_Gid_t) (err error)
    68  //sys	getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
    69  //sys	setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
    70  //sysnb	socket(domain int, typ int, proto int) (fd int, err error)
    71  //sysnb	socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
    72  //sysnb	getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    73  //sysnb	getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
    74  //sys	recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
    75  //sys	sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
    76  //sys	recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
    77  //sys	sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
    78  //sys	mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
    79  
    80  //sysnb	Gettimeofday(tv *Timeval) (err error)
    81  
    82  func setTimespec(sec, nsec int64) Timespec {
    83  	return Timespec{Sec: sec, Nsec: nsec}
    84  }
    85  
    86  func setTimeval(sec, usec int64) Timeval {
    87  	return Timeval{Sec: sec, Usec: usec}
    88  }
    89  
    90  func futimesat(dirfd int, path string, tv *[2]Timeval) (err error) {
    91  	if tv == nil {
    92  		return utimensat(dirfd, path, nil, 0)
    93  	}
    94  
    95  	ts := []Timespec{
    96  		NsecToTimespec(TimevalToNsec(tv[0])),
    97  		NsecToTimespec(TimevalToNsec(tv[1])),
    98  	}
    99  	return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
   100  }
   101  
   102  func Time(t *Time_t) (Time_t, error) {
   103  	var tv Timeval
   104  	err := Gettimeofday(&tv)
   105  	if err != nil {
   106  		return 0, err
   107  	}
   108  	if t != nil {
   109  		*t = Time_t(tv.Sec)
   110  	}
   111  	return Time_t(tv.Sec), nil
   112  }
   113  
   114  func Utime(path string, buf *Utimbuf) error {
   115  	tv := []Timeval{
   116  		{Sec: buf.Actime},
   117  		{Sec: buf.Modtime},
   118  	}
   119  	return Utimes(path, tv)
   120  }
   121  
   122  func utimes(path string, tv *[2]Timeval) (err error) {
   123  	if tv == nil {
   124  		return utimensat(AT_FDCWD, path, nil, 0)
   125  	}
   126  
   127  	ts := []Timespec{
   128  		NsecToTimespec(TimevalToNsec(tv[0])),
   129  		NsecToTimespec(TimevalToNsec(tv[1])),
   130  	}
   131  	return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
   132  }
   133  
   134  func (r *PtraceRegs) PC() uint64 { return r.Pc }
   135  
   136  func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc }
   137  
   138  func (iov *Iovec) SetLen(length int) {
   139  	iov.Len = uint64(length)
   140  }
   141  
   142  func (msghdr *Msghdr) SetControllen(length int) {
   143  	msghdr.Controllen = uint64(length)
   144  }
   145  
   146  func (msghdr *Msghdr) SetIovlen(length int) {
   147  	msghdr.Iovlen = uint64(length)
   148  }
   149  
   150  func (cmsg *Cmsghdr) SetLen(length int) {
   151  	cmsg.Len = uint64(length)
   152  }
   153  
   154  func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) {
   155  	rsa.Service_name_len = uint64(length)
   156  }
   157  
   158  func Pause() error {
   159  	_, err := ppoll(nil, 0, nil, nil)
   160  	return err
   161  }
   162  
   163  func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
   164  	return Renameat2(olddirfd, oldpath, newdirfd, newpath, 0)
   165  }
   166  
   167  //sys	kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error)
   168  
   169  func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error {
   170  	cmdlineLen := len(cmdline)
   171  	if cmdlineLen > 0 {
   172  		// Account for the additional NULL byte added by
   173  		// BytePtrFromString in kexecFileLoad. The kexec_file_load
   174  		// syscall expects a NULL-terminated string.
   175  		cmdlineLen++
   176  	}
   177  	return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
   178  }
   179  
   180  //sys	riscvHWProbe(pairs []RISCVHWProbePairs, cpuCount uintptr, cpus *CPUSet, flags uint) (err error)
   181  
   182  func RISCVHWProbe(pairs []RISCVHWProbePairs, set *CPUSet, flags uint) (err error) {
   183  	var setSize uintptr
   184  
   185  	if set != nil {
   186  		setSize = uintptr(unsafe.Sizeof(*set))
   187  	}
   188  	return riscvHWProbe(pairs, setSize, set, flags)
   189  }
   190  

View as plain text