From e92030239abb4038d4f915d47021d6c037239309 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 19 Apr 2017 07:44:48 +0200 Subject: Assume that accept4 is always available and works Simplify the Linux accept4 implementation based on the assumption that it is available in some way. __ASSUME_ACCEPT4_SOCKETCALL was previously unused, so remove it. For ia64, the accept4 system call (and socket call) were backported in kernel version 3.2.18. Reflect this in the installation instructions. --- support/Makefile | 1 + support/xaccept4.c | 32 ++++++++++++++++++++++++++++++++ support/xsocket.h | 1 + 3 files changed, 34 insertions(+) create mode 100644 support/xaccept4.c (limited to 'support') diff --git a/support/Makefile b/support/Makefile index 1f33fa0..38dbd83 100644 --- a/support/Makefile +++ b/support/Makefile @@ -50,6 +50,7 @@ libsupport-routines = \ temp_file \ write_message \ xaccept \ + xaccept4 \ xasprintf \ xbind \ xcalloc \ diff --git a/support/xaccept4.c b/support/xaccept4.c new file mode 100644 index 0000000..67dd95e --- /dev/null +++ b/support/xaccept4.c @@ -0,0 +1,32 @@ +/* accept4 with error checking. + Copyright (C) 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 + . */ + +#include + +#include +#include +#include + +int +xaccept4 (int fd, struct sockaddr *sa, socklen_t *salen, int flags) +{ + int clientfd = accept4 (fd, sa, salen, flags); + if (clientfd < 0) + FAIL_EXIT1 ("accept4 (%d, 0x%x): %m", fd, flags); + return clientfd; +} diff --git a/support/xsocket.h b/support/xsocket.h index 0dbf13a..d672494 100644 --- a/support/xsocket.h +++ b/support/xsocket.h @@ -30,6 +30,7 @@ void xconnect (int, const struct sockaddr *, socklen_t); void xbind (int, const struct sockaddr *, socklen_t); void xlisten (int, int); int xaccept (int, struct sockaddr *, socklen_t *); +int xaccept4 (int, struct sockaddr *, socklen_t *, int); void xsendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t); size_t xrecvfrom (int, void *, size_t, int, struct sockaddr *, socklen_t *); -- cgit v1.1