PageRenderTime 2911ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/go/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go

https://gitlab.com/ipernet/gitlab-shell
Go | 209 lines | 123 code | 34 blank | 52 comment | 18 complexity | ff5527914d55592f7c401cae077aa480 MD5 | raw file
  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. // +build riscv64,linux
  5. package unix
  6. import "unsafe"
  7. func EpollCreate(size int) (fd int, err error) {
  8. if size <= 0 {
  9. return -1, EINVAL
  10. }
  11. return EpollCreate1(0)
  12. }
  13. //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT
  14. //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
  15. //sys Fchown(fd int, uid int, gid int) (err error)
  16. //sys Fstat(fd int, stat *Stat_t) (err error)
  17. //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
  18. //sys Fstatfs(fd int, buf *Statfs_t) (err error)
  19. //sys Ftruncate(fd int, length int64) (err error)
  20. //sysnb Getegid() (egid int)
  21. //sysnb Geteuid() (euid int)
  22. //sysnb Getgid() (gid int)
  23. //sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
  24. //sysnb Getuid() (uid int)
  25. //sys Listen(s int, n int) (err error)
  26. //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
  27. //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
  28. //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
  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. //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. //sysnb Setregid(rgid int, egid int) (err error)
  40. //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
  41. //sysnb Setresuid(ruid int, euid int, suid int) (err error)
  42. //sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
  43. //sysnb Setreuid(ruid int, euid int) (err error)
  44. //sys Shutdown(fd int, how int) (err error)
  45. //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
  46. func Stat(path string, stat *Stat_t) (err error) {
  47. return Fstatat(AT_FDCWD, path, stat, 0)
  48. }
  49. func Lchown(path string, uid int, gid int) (err error) {
  50. return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW)
  51. }
  52. func Lstat(path string, stat *Stat_t) (err error) {
  53. return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW)
  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. func Ustat(dev int, ubuf *Ustat_t) (err error) {
  59. return ENOSYS
  60. }
  61. //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
  62. //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
  63. //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
  64. //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
  65. //sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
  66. //sysnb setgroups(n int, list *_Gid_t) (err error)
  67. //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
  68. //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
  69. //sysnb socket(domain int, typ int, proto int) (fd int, err error)
  70. //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
  71. //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
  72. //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
  73. //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
  74. //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
  75. //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
  76. //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
  77. //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
  78. //sysnb Gettimeofday(tv *Timeval) (err error)
  79. func setTimespec(sec, nsec int64) Timespec {
  80. return Timespec{Sec: sec, Nsec: nsec}
  81. }
  82. func setTimeval(sec, usec int64) Timeval {
  83. return Timeval{Sec: sec, Usec: usec}
  84. }
  85. func futimesat(dirfd int, path string, tv *[2]Timeval) (err error) {
  86. if tv == nil {
  87. return utimensat(dirfd, path, nil, 0)
  88. }
  89. ts := []Timespec{
  90. NsecToTimespec(TimevalToNsec(tv[0])),
  91. NsecToTimespec(TimevalToNsec(tv[1])),
  92. }
  93. return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
  94. }
  95. func Time(t *Time_t) (Time_t, error) {
  96. var tv Timeval
  97. err := Gettimeofday(&tv)
  98. if err != nil {
  99. return 0, err
  100. }
  101. if t != nil {
  102. *t = Time_t(tv.Sec)
  103. }
  104. return Time_t(tv.Sec), nil
  105. }
  106. func Utime(path string, buf *Utimbuf) error {
  107. tv := []Timeval{
  108. {Sec: buf.Actime},
  109. {Sec: buf.Modtime},
  110. }
  111. return Utimes(path, tv)
  112. }
  113. func utimes(path string, tv *[2]Timeval) (err error) {
  114. if tv == nil {
  115. return utimensat(AT_FDCWD, path, nil, 0)
  116. }
  117. ts := []Timespec{
  118. NsecToTimespec(TimevalToNsec(tv[0])),
  119. NsecToTimespec(TimevalToNsec(tv[1])),
  120. }
  121. return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
  122. }
  123. func Pipe(p []int) (err error) {
  124. if len(p) != 2 {
  125. return EINVAL
  126. }
  127. var pp [2]_C_int
  128. err = pipe2(&pp, 0)
  129. p[0] = int(pp[0])
  130. p[1] = int(pp[1])
  131. return
  132. }
  133. //sysnb pipe2(p *[2]_C_int, flags int) (err error)
  134. func Pipe2(p []int, flags int) (err error) {
  135. if len(p) != 2 {
  136. return EINVAL
  137. }
  138. var pp [2]_C_int
  139. err = pipe2(&pp, flags)
  140. p[0] = int(pp[0])
  141. p[1] = int(pp[1])
  142. return
  143. }
  144. func (r *PtraceRegs) PC() uint64 { return r.Pc }
  145. func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc }
  146. func (iov *Iovec) SetLen(length int) {
  147. iov.Len = uint64(length)
  148. }
  149. func (msghdr *Msghdr) SetControllen(length int) {
  150. msghdr.Controllen = uint64(length)
  151. }
  152. func (cmsg *Cmsghdr) SetLen(length int) {
  153. cmsg.Len = uint64(length)
  154. }
  155. func InotifyInit() (fd int, err error) {
  156. return InotifyInit1(0)
  157. }
  158. func Dup2(oldfd int, newfd int) (err error) {
  159. return Dup3(oldfd, newfd, 0)
  160. }
  161. func Pause() error {
  162. _, err := ppoll(nil, 0, nil, nil)
  163. return err
  164. }
  165. func Poll(fds []PollFd, timeout int) (n int, err error) {
  166. var ts *Timespec
  167. if timeout >= 0 {
  168. ts = new(Timespec)
  169. *ts = NsecToTimespec(int64(timeout) * 1e6)
  170. }
  171. if len(fds) == 0 {
  172. return ppoll(nil, 0, ts, nil)
  173. }
  174. return ppoll(&fds[0], len(fds), ts, nil)
  175. }