]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
mksysinfo, net: Always define F_DUPFD_CLOEXEC.
authorIan Lance Taylor <ian@gcc.gnu.org>
Mon, 11 Nov 2013 21:21:50 +0000 (21:21 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 11 Nov 2013 21:21:50 +0000 (21:21 +0000)
For Solaris and CentOS portability.

From-SVN: r204687

libgo/go/net/fd_unix.go
libgo/mksysinfo.sh

index 9ed4f753649aeeb13ee0a6404503eba919e3a2fe..4911ab0abe3f3aac33211a61750c48f39d5b9a4d 100644 (file)
@@ -410,7 +410,7 @@ func (fd *netFD) accept(toAddr func(syscall.Sockaddr) Addr) (netfd *netFD, err e
 var tryDupCloexec = int32(1)
 
 func dupCloseOnExec(fd int) (newfd int, err error) {
-       if atomic.LoadInt32(&tryDupCloexec) == 1 {
+       if atomic.LoadInt32(&tryDupCloexec) == 1 && syscall.F_DUPFD_CLOEXEC != 0 {
                r0, _, e1 := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), syscall.F_DUPFD_CLOEXEC, 0)
                if runtime.GOOS == "darwin" && e1 == syscall.EBADF {
                        // On OS X 10.6 and below (but we only support
index a1713df9b572e75f41024b5223915c0bdfcffaae..025729ccad1df0259cd014b915f8fb46d555b1d6 100755 (executable)
@@ -220,6 +220,11 @@ if ! grep '^const O_CLOEXEC' ${OUT} >/dev/null 2>&1; then
   echo "const O_CLOEXEC = 0" >> ${OUT}
 fi
 
+# The os package requires F_DUPFD_CLOEXEC to be defined.
+if ! grep '^const F_DUPFD_CLOEXEC' ${OUT} >/dev/null 2>&1; then
+  echo "const F_DUPFD_CLOEXEC = 0" >> ${OUT}
+fi
+
 # These flags can be lost on i386 GNU/Linux when using
 # -D_FILE_OFFSET_BITS=64, because we see "#define F_SETLK F_SETLK64"
 # before we see the definition of F_SETLK64.