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: Carlos O'Donell <carlos at redhat dot com>
- To: Zack Weinberg <zackw at panix 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:50:06 -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> <CAKCAbMiJ2VyNo+zueBNO0BLUhe7PhivAy5FqZ6Bw6f80nkKQ6A@mail.gmail.com>
On 09/21/2016 03:12 PM, Zack Weinberg wrote:
> 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.
I like your version, it makes it clearer that the
time_t and struct timespec are unconditionally needed.
For those following along at home...
Original code:
#ifdef __USE_XOPEN2K
# define __need_time_t
# define __need_timespec
#endif
#include <time.h>
|defined __USE_OPEN2K |#include <time.h> |
-------------------------------------------------
|need time_t |define time_t |
|need timespec |define timespec |
| | |
|!defined __USE_OPEN2K|#include <time.h> |
------------------------------------------------
| |define time_t |
| |define timespec |
| |define the rest of time.h|
Notice `define time_t` and `define timespec` are
present in both cases, but the rest of time.h is
only included when !defined __USE_OPEN2K.
So refactor into:
define time_t
define timespec
!defined __USE_OPEN2K
define the rest of time.h
e.g.
#include <bits/types/time_t.h>
#include <bits/types/struct_timespec.h>
#ifndef __USE_XOPEN2K
# include <time.h>
#endif
--
Cheers,
Carlos.