This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: struct stat.h with nanosecond resolution
- From: Ulrich Drepper <drepper at redhat dot com>
- To: Andreas Jaeger <aj at suse dot de>
- Cc: Roland McGrath <roland at redhat dot com>, Andi Kleen <ak at suse dot de>, GNU libc alpha <libc-alpha at sources dot redhat dot com>
- Date: Sat, 28 Dec 2002 12:48:58 -0800
- Subject: Re: struct stat.h with nanosecond resolution
- Organization: Red Hat, Inc.
- References: <200212032125.gB3LPdJ02740@magilla.sf.frob.com> <u8r8c2jgnq.fsf@gromit.moeb>
The patch looks mostly OK. I don't like the transparent union thing
very much. Let's keep it simple.
=====================
> Index: sysdeps/unix/sysv/linux/bits/stat.h
> --- sysdeps/unix/sysv/linux/bits/stat.h 8 Feb 2002 07:48:10 -0000 1.15
> +++ sysdeps/unix/sysv/linux/bits/stat.h 28 Dec 2002 14:38:47 -0000
> @@ -60,12 +60,21 @@ struct stat
> #else
> __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
> #endif
> - __time_t st_atime; /* Time of last access. */
> - unsigned long int __unused1;
> +#ifdef __USE_MISC
> + struct timespec st_atim; /* Time of last access. */
> + struct timespec st_mtim; /* Time of last modification. */
> + struct timespec st_ctim; /* Time of last status change. */
> +# define st_atime st_atim.tv_sec /* Backward compatibility. */
> +# define st_mtime st_mtim.tv_sec
> +# define st_ctime st_ctim.tv_sec
> +#else
> + time_t st_atime; /* Time of last access. */
Why is the type changed to time_t? It should remain __time_t. See the
other fields, they are not changed.
The struct definitions should also contain a comment explaining this
ugly hack. There are people out there who compile their sources with
the POSIX options only enabled. If this code gets reused in a
_GNU_SOURCE context or so it might be a surprise that it fails.
--
--------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------