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 5 // +build linux 6 // +build ppc64 ppc64le 7 8 package syscall 9 10 const _SYS_dup = SYS_DUP2 11 12 //sys Dup2(oldfd int, newfd int) (err error) 13 //sys Fchown(fd int, uid int, gid int) (err error) 14 //sys Fstat(fd int, stat *Stat_t) (err error) 15 //sys Fstatfs(fd int, buf *Statfs_t) (err error) 16 //sys Ftruncate(fd int, length int64) (err error) 17 //sysnb Getegid() (egid int) 18 //sysnb Geteuid() (euid int) 19 //sysnb Getgid() (gid int) 20 //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT 21 //sysnb Getuid() (uid int) 22 //sysnb InotifyInit() (fd int, err error) 23 //sys Ioperm(from int, num int, on int) (err error) 24 //sys Iopl(level int) (err error) 25 //sys Lchown(path string, uid int, gid int) (err error) 26 //sys Listen(s int, n int) (err error) 27 //sys Lstat(path string, stat *Stat_t) (err error) 28 //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 29 //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 30 //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 31 //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 32 //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 33 //sys Setfsgid(gid int) (err error) 34 //sys Setfsuid(uid int) (err error) 35 //sysnb Setregid(rgid int, egid int) (err error) 36 //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 37 //sysnb Setresuid(ruid int, euid int, suid int) (err error) 38 //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 39 //sysnb Setreuid(ruid int, euid 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 //sys Stat(path string, stat *Stat_t) (err error) 43 //sys Statfs(path string, buf *Statfs_t) (err error) 44 //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2 45 //sys Truncate(path string, length int64) (err error) 46 //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 47 //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 48 //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 49 //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 50 //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 51 //sysnb setgroups(n int, list *_Gid_t) (err error) 52 //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 53 //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 54 //sysnb socket(domain int, typ int, proto int) (fd int, err error) 55 //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 56 //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 57 //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 58 //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 59 //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 60 //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 61 //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 62 //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 63 64 func Getpagesize() int { return 65536 } 65 66 //sysnb Gettimeofday(tv *Timeval) (err error) 67 //sysnb Time(t *Time_t) (tt Time_t, err error) 68 69 func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 70 71 func NsecToTimespec(nsec int64) (ts Timespec) { 72 ts.Sec = nsec / 1e9 73 ts.Nsec = nsec % 1e9 74 return 75 } 76 77 func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 78 79 func NsecToTimeval(nsec int64) (tv Timeval) { 80 nsec += 999 // round up to microsecond 81 tv.Sec = nsec / 1e9 82 tv.Usec = nsec % 1e9 / 1e3 83 return 84 } 85 86 func Pipe(p []int) (err error) { 87 if len(p) != 2 { 88 return EINVAL 89 } 90 var pp [2]_C_int 91 err = pipe2(&pp, 0) 92 p[0] = int(pp[0]) 93 p[1] = int(pp[1]) 94 return 95 } 96 97 //sysnb pipe2(p *[2]_C_int, flags int) (err error) 98 99 func Pipe2(p []int, flags int) (err error) { 100 if len(p) != 2 { 101 return EINVAL 102 } 103 var pp [2]_C_int 104 err = pipe2(&pp, flags) 105 p[0] = int(pp[0]) 106 p[1] = int(pp[1]) 107 return 108 } 109 110 func (r *PtraceRegs) PC() uint64 { return r.Nip } 111 112 func (r *PtraceRegs) SetPC(pc uint64) { r.Nip = pc } 113 114 func (iov *Iovec) SetLen(length int) { 115 iov.Len = uint64(length) 116 } 117 118 func (msghdr *Msghdr) SetControllen(length int) { 119 msghdr.Controllen = uint64(length) 120 } 121 122 func (cmsg *Cmsghdr) SetLen(length int) { 123 cmsg.Len = uint64(length) 124 } 125