This is the mail archive of the libc-alpha@sources.redhat.com 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: struct stat.h with nanosecond resolution


Andreas Jaeger <aj@suse.de> writes:

> Ulrich Drepper <drepper@redhat.com> writes:
>
>> Andreas Jaeger wrote:
>>
>>> I'm not sure that this is right either.  Uli, what is the proper way
>>> to handle <time.h>?  I currently don't see a clean solution for
>>> this:-(
>>
>> We have something similar in a number of places.
>>
>> <time.h> unconditionally defines struct __timespec.  The member names
>> are namespace-protected as well.
>>
>> If __need_timespec is defined or <time.h> is included normally three new
>> macros are defined:
>>
>> #define timespec __timespec
>> #define tv_sec __tv_sec
>> #define tv_nsec __tv_nsec

This will not work since it clashes with struct timeval which is
defined as:

struct timeval
  {
    __time_t tv_sec;            /* Seconds.  */
    __suseconds_t tv_usec;      /* Microseconds.  */
  };

Together with this:

struct __timespec
  {
    __time_t __tv_sec;		/* Seconds.  */
    long int __tv_nsec;		/* Nanoseconds.  */
  };

/* Define exported names for POSIX.1b timespec structure.  */
# define timespec __timespec
# define tv_sec __tv_sec
# define tv_nsec __tv_nsec

We get a redefine of the timeval member and thus an error:
In file included from ../sysdeps/unix/sysv/linux/ftime.c:3:
../sysdeps/unix/bsd/ftime.c: In function `ftime':
../sysdeps/unix/bsd/ftime.c:32: error: structure has no member named `__tv_sec'

Do we really need to rename the members of struct __timespec also?

Not doing so, would avoid this problem.

Andreas
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj


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