From patchwork Fri Dec 9 10:34:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 704396 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 3tZpX473WDz9sxS for ; Fri, 9 Dec 2016 21:35:00 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="HfemUKEO"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type; q=dns; s=default; b=XQLm AKdXzy7neppdEPUAwPpQDueklQxxa2Mvh4B16ypOx5c/IVtsd3bsq2F86jQ5rMeG vQLoBYSjrIMcxBpRxlp3U1Dcmi632ubS8gDgFIIr8gUpnKrTgUvhmW6K57Ir1VPj h/wZyW3J0S1VvE93BokKOPvjsSS9iM7LZSsqIE8= 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:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type; s=default; bh=U/kP8k3dNY P2V+/m0P7YZAzfWGw=; b=HfemUKEONkKprP3QuejO4/jAu3l3b6gkoOUJwND5mv vWEs3ZZA+aW9KoBGiJsS4Rg618pePgGNGGLy4qC2fAmGzESIo0xALqF80rA8/0V9 cPSuVttBKLFvoCG32ATi86hDS1iPHquGBCf98R2gmBDJ/mMM0IZmRw2IUTPwodEm g= Received: (qmail 54215 invoked by alias); 9 Dec 2016 10:34:53 -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 54164 invoked by uid 89); 9 Dec 2016 10:34:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=ab, fweimer@redhat.com, U*fweimer, fweimerredhatcom X-HELO: mx1.redhat.com Subject: Re: [PATCH] inet: Make IN6_IS_ADDR_UNSPECIFIED etc. usable with POSIX [BZ #16421] To: libc-alpha@sourceware.org References: <11b8e9fb-8251-d3e0-5f7a-14deefec43af@redhat.com> From: Florian Weimer Message-ID: Date: Fri, 9 Dec 2016 11:34:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <11b8e9fb-8251-d3e0-5f7a-14deefec43af@redhat.com> On 11/25/2016 09:34 AM, Florian Weimer wrote: > This resurrects an old patch from Carlos. I have added a test. > > Compiling test-skeleton.c without _GNU_SOURCE required some surgery on > it. I hope to clear this up soon because I need it for writing other > kinds of tests anyway. > > Are the test-skeleton.c changes okay in the meantime? With the new support infrastructure, the test-skeleton.c changes are no longer necessary, and I committed the attached patch. Thanks, Florian inet: Make IN6_IS_ADDR_UNSPECIFIED etc. usable with POSIX [BZ #16421] Previously, under some feature test macros and compilers, the macros were defined, but references undefined struct members in their implementation. 2016-12-09 Carlos O'Donell Florian Weimer [BZ #16421] * inet/netinet/in.h (struct in6_addr): Always define __u6_addr16 and __u6_addr32 members. (IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_LOOPBACK) (IN6_IS_ADDR_LINKLOCAL, IN6_IS_ADDR_SITELOCAL) (IN6_IS_ADDR_V4MAPPED, IN6_IS_ADDR_V4COMPAT, IN6_ARE_ADDR_EQUAL): Use __u6_addr32. * inet/tst-checks.c: Use * inet/tst-checks-posix.c: New file. * inet/Makefile (tests): Add it. (CFLAGS-tst-checks-posix.c): Compile in C99 mode. diff --git a/inet/Makefile b/inet/Makefile index 1c30932..c82ad92 100644 --- a/inet/Makefile +++ b/inet/Makefile @@ -51,8 +51,8 @@ aux := check_pf check_native ifreq tests := htontest test_ifindex tst-ntoa tst-ether_aton tst-network \ tst-gethnm test-ifaddrs bug-if1 test-inet6_opt tst-ether_line \ - tst-getni1 tst-getni2 tst-inet6_rth tst-checks tst-sockaddr \ - tst-inet6_scopeid_pton + tst-getni1 tst-getni2 tst-inet6_rth tst-checks tst-checks-posix \ + tst-sockaddr tst-inet6_scopeid_pton include ../Rules @@ -86,6 +86,7 @@ CFLAGS-either_hton.c = -fexceptions CFLAGS-getnetgrent.c = -fexceptions CFLAGS-getnetgrent_r.c = -fexceptions +CFLAGS-tst-checks-posix.c = -std=c99 CFLAGS-tst-sockaddr.c = -fno-strict-aliasing endif diff --git a/inet/netinet/in.h b/inet/netinet/in.h index c801593..01594c6 100644 --- a/inet/netinet/in.h +++ b/inet/netinet/in.h @@ -213,10 +213,8 @@ struct in6_addr union { uint8_t __u6_addr8[16]; -#ifdef __USE_MISC uint16_t __u6_addr16[8]; uint32_t __u6_addr32[4]; -#endif } __in6_u; #define s6_addr __in6_u.__u6_addr8 #ifdef __USE_MISC @@ -411,52 +409,52 @@ extern uint16_t htons (uint16_t __hostshort) # define IN6_IS_ADDR_UNSPECIFIED(a) \ (__extension__ \ ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ - __a->s6_addr32[0] == 0 \ - && __a->s6_addr32[1] == 0 \ - && __a->s6_addr32[2] == 0 \ - && __a->s6_addr32[3] == 0; })) + __a->__in6_u.__u6_addr32[0] == 0 \ + && __a->__in6_u.__u6_addr32[1] == 0 \ + && __a->__in6_u.__u6_addr32[2] == 0 \ + && __a->__in6_u.__u6_addr32[3] == 0; })) # define IN6_IS_ADDR_LOOPBACK(a) \ (__extension__ \ ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ - __a->s6_addr32[0] == 0 \ - && __a->s6_addr32[1] == 0 \ - && __a->s6_addr32[2] == 0 \ - && __a->s6_addr32[3] == htonl (1); })) + __a->__in6_u.__u6_addr32[0] == 0 \ + && __a->__in6_u.__u6_addr32[1] == 0 \ + && __a->__in6_u.__u6_addr32[2] == 0 \ + && __a->__in6_u.__u6_addr32[3] == htonl (1); })) # define IN6_IS_ADDR_LINKLOCAL(a) \ (__extension__ \ ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ - (__a->s6_addr32[0] & htonl (0xffc00000)) == htonl (0xfe800000); })) + (__a->__in6_u.__u6_addr32[0] & htonl (0xffc00000)) == htonl (0xfe800000); })) # define IN6_IS_ADDR_SITELOCAL(a) \ (__extension__ \ ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ - (__a->s6_addr32[0] & htonl (0xffc00000)) == htonl (0xfec00000); })) + (__a->__in6_u.__u6_addr32[0] & htonl (0xffc00000)) == htonl (0xfec00000); })) # define IN6_IS_ADDR_V4MAPPED(a) \ (__extension__ \ ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ - __a->s6_addr32[0] == 0 \ - && __a->s6_addr32[1] == 0 \ - && __a->s6_addr32[2] == htonl (0xffff); })) + __a->__in6_u.__u6_addr32[0] == 0 \ + && __a->__in6_u.__u6_addr32[1] == 0 \ + && __a->__in6_u.__u6_addr32[2] == htonl (0xffff); })) # define IN6_IS_ADDR_V4COMPAT(a) \ (__extension__ \ ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ - __a->s6_addr32[0] == 0 \ - && __a->s6_addr32[1] == 0 \ - && __a->s6_addr32[2] == 0 \ - && ntohl (__a->s6_addr32[3]) > 1; })) + __a->__in6_u.__u6_addr32[0] == 0 \ + && __a->__in6_u.__u6_addr32[1] == 0 \ + && __a->__in6_u.__u6_addr32[2] == 0 \ + && ntohl (__a->__in6_u.__u6_addr32[3]) > 1; })) # define IN6_ARE_ADDR_EQUAL(a,b) \ (__extension__ \ ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ const struct in6_addr *__b = (const struct in6_addr *) (b); \ - __a->s6_addr32[0] == __b->s6_addr32[0] \ - && __a->s6_addr32[1] == __b->s6_addr32[1] \ - && __a->s6_addr32[2] == __b->s6_addr32[2] \ - && __a->s6_addr32[3] == __b->s6_addr32[3]; })) + __a->__in6_u.__u6_addr32[0] == __b->__in6_u.__u6_addr32[0] \ + && __a->__in6_u.__u6_addr32[1] == __b->__in6_u.__u6_addr32[1] \ + && __a->__in6_u.__u6_addr32[2] == __b->__in6_u.__u6_addr32[2] \ + && __a->__in6_u.__u6_addr32[3] == __b->__in6_u.__u6_addr32[3]; })) #else # define IN6_IS_ADDR_UNSPECIFIED(a) \ (((const uint32_t *) (a))[0] == 0 \ diff --git a/inet/tst-checks-posix.c b/inet/tst-checks-posix.c new file mode 100644 index 0000000..c41a180 --- /dev/null +++ b/inet/tst-checks-posix.c @@ -0,0 +1,24 @@ +/* Test IPv6 classification macros in POSIX mode. + Copyright (C) 2016 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 + . */ + +/* Process tst-checks.c in POSIX mode. */ +#undef _GNU_SOURCE +#define _POSIX_C_SOURCE 200112L +#define _ISOMAC + +#include "tst-checks.c" diff --git a/inet/tst-checks.c b/inet/tst-checks.c index 5d97564..1a4785d 100644 --- a/inet/tst-checks.c +++ b/inet/tst-checks.c @@ -169,5 +169,4 @@ do_test (void) return result; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include