From patchwork Fri Jun 20 21:03:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 362349 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EE15B14009F for ; Sat, 21 Jun 2014 07:03:36 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=mlkx/gZQ0PAnkHXsKgYjLMEA/A3Nk yKQ5ppB2X+7E7M+YxQyUOc7sP7wuvKP/wndPZOkg97LD1VlB31RvX9VraHIO0c1e krUFUmVKyw69INXaR8kXFca6azsexlrvELjLnDM9l5m+tveUEDewlbZepXKTtV7G QT8O7U2Y8CC3C8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=DpkMfKwXgJIi5ieAWQp0gsxc7ps=; b=iGn d9ki/TGlvI8jU2SVAa2S6yotXOEuTEMLh/Ev5KTydrhyo04+WcAT3qKm0k38pGqr /pedp0Gi3enlXiv+7rTMtD4VBUBXUrGge5jUkoeQlJiOtfbnrHYb1iTLwL+KkZwq 9QfAW8oJaLcUC+XP3pw5xxdqgzfN9pssOxxGBKBw= Received: (qmail 24331 invoked by alias); 20 Jun 2014 21:03:31 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 24308 invoked by uid 89); 20 Jun 2014 21:03:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Date: Fri, 20 Jun 2014 21:03:22 +0000 From: "Joseph S. Myers" To: Subject: Remove __ASSUME_SOCK_CLOEXEC / SOCK_CLOEXEC conditionals in Linux-specific code Message-ID: MIME-Version: 1.0 This patch removes conditionals on __ASSUME_SOCK_CLOEXEC, and on SOCK_CLOEXEC being defined, in Linux-specific code, now that all supported Linux kernel versions can be assumed to have this functionality. (The macro is also used in OS-independent code and is not defined for Hurd.) Tested x86_64 that the disassembly of installed shared libraries is unchanged by this patch. 2014-06-20 Joseph Myers * nptl/sysdeps/unix/sysv/linux/mq_notify.c: Do not include . (init_mq_netlink): Remove conditional have_sock_cloexec definitions. Remove code conditional on have_sock_cloexec < 0. (init_mq_netlink) [!SOCK_CLOEXEC]: Remove conditional code. (init_mq_netlink) [!__ASSUME_SOCK_CLOEXEC]: Likewise. * sysdeps/unix/sysv/linux/opensock.c: Do not include . (__opensock) [SOCK_CLOEXEC]: Make code unconditional. (__opensock) [!__ASSUME_SOCK_CLOEXEC]: Remove conditional code. diff --git a/nptl/sysdeps/unix/sysv/linux/mq_notify.c b/nptl/sysdeps/unix/sysv/linux/mq_notify.c index 3138ad2..6893d8c 100644 --- a/nptl/sysdeps/unix/sysv/linux/mq_notify.c +++ b/nptl/sysdeps/unix/sysv/linux/mq_notify.c @@ -28,7 +28,6 @@ #include #include #include -#include #include @@ -153,41 +152,15 @@ reset_once (void) static void init_mq_netlink (void) { -#ifdef SOCK_CLOEXEC -# ifndef __ASSUME_SOCK_CLOEXEC - static int have_sock_cloexec; -# else -# define have_sock_cloexec 1 -# endif -#else -# define have_sock_cloexec -1 -# define SOCK_CLOEXEC 0 -#endif - /* This code might be called a second time after fork(). The file descriptor is inherited from the parent. */ if (netlink_socket == -1) { /* Just a normal netlink socket, not bound. */ - if (have_sock_cloexec >= 0) - { - netlink_socket = socket (AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, 0); -#if defined SOCK_CLOEXEC && !defined __ASSUME_SOCK_CLOEXEC - if (have_sock_cloexec == 0) - have_sock_cloexec = (netlink_socket != -1 || errno != EINVAL - ? 1 : -1); -#endif - } - if (have_sock_cloexec < 0) - netlink_socket = socket (AF_NETLINK, SOCK_RAW, 0); + netlink_socket = socket (AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, 0); /* No need to do more if we have no socket. */ if (netlink_socket == -1) return; - - /* Make sure the descriptor is closed on exec. */ - if (have_sock_cloexec < 0 - && fcntl (netlink_socket, F_SETFD, FD_CLOEXEC) != 0) - goto errout; } int err = 1; diff --git a/sysdeps/unix/sysv/linux/opensock.c b/sysdeps/unix/sysv/linux/opensock.c index bcf7f5f..4894bf9 100644 --- a/sysdeps/unix/sysv/linux/opensock.c +++ b/sysdeps/unix/sysv/linux/opensock.c @@ -21,7 +21,6 @@ #include #include #include -#include /* Return a socket of any type. The socket can be used in subsequent ioctl calls to talk to the kernel. */ @@ -63,24 +62,7 @@ __opensock (void) { assert (last_type != 0); -#ifdef SOCK_CLOEXEC -# ifndef __ASSUME_SOCK_CLOEXEC - if (__have_sock_cloexec >= 0) -# endif - { - result = __socket (last_family, last_type | SOCK_CLOEXEC, 0); -# ifndef __ASSUME_SOCK_CLOEXEC - if (__have_sock_cloexec == 0) - __have_sock_cloexec = result != -1 || errno != EINVAL ? 1 : -1; -# endif - } -#endif -#ifndef __ASSUME_SOCK_CLOEXEC -# ifdef SOCK_CLOEXEC - if (__have_sock_cloexec < 0) -# endif - result = __socket (last_family, last_type, 0); -#endif + result = __socket (last_family, last_type | SOCK_CLOEXEC, 0); if (result != -1 || errno != EAFNOSUPPORT) /* Maybe the socket type isn't supported anymore (module is unloaded). In this case again try to find the type. */ @@ -115,24 +97,7 @@ __opensock (void) if (afs[cnt].family == AF_NETROM || afs[cnt].family == AF_X25) type = SOCK_SEQPACKET; -#ifdef SOCK_CLOEXEC -# ifndef __ASSUME_SOCK_CLOEXEC - if (__have_sock_cloexec >= 0) -# endif - { - result = __socket (afs[cnt].family, type | SOCK_CLOEXEC, 0); -# ifndef __ASSUME_SOCK_CLOEXEC - if (__have_sock_cloexec == 0) - __have_sock_cloexec = result != -1 || errno != EINVAL ? 1 : -1; -# endif - } -#endif -#ifndef __ASSUME_SOCK_CLOEXEC -# ifdef SOCK_CLOEXEC - if (__have_sock_cloexec < 0) -# endif - result = __socket (afs[cnt].family, type, 0); -#endif + result = __socket (afs[cnt].family, type | SOCK_CLOEXEC, 0); if (result != -1) { /* Found an available family. */