aboutsummaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-03-30 23:05:04 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-03-30 23:05:04 +0000
commit0b3189e79f87c6d8927a96918b2ee53456df4928 (patch)
tree96a73acd062cce5897fb331039d0cb1cb6442134 /libgo
parent8955c80a1cc754999cfa93d03c04307281e6136f (diff)
downloadgcc-0b3189e79f87c6d8927a96918b2ee53456df4928.zip
gcc-0b3189e79f87c6d8927a96918b2ee53456df4928.tar.gz
gcc-0b3189e79f87c6d8927a96918b2ee53456df4928.tar.bz2
libgo: Use waitpid on systems which do not have wait4.
From-SVN: r171758
Diffstat (limited to 'libgo')
-rw-r--r--libgo/Makefile.am10
-rw-r--r--libgo/Makefile.in7
-rw-r--r--libgo/configure20
-rw-r--r--libgo/configure.ac3
-rwxr-xr-xlibgo/mksysinfo.sh2
-rw-r--r--libgo/syscalls/exec.go14
-rw-r--r--libgo/syscalls/wait4.go22
-rw-r--r--libgo/syscalls/waitpid.go22
8 files changed, 80 insertions, 20 deletions
diff --git a/libgo/Makefile.am b/libgo/Makefile.am
index 476d4aa..a2f2d54 100644
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -1246,13 +1246,20 @@ endif # !LIBGO_IS_SOLARIS
endif # !LIBGO_IS_LINUX
-# Define ForkExec, PtraceForkExec, Exec, and Wait4.
+# Define ForkExec, PtraceForkExec, and Exec.
if LIBGO_IS_RTEMS
syscall_exec_os_file = syscalls/exec_stubs.go
else
syscall_exec_os_file = syscalls/exec.go
endif
+# Define Wait4.
+if HAVE_WAIT4
+syscall_wait_file = syscalls/wait4.go
+else
+syscall_wait_file = syscalls/waitpid.go
+endif
+
# Define Sleep.
if LIBGO_IS_RTEMS
syscall_sleep_file = syscalls/sleep_rtems.go
@@ -1329,6 +1336,7 @@ go_syscall_files = \
$(syscall_errstr_decl_file) \
syscalls/exec_helpers.go \
$(syscall_exec_os_file) \
+ $(syscall_wait_file) \
$(syscall_filesize_file) \
$(syscall_stat_file) \
$(syscall_sleep_file) \
diff --git a/libgo/Makefile.in b/libgo/Makefile.in
index 5797fad..16eb62b 100644
--- a/libgo/Makefile.in
+++ b/libgo/Makefile.in
@@ -1632,8 +1632,12 @@ go_testing_script_files = \
@LIBGO_IS_LINUX_TRUE@syscall_stat_file = syscalls/sysfile_stat_largefile.go
@LIBGO_IS_RTEMS_FALSE@syscall_exec_os_file = syscalls/exec.go
-# Define ForkExec, PtraceForkExec, Exec, and Wait4.
+# Define ForkExec, PtraceForkExec, and Exec.
@LIBGO_IS_RTEMS_TRUE@syscall_exec_os_file = syscalls/exec_stubs.go
+@HAVE_WAIT4_FALSE@syscall_wait_file = syscalls/waitpid.go
+
+# Define Wait4.
+@HAVE_WAIT4_TRUE@syscall_wait_file = syscalls/wait4.go
@LIBGO_IS_RTEMS_FALSE@syscall_sleep_file = syscalls/sleep_select.go
# Define Sleep.
@@ -1671,6 +1675,7 @@ go_syscall_files = \
$(syscall_errstr_decl_file) \
syscalls/exec_helpers.go \
$(syscall_exec_os_file) \
+ $(syscall_wait_file) \
$(syscall_filesize_file) \
$(syscall_stat_file) \
$(syscall_sleep_file) \
diff --git a/libgo/configure b/libgo/configure
index 6fe0259..fbf6297 100644
--- a/libgo/configure
+++ b/libgo/configure
@@ -603,6 +603,8 @@ am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
STRINGOPS_FLAG
+HAVE_WAIT4_FALSE
+HAVE_WAIT4_TRUE
HAVE_STRERROR_R_FALSE
HAVE_STRERROR_R_TRUE
HAVE_SYS_MMAN_H_FALSE
@@ -10900,7 +10902,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10903 "configure"
+#line 10905 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11006,7 +11008,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11009 "configure"
+#line 11011 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -14154,7 +14156,7 @@ else
fi
-for ac_func in srandom random strerror_r strsignal
+for ac_func in srandom random strerror_r strsignal wait4
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -14175,6 +14177,14 @@ else
HAVE_STRERROR_R_FALSE=
fi
+ if test "$ac_cv_func_wait4" = yes; then
+ HAVE_WAIT4_TRUE=
+ HAVE_WAIT4_FALSE='#'
+else
+ HAVE_WAIT4_TRUE='#'
+ HAVE_WAIT4_FALSE=
+fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __sync_bool_compare_and_swap_4" >&5
$as_echo_n "checking for __sync_bool_compare_and_swap_4... " >&6; }
@@ -14552,6 +14562,10 @@ if test -z "${HAVE_STRERROR_R_TRUE}" && test -z "${HAVE_STRERROR_R_FALSE}"; then
as_fn_error "conditional \"HAVE_STRERROR_R\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${HAVE_WAIT4_TRUE}" && test -z "${HAVE_WAIT4_FALSE}"; then
+ as_fn_error "conditional \"HAVE_WAIT4\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
: ${CONFIG_STATUS=./config.status}
ac_write_fail=0
diff --git a/libgo/configure.ac b/libgo/configure.ac
index 7839278..0696351 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -381,8 +381,9 @@ esac
AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h)
AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes)
-AC_CHECK_FUNCS(srandom random strerror_r strsignal)
+AC_CHECK_FUNCS(srandom random strerror_r strsignal wait4)
AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes)
+AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes)
AC_CACHE_CHECK([for __sync_bool_compare_and_swap_4],
[libgo_cv_func___sync_bool_compare_and_swap_4],
diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh
index 033c3ec..331c04b 100755
--- a/libgo/mksysinfo.sh
+++ b/libgo/mksysinfo.sh
@@ -377,6 +377,8 @@ if test "$rusage" != ""; then
nrusage="$nrusage $field;"
done
echo "type Rusage struct {$nrusage }" >> ${OUT}
+else
+ echo "type Rusage struct {}" >> ${OUT}
fi
# The utsname struct.
diff --git a/libgo/syscalls/exec.go b/libgo/syscalls/exec.go
index 64b40bd..450c7e5 100644
--- a/libgo/syscalls/exec.go
+++ b/libgo/syscalls/exec.go
@@ -17,7 +17,6 @@ func libc_chdir(name *byte) int __asm__ ("chdir")
func libc_dup2(int, int) int __asm__ ("dup2")
func libc_execve(*byte, **byte, **byte) int __asm__ ("execve")
func libc_sysexit(int) __asm__ ("_exit")
-func libc_wait4(Pid_t, *int, int, *Rusage) Pid_t __asm__ ("wait4")
// Fork, dup fd onto 0..len(fd), and exec(argv0, argvv, envv) in child.
// If a dup or exec fails, write the errno int to pipe.
@@ -263,16 +262,3 @@ func Exec(argv0 string, argv []string, envv []string) (err int) {
libc_execve(StringBytePtr(argv0), &argv_arg[0], &envv_arg[0])
return GetErrno()
}
-
-func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, errno int) {
- var status int
- r := libc_wait4(Pid_t(pid), &status, options, rusage)
- wpid = int(r)
- if r < 0 {
- errno = GetErrno()
- }
- if wstatus != nil {
- *wstatus = WaitStatus(status)
- }
- return
-}
diff --git a/libgo/syscalls/wait4.go b/libgo/syscalls/wait4.go
new file mode 100644
index 0000000..bb00c79
--- /dev/null
+++ b/libgo/syscalls/wait4.go
@@ -0,0 +1,22 @@
+// wait4.go -- Wait4 for systems with wait4.
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+func libc_wait4(Pid_t, *int, int, *Rusage) Pid_t __asm__ ("wait4")
+
+func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, errno int) {
+ var status int
+ r := libc_wait4(Pid_t(pid), &status, options, rusage)
+ wpid = int(r)
+ if r < 0 {
+ errno = GetErrno()
+ }
+ if wstatus != nil {
+ *wstatus = WaitStatus(status)
+ }
+ return
+}
diff --git a/libgo/syscalls/waitpid.go b/libgo/syscalls/waitpid.go
new file mode 100644
index 0000000..1cb4d5d
--- /dev/null
+++ b/libgo/syscalls/waitpid.go
@@ -0,0 +1,22 @@
+// waitpid.go -- Wait4 for systems without wait4, but with waitpid.
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+func libc_waitpid(Pid_t, *int, int) Pid_t __asm__ ("waitpid")
+
+func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, errno int) {
+ var status int
+ r := libc_waitpid(Pid_t(pid), &status, options)
+ wpid = int(r)
+ if r < 0 {
+ errno = GetErrno()
+ }
+ if wstatus != nil {
+ *wstatus = WaitStatus(status)
+ }
+ return
+}