struct stat.h with nanosecond resolution

Roland McGrath roland@redhat.com
Tue Dec 3 13:25:00 GMT 2002


> It's too much for my taste.

I was gagging too much last night to even write about it. :-)

I think your suggestion is fine.  I'd go for __USE_MISC, there is no harm
in it and miscellaneous other systems have similar members in struct stat
(though BSD's are called `st_mtimensec' and the like, no second _).

Checking the feature-test macros is what BSD's struct stat does now.
In nonstandard mode they use the names `st_mtimespec' et al rather than
`st_mtim'.  I am guessing the latter names are used by Solaris or something?

I was thinking about ways to avoid the ugliness and nothing fits to avoid
the macros for the struct timespec type.  You can avoid the st_* macros
that need to use tv_sec in the rhs with:

struct stat {
  ...;
  __extension__ union {
    struct timespec st_mtim;
    __extension__ struct {
      time_t st_mtime;
      __suseconds_t st_mtime_nsec;
    };
  };
};

But that doesn't really help since `struct timespec' itself must be defined
using `tv_sec' or else st_mtim cannot be used normally.  



More information about the Libc-alpha mailing list