Assume that dup3 is available
This commit is contained in:
parent
46d8874d5b
commit
b48061e1a5
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2017-04-18 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
|
* include/unistd.h (__have_dup3): Remove declaration.
|
||||||
|
* libio/freopen.c (freopen): Assume that O_CLOEXEC is defined and
|
||||||
|
dup3 is available.
|
||||||
|
* libio/freopen64.c (freopen64): Likewise.
|
||||||
|
* socket/Makefile (aux): Remove have_sock_cloexec.
|
||||||
|
* socket/have_sock_cloexec.c: Remove file.
|
||||||
|
* sysdeps/mach/hurd/kernel-features.h (__ASSUME_DUP3): Remove
|
||||||
|
definition.
|
||||||
|
* sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_DUP3):
|
||||||
|
Likewise.
|
||||||
|
* sysdeps/nacl/kernel-features.h: Update comment.
|
||||||
|
|
||||||
2017-04-18 Florian Weimer <fweimer@redhat.com>
|
2017-04-18 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
* include/unistd.h (__have_pipe2): Remove declaration.
|
* include/unistd.h (__have_pipe2): Remove declaration.
|
||||||
|
|
|
@ -171,8 +171,6 @@ extern int __libc_pause (void);
|
||||||
/* Not cancelable variant. */
|
/* Not cancelable variant. */
|
||||||
extern int __pause_nocancel (void) attribute_hidden;
|
extern int __pause_nocancel (void) attribute_hidden;
|
||||||
|
|
||||||
extern int __have_dup3 attribute_hidden;
|
|
||||||
|
|
||||||
extern int __getlogin_r_loginuid (char *name, size_t namesize)
|
extern int __getlogin_r_loginuid (char *name, size_t namesize)
|
||||||
attribute_hidden;
|
attribute_hidden;
|
||||||
|
|
||||||
|
|
|
@ -78,32 +78,9 @@ freopen (const char *filename, const char *mode, FILE *fp)
|
||||||
|
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
{
|
{
|
||||||
#ifdef O_CLOEXEC
|
__dup3 (_IO_fileno (result), fd,
|
||||||
# ifndef __ASSUME_DUP3
|
(result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0
|
||||||
int newfd;
|
? O_CLOEXEC : 0);
|
||||||
if (__have_dup3 < 0)
|
|
||||||
newfd = -1;
|
|
||||||
else
|
|
||||||
newfd =
|
|
||||||
# endif
|
|
||||||
__dup3 (_IO_fileno (result), fd,
|
|
||||||
(result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0
|
|
||||||
? O_CLOEXEC : 0);
|
|
||||||
#else
|
|
||||||
# define newfd 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __ASSUME_DUP3
|
|
||||||
if (newfd < 0)
|
|
||||||
{
|
|
||||||
if (errno == ENOSYS)
|
|
||||||
__have_dup3 = -1;
|
|
||||||
|
|
||||||
__dup2 (_IO_fileno (result), fd);
|
|
||||||
if ((result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0)
|
|
||||||
__fcntl (fd, F_SETFD, FD_CLOEXEC);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
__close (_IO_fileno (result));
|
__close (_IO_fileno (result));
|
||||||
_IO_fileno (result) = fd;
|
_IO_fileno (result) = fd;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,32 +61,9 @@ freopen64 (const char *filename, const char *mode, FILE *fp)
|
||||||
|
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
{
|
{
|
||||||
#ifdef O_CLOEXEC
|
__dup3 (_IO_fileno (result), fd,
|
||||||
# ifndef __ASSUME_DUP3
|
(result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0
|
||||||
int newfd;
|
? O_CLOEXEC : 0);
|
||||||
if (__have_dup3 < 0)
|
|
||||||
newfd = -1;
|
|
||||||
else
|
|
||||||
newfd =
|
|
||||||
# endif
|
|
||||||
__dup3 (_IO_fileno (result), fd,
|
|
||||||
(result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0
|
|
||||||
? O_CLOEXEC : 0);
|
|
||||||
#else
|
|
||||||
# define newfd 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __ASSUME_DUP3
|
|
||||||
if (newfd < 0)
|
|
||||||
{
|
|
||||||
if (errno == ENOSYS)
|
|
||||||
__have_dup3 = -1;
|
|
||||||
|
|
||||||
__dup2 (_IO_fileno (result), fd);
|
|
||||||
if ((result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0)
|
|
||||||
__fcntl (fd, F_SETFD, FD_CLOEXEC);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
__close (_IO_fileno (result));
|
__close (_IO_fileno (result));
|
||||||
_IO_fileno (result) = fd;
|
_IO_fileno (result) = fd;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,6 @@ routines := accept bind connect getpeername getsockname getsockopt \
|
||||||
setsockopt shutdown socket socketpair isfdtype opensock \
|
setsockopt shutdown socket socketpair isfdtype opensock \
|
||||||
sockatmark accept4 recvmmsg sendmmsg
|
sockatmark accept4 recvmmsg sendmmsg
|
||||||
|
|
||||||
aux := have_sock_cloexec sa_len
|
aux := sa_len
|
||||||
|
|
||||||
include ../Rules
|
include ../Rules
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
/* Copyright (C) 2008-2017 Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with the GNU C Library; if not, see
|
|
||||||
<http://www.gnu.org/licenses/>. */
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <kernel-features.h>
|
|
||||||
|
|
||||||
#if defined O_CLOEXEC && !defined __ASSUME_DUP3
|
|
||||||
int __have_dup3;
|
|
||||||
#endif
|
|
|
@ -21,5 +21,4 @@
|
||||||
But those referring to POSIX-level features like O_* flags can be. */
|
But those referring to POSIX-level features like O_* flags can be. */
|
||||||
|
|
||||||
#define __ASSUME_O_CLOEXEC 1
|
#define __ASSUME_O_CLOEXEC 1
|
||||||
#define __ASSUME_DUP3 1
|
|
||||||
#define __ASSUME_ACCEPT4 1
|
#define __ASSUME_ACCEPT4 1
|
||||||
|
|
|
@ -23,6 +23,5 @@
|
||||||
#define __ASSUME_O_CLOEXEC 1
|
#define __ASSUME_O_CLOEXEC 1
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define __ASSUME_DUP3 1
|
|
||||||
#define __ASSUME_ACCEPT4 1
|
#define __ASSUME_ACCEPT4 1
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -74,7 +74,6 @@
|
||||||
/* Support for various CLOEXEC and NONBLOCK flags was added in
|
/* Support for various CLOEXEC and NONBLOCK flags was added in
|
||||||
2.6.27. */
|
2.6.27. */
|
||||||
#define __ASSUME_IN_NONBLOCK 1
|
#define __ASSUME_IN_NONBLOCK 1
|
||||||
#define __ASSUME_DUP3 1
|
|
||||||
|
|
||||||
/* Support for accept4 functionality was added in 2.6.28, but for some
|
/* Support for accept4 functionality was added in 2.6.28, but for some
|
||||||
architectures using a separate syscall rather than socketcall that
|
architectures using a separate syscall rather than socketcall that
|
||||||
|
|
Loading…
Reference in a new issue