syscall_linux_sparc64.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // Copyright 2009 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 sparc64,linux
  5. package unix
  6. import (
  7. "sync/atomic"
  8. "syscall"
  9. )
  10. //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
  11. //sys Dup2(oldfd int, newfd int) (err error)
  12. //sys Fchown(fd int, uid int, gid int) (err error)
  13. //sys Fstat(fd int, stat *Stat_t) (err error)
  14. //sys Fstatfs(fd int, buf *Statfs_t) (err error)
  15. //sys Ftruncate(fd int, length int64) (err error)
  16. //sysnb Getegid() (egid int)
  17. //sysnb Geteuid() (euid int)
  18. //sysnb Getgid() (gid int)
  19. //sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
  20. //sysnb Getuid() (uid int)
  21. //sysnb InotifyInit() (fd int, err error)
  22. //sys Lchown(path string, uid int, gid int) (err error)
  23. //sys Listen(s int, n int) (err error)
  24. //sys Lstat(path string, stat *Stat_t) (err error)
  25. //sys Pause() (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. //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
  30. //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
  31. //sys Setfsgid(gid int) (err error)
  32. //sys Setfsuid(uid int) (err error)
  33. //sysnb Setregid(rgid int, egid int) (err error)
  34. //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
  35. //sysnb Setresuid(ruid int, euid int, suid int) (err error)
  36. //sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
  37. //sysnb Setreuid(ruid int, euid int) (err error)
  38. //sys Shutdown(fd int, how int) (err error)
  39. //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
  40. //sys Stat(path string, stat *Stat_t) (err error)
  41. //sys Statfs(path string, buf *Statfs_t) (err error)
  42. //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
  43. //sys Truncate(path string, length int64) (err error)
  44. //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
  45. //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
  46. //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
  47. //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
  48. //sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
  49. //sysnb setgroups(n int, list *_Gid_t) (err error)
  50. //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
  51. //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
  52. //sysnb socket(domain int, typ int, proto int) (fd int, err error)
  53. //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
  54. //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
  55. //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
  56. //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
  57. //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
  58. //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
  59. //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
  60. //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
  61. func sysconf(name int) (n int64, err syscall.Errno)
  62. // pageSize caches the value of Getpagesize, since it can't change
  63. // once the system is booted.
  64. var pageSize int64 // accessed atomically
  65. func Getpagesize() int {
  66. n := atomic.LoadInt64(&pageSize)
  67. if n == 0 {
  68. n, _ = sysconf(_SC_PAGESIZE)
  69. atomic.StoreInt64(&pageSize, n)
  70. }
  71. return int(n)
  72. }
  73. func Ioperm(from int, num int, on int) (err error) {
  74. return ENOSYS
  75. }
  76. func Iopl(level int) (err error) {
  77. return ENOSYS
  78. }
  79. //sysnb Gettimeofday(tv *Timeval) (err error)
  80. func Time(t *Time_t) (tt Time_t, err error) {
  81. var tv Timeval
  82. err = Gettimeofday(&tv)
  83. if err != nil {
  84. return 0, err
  85. }
  86. if t != nil {
  87. *t = Time_t(tv.Sec)
  88. }
  89. return Time_t(tv.Sec), nil
  90. }
  91. //sys Utime(path string, buf *Utimbuf) (err error)
  92. func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
  93. func NsecToTimespec(nsec int64) (ts Timespec) {
  94. ts.Sec = nsec / 1e9
  95. ts.Nsec = nsec % 1e9
  96. return
  97. }
  98. func NsecToTimeval(nsec int64) (tv Timeval) {
  99. nsec += 999 // round up to microsecond
  100. tv.Sec = nsec / 1e9
  101. tv.Usec = int32(nsec % 1e9 / 1e3)
  102. return
  103. }
  104. func (r *PtraceRegs) PC() uint64 { return r.Tpc }
  105. func (r *PtraceRegs) SetPC(pc uint64) { r.Tpc = pc }
  106. func (iov *Iovec) SetLen(length int) {
  107. iov.Len = uint64(length)
  108. }
  109. func (msghdr *Msghdr) SetControllen(length int) {
  110. msghdr.Controllen = uint64(length)
  111. }
  112. func (cmsg *Cmsghdr) SetLen(length int) {
  113. cmsg.Len = uint64(length)
  114. }
  115. //sysnb pipe(p *[2]_C_int) (err error)
  116. func Pipe(p []int) (err error) {
  117. if len(p) != 2 {
  118. return EINVAL
  119. }
  120. var pp [2]_C_int
  121. err = pipe(&pp)
  122. p[0] = int(pp[0])
  123. p[1] = int(pp[1])
  124. return
  125. }
  126. //sysnb pipe2(p *[2]_C_int, flags int) (err error)
  127. func Pipe2(p []int, flags int) (err error) {
  128. if len(p) != 2 {
  129. return EINVAL
  130. }
  131. var pp [2]_C_int
  132. err = pipe2(&pp, flags)
  133. p[0] = int(pp[0])
  134. p[1] = int(pp[1])
  135. return
  136. }
  137. //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
  138. func Poll(fds []PollFd, timeout int) (n int, err error) {
  139. if len(fds) == 0 {
  140. return poll(nil, 0, timeout)
  141. }
  142. return poll(&fds[0], len(fds), timeout)
  143. }