struct stat.h with nanosecond resolution
Andreas Jaeger
aj@suse.de
Tue Dec 3 01:28:00 GMT 2002
Ulrich Drepper <drepper@redhat.com> writes:
> Andreas Jaeger wrote:
>
>> Looking at how fileutils handles this, I think we should go with your
>> first proposal.
>>
>> Here's what I'm currently testing,
>
> Looks OK to be. It won't win any contests for elegant programming but
> there is not much we can do.
I noticed some more warning while testing and now use the appended
version (before I defined __timespec every time time.h got included).
I'm building glibc now on i686 and if everything builds and the
testsuite passes will commit the files.
Andreas
============================================================
Index: time/time.h
--- time/time.h 28 Aug 2002 08:01:10 -0000 1.66
+++ time/time.h 3 Dec 2002 09:26:55 -0000
@@ -106,18 +106,25 @@ typedef __timer_t timer_t;
#endif /* timer_t not defined and <time.h> or need timer_t. */
#undef __need_timer_t
+#if !defined ____timespec_defined
+# define ____timespec_defined 1
+/* POSIX.1b structure for a time value. This is like a `struct timeval' but
+ has nanoseconds instead of microseconds. This is an internal name. */
+struct __timespec
+ {
+ __time_t __tv_sec; /* Seconds. */
+ long int __tv_nsec; /* Nanoseconds. */
+ };
+#endif /* ____timespec not defined. */
#if !defined __timespec_defined && \
((defined _TIME_H && defined __USE_POSIX199309) || defined __need_timespec)
# define __timespec_defined 1
-/* POSIX.1b structure for a time value. This is like a `struct timeval' but
- has nanoseconds instead of microseconds. */
-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
#endif /* timespec not defined and <time.h> or need timespec. */
#undef __need_timespec
============================================================
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 3 Dec 2002 09:26:55 -0000
@@ -60,12 +60,9 @@ 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;
- __time_t st_mtime; /* Time of last modification. */
- unsigned long int __unused2;
- __time_t st_ctime; /* Time of last status change. */
- unsigned long int __unused3;
+ 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. */
#ifndef __USE_FILE_OFFSET64
unsigned long int __unused4;
unsigned long int __unused5;
@@ -74,6 +71,10 @@ struct stat
#endif
};
+#define st_atime st_atim.__tv_sec /* Backward compatibility. */
+#define st_mtime st_mtim.__tv_sec
+#define st_ctime st_ctim.__tv_sec
+
#ifdef __USE_LARGEFILE64
struct stat64
{
@@ -91,12 +92,9 @@ struct stat64
__blksize_t st_blksize; /* Optimal block size for I/O. */
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
- __time_t st_atime; /* Time of last access. */
- unsigned long int __unused1;
- __time_t st_mtime; /* Time of last modification. */
- unsigned long int __unused2;
- __time_t st_ctime; /* Time of last status change. */
- unsigned long int __unused3;
+ 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. */
__ino64_t st_ino; /* File serial number. */
};
#endif
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
More information about the Libc-alpha
mailing list