S/390: Fix vector all/any cc modes.
[official-gcc.git] / libgo / go / os / wait_wait6.go
blob7f4780ae2d0ab8a9622f7629b68d1e66ece0dae8
1 // Copyright 2016 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.
5 // +build freebsd
7 package os
9 import (
10 "runtime"
11 "syscall"
14 const _P_PID = 0
16 // blockUntilWaitable attempts to block until a call to p.Wait will
17 // succeed immediately, and returns whether it has done so.
18 // It does not actually call p.Wait.
19 func (p *Process) blockUntilWaitable() (bool, error) {
20 var errno syscall.Errno
21 // The arguments on 32-bit FreeBSD look like the following:
22 // - freebsd32_wait6_args{ idtype, id1, id2, status, options, wrusage, info } or
23 // - freebsd32_wait6_args{ idtype, pad, id1, id2, status, options, wrusage, info } when PAD64_REQUIRED=1 on ARM, MIPS or PowerPC
24 if runtime.GOARCH == "386" {
25 _, _, errno = syscall.Syscall9(syscall.SYS_WAIT6, _P_PID, uintptr(p.Pid), 0, 0, syscall.WEXITED|syscall.WNOWAIT, 0, 0, 0, 0)
26 } else if runtime.GOARCH == "arm" {
27 _, _, errno = syscall.Syscall9(syscall.SYS_WAIT6, _P_PID, 0, uintptr(p.Pid), 0, 0, syscall.WEXITED|syscall.WNOWAIT, 0, 0, 0)
28 } else {
29 _, _, errno = syscall.Syscall6(syscall.SYS_WAIT6, _P_PID, uintptr(p.Pid), 0, syscall.WEXITED|syscall.WNOWAIT, 0, 0)
31 if errno != 0 {
32 // The wait6 system call is supported only on FreeBSD
33 // 9.3 and above, so it may return an ENOSYS error.
34 if errno == syscall.ENOSYS {
35 return false, nil
37 return false, NewSyscallError("wait6", errno)
39 return true, nil