This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 08/13] Installed-header hygiene (BZ#20366): time.h types.
- From: Zack Weinberg <zackw at panix dot com>
- To: "Carlos O'Donell" <carlos at redhat dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>, Joseph Myers <joseph at codesourcery dot com>
- Date: Wed, 21 Sep 2016 15:12:37 -0400
- Subject: Re: [PATCH 08/13] Installed-header hygiene (BZ#20366): time.h types.
- Authentication-results: sourceware.org; auth=none
- 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> <a3df7265-a24f-c756-b0fb-359216153f8f@redhat.com>
On Wed, Sep 21, 2016 at 3:04 PM, Carlos O'Donell <carlos@redhat.com> wrote:
>> -#ifdef __USE_XOPEN2K
>> -# define __need_time_t
>> -# define __need_timespec
>> +#include <bits/types/time_t.h>
>> +#include <bits/types/struct_timespec.h>
>> +#ifndef __USE_XOPEN2K
>> +# include <time.h>
>> #endif
>> -#include <time.h>
>
> Your change unconditionally pulls in the two new headers?
>
> Why aren't the original semantics OK?
It _is_ the original semantics. Before the patch, we have
#ifdef __USE_XOPEN2K
# define __need_time_t
# define __need_timespec
#endif
#include <time.h>
i.e. always include time.h, but under __USE_XOPEN2K, ask it to define
only time_t and struct timespec. In other words, time_t and struct
timespec are always exposed by sched.h, and if __USE_XOPEN2K is *not*
defined, then so is the rest of time.h. That translates directly to
#include <bits/types/time_t.h>
#include <bits/types/struct_timespec.h>
#ifndef __USE_XOPEN2K
# include <time.h>
#endif
with the new mechanism. (I have doubts about whether this is the
_right_ thing for this header to be doing, but it is what conform/
expects it to do.)
Your version
> #ifdef __USE_XOPEN2K
> # include <bits/types/time_t.h>
> # include <bits/types/struct_timespec.h>
> #else
> # include <time.h>
> #endif
does the same thing as well, since time.h will unconditionally include
both headers. I don't really care which version we go with.
zw