This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 08/13] Installed-header hygiene (BZ#20366): time.h types.

On 09/21/2016 03:12 PM, Zack Weinberg wrote:
> On Wed, Sep 21, 2016 at 3:04 PM, Carlos O'Donell <> 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
#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


#include <bits/types/time_t.h>
#include <bits/types/struct_timespec.h>
#ifndef __USE_XOPEN2K
# include <time.h>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]