From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12150 invoked by alias); 21 Sep 2016 19:04:09 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 12134 invoked by uid 89); 21 Sep 2016 19:04:09 -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,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=__need_size_t, messy, sk:struct_, 2513 X-HELO: mail-yb0-f173.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding; bh=VRwm3bIqMVV7OsxQ3LnIwWQyDpT2JCT/5IronPKX6X0=; b=MbIepTKtXNWjhqvJ4TemAPcH/9osvJyOKI07cPWqWI/i2wFRDItg3Hxg7V7eow5rwj fJD0XHnNCnTJOim0U0RF87HwBo//0j08JFno1EtO04PFgPhMcGpXCSbZUGAYHTM/8Dy0 VD/59VkWcxGGZUaa0Nz3KIs0SgDoEJW9sTZdz6MnVsqOYxl65+J+H7UOuC0yfXQbWhwM g4NxHY11r20KUz1efUh8lIjCu49YhnH/GbfxtBuBlBYmSZnV5uOVbm0tbfzEYs2aroXq vUASkWSs8/OpBACxEGyWU2GP1QlA4usyEL/QTiBBYQ3WngU9/v6rhtPBxJ023alX2Kim OGPw== X-Gm-Message-State: AE9vXwOoCRi+rCn6EPPi4Sjc2+T/rvCCMqs52V3VeOW4G/A4Aop05E4Ju1rEwiIjmi+FDwrf X-Received: by 10.37.16.214 with SMTP id 205mr37219257ybq.41.1474484646363; Wed, 21 Sep 2016 12:04:06 -0700 (PDT) Subject: Re: [PATCH 08/13] Installed-header hygiene (BZ#20366): time.h types. To: Zack Weinberg , libc-alpha@sourceware.org References: <20160830011645.25769-1-zackw@panix.com> <20160830011645.25769-2-zackw@panix.com> <20160830011645.25769-3-zackw@panix.com> <20160830011645.25769-4-zackw@panix.com> <20160830011645.25769-5-zackw@panix.com> <20160830011645.25769-6-zackw@panix.com> <20160830011645.25769-7-zackw@panix.com> <20160830011645.25769-8-zackw@panix.com> <20160830011645.25769-9-zackw@panix.com> Cc: joseph@codesourcery.com From: Carlos O'Donell Message-ID: Date: Wed, 21 Sep 2016 19:04:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160830011645.25769-9-zackw@panix.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-09/txt/msg00418.txt.bz2 On 08/29/2016 09:16 PM, Zack Weinberg wrote: > Many headers are expected to expose a subset of the type definitions > in time.h. time.h has a whole bunch of messy logic for conditionally > defining some its types and structs, but, as best I can tell, this > has never worked 100%. In particular, __need_timespec is ineffective > if _TIME_H has already been defined, which means that if you compile > > #include > #include > > with e.g. -fsyntax-only -std=c89 -Wall -Wsystem-headers, you will get > > In file included from test.c:2:0: > /usr/include/sched.h:74:57: warning: "struct timespec" declared inside > parameter list will not be visible outside of this definition or declaration > extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW; > ^~~~~~~~ > > And if you want to _use_ sched_rr_get_interval in a TU compiled that > way, you're hosed. > > Rather than make the logic in time.h even messier, I had been kicking > around in my head the idea of replacing the __need/__defined mechanism > with a set of small headers, bits/types/foo_t.h for every foo_t that > more than one header may need to define. This seemed like a good > place to give it a try. I rather like the effect; time.h and > bits/time.h are now *much* simpler, and a lot of other headers are > slightly simpler. +1 This is a good way forward. > This is NOT a complete conversion; I have only done the types formerly > accessed by defining __need_something and then including either time.h > or bits/time.h. It should be sufficient as a proof of concept, though. LGTM with the caveat that I have one nit/question below. > diff --git a/posix/sched.h b/posix/sched.h > index 253c963..5b431c6 100644 > --- a/posix/sched.h > +++ b/posix/sched.h > @@ -25,13 +25,14 @@ > #include > > #define __need_size_t > +#define __need_NULL > #include > > -#ifdef __USE_XOPEN2K > -# define __need_time_t > -# define __need_timespec > +#include > +#include > +#ifndef __USE_XOPEN2K > +# include > #endif > -#include Your change unconditionally pulls in the two new headers? Why aren't the original semantics OK? e.g. #ifdef __USE_XOPEN2K # include # include #else # include #endif -- Cheers, Carlos.