svn commit: r205792 - in head: lib/libc/sys sys/amd64/linux32 sys/compat/freebsd32 sys/compat/linux sys/compat/svr4 sys/i386/ibcs2 sys/i386/linux sys/kern sys/sys

Ed Schouten ed at FreeBSD.org
Sun Mar 28 13:13:23 UTC 2010


Author: ed
Date: Sun Mar 28 13:13:22 2010
New Revision: 205792
URL: http://svn.freebsd.org/changeset/base/205792

Log:
  Rename st_*timespec fields to st_*tim for POSIX 2008 compliance.
  
  A nice thing about POSIX 2008 is that it finally standardizes a way to
  obtain file access/modification/change times in sub-second precision,
  namely using struct timespec, which we already have for a very long
  time. Unfortunately POSIX uses different names.
  
  This commit adds compatibility macros, so existing code should still
  build properly. Also change all source code in the kernel to work
  without any of the compatibility macros. This makes it all a less
  ambiguous.
  
  I am also renaming st_birthtime to st_birthtim, even though it was a
  local extension anyway. It seems Cygwin also has a st_birthtim.

Modified:
  head/lib/libc/sys/stat.2
  head/sys/amd64/linux32/linux.h
  head/sys/compat/freebsd32/freebsd32.h
  head/sys/compat/freebsd32/freebsd32_misc.c
  head/sys/compat/linux/linux_stats.c
  head/sys/compat/svr4/svr4_stat.c
  head/sys/i386/ibcs2/ibcs2_stat.c
  head/sys/i386/linux/linux.h
  head/sys/kern/sys_pipe.c
  head/sys/kern/tty_pts.c
  head/sys/kern/uipc_mqueue.c
  head/sys/kern/uipc_sem.c
  head/sys/kern/uipc_shm.c
  head/sys/kern/vfs_syscalls.c
  head/sys/kern/vfs_vnops.c
  head/sys/sys/_timespec.h
  head/sys/sys/stat.h
  head/sys/sys/timespec.h

Modified: head/lib/libc/sys/stat.2
==============================================================================
--- head/lib/libc/sys/stat.2	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/lib/libc/sys/stat.2	Sun Mar 28 13:13:22 2010	(r205792)
@@ -149,8 +149,8 @@ fields together identify the file unique
 The time-related fields of
 .Vt "struct stat"
 are as follows:
-.Bl -tag -width ".Va st_birthtime"
-.It Va st_atime
+.Bl -tag -width ".Va st_birthtim"
+.It Va st_atim
 Time when file data last accessed.
 Changed by the
 .Xr mknod 2 ,
@@ -159,7 +159,7 @@ Changed by the
 and
 .Xr readv 2
 system calls.
-.It Va st_mtime
+.It Va st_mtim
 Time when file data last modified.
 Changed by the
 .Xr mkdir 2 ,
@@ -170,7 +170,7 @@ Changed by the
 and
 .Xr writev 2
 system calls.
-.It Va st_ctime
+.It Va st_ctim
 Time when file status was last changed (inode data modification).
 Changed by the
 .Xr chflags 2 ,
@@ -191,18 +191,24 @@ Changed by the
 and
 .Xr writev 2
 system calls.
-.It Va st_birthtime
+.It Va st_birthtim
 Time when the inode was created.
 .El
 .Pp
-If
-.Dv _POSIX_SOURCE
-is not defined, the time-related fields are defined as:
+The following time-related macros are defined for compatibility:
 .Bd -literal
+#define	st_atime		st_atim.tv_sec
+#define	st_mtime		st_mtim.tv_sec
+#define	st_ctime		st_ctim.tv_sec
 #ifndef _POSIX_SOURCE
-#define st_atime st_atimespec.tv_sec
-#define st_mtime st_mtimespec.tv_sec
-#define st_ctime st_ctimespec.tv_sec
+#define	st_birthtime		st_birthtim.tv_sec
+#endif
+
+#ifndef _POSIX_SOURCE
+#define	st_atimespec		st_atim
+#define	st_mtimespec		st_mtim
+#define	st_ctimespec		st_ctim
+#define	st_birthtimespec	st_birthtim
 #endif
 .Ed
 .Pp

Modified: head/sys/amd64/linux32/linux.h
==============================================================================
--- head/sys/amd64/linux32/linux.h	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/amd64/linux32/linux.h	Sun Mar 28 13:13:22 2010	(r205792)
@@ -203,9 +203,9 @@ struct l_newstat {
 	l_ulong		st_size;
 	l_ulong		st_blksize;
 	l_ulong		st_blocks;
-	struct l_timespec	st_atimespec;
-	struct l_timespec	st_mtimespec;
-	struct l_timespec	st_ctimespec;
+	struct l_timespec	st_atim;
+	struct l_timespec	st_mtim;
+	struct l_timespec	st_ctim;
 	l_ulong		__unused4;
 	l_ulong		__unused5;
 } __packed;
@@ -219,9 +219,9 @@ struct l_stat {
 	l_ushort	st_gid;
 	l_ushort	st_rdev;
 	l_long		st_size;
-	struct l_timespec	st_atimespec;
-	struct l_timespec	st_mtimespec;
-	struct l_timespec	st_ctimespec;
+	struct l_timespec	st_atim;
+	struct l_timespec	st_mtim;
+	struct l_timespec	st_ctim;
 	l_long		st_blksize;
 	l_long		st_blocks;
 	l_ulong		st_flags;
@@ -242,9 +242,9 @@ struct l_stat64 {
 	l_ulong		st_blksize;
 	l_ulong		st_blocks;
 	l_ulong		__pad4;
-	struct l_timespec	st_atimespec;
-	struct l_timespec	st_mtimespec;
-	struct l_timespec	st_ctimespec;
+	struct l_timespec	st_atim;
+	struct l_timespec	st_mtim;
+	struct l_timespec	st_ctim;
 	l_ulonglong	st_ino;
 } __packed;
 

Modified: head/sys/compat/freebsd32/freebsd32.h
==============================================================================
--- head/sys/compat/freebsd32/freebsd32.h	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/compat/freebsd32/freebsd32.h	Sun Mar 28 13:13:22 2010	(r205792)
@@ -143,15 +143,15 @@ struct stat32 {
 	uid_t	st_uid;
 	gid_t	st_gid;
 	dev_t	st_rdev;
-	struct timespec32 st_atimespec;
-	struct timespec32 st_mtimespec;
-	struct timespec32 st_ctimespec;
+	struct timespec32 st_atim;
+	struct timespec32 st_mtim;
+	struct timespec32 st_ctim;
 	off_t	st_size;
 	int64_t	st_blocks;
 	u_int32_t st_blksize;
 	u_int32_t st_flags;
 	u_int32_t st_gen;
-	struct timespec32 st_birthtimespec;
+	struct timespec32 st_birthtim;
 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
 };

Modified: head/sys/compat/freebsd32/freebsd32_misc.c
==============================================================================
--- head/sys/compat/freebsd32/freebsd32_misc.c	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/compat/freebsd32/freebsd32_misc.c	Sun Mar 28 13:13:22 2010	(r205792)
@@ -1634,9 +1634,9 @@ copy_stat( struct stat *in, struct stat3
 	CP(*in, *out, st_uid);
 	CP(*in, *out, st_gid);
 	CP(*in, *out, st_rdev);
-	TS_CP(*in, *out, st_atimespec);
-	TS_CP(*in, *out, st_mtimespec);
-	TS_CP(*in, *out, st_ctimespec);
+	TS_CP(*in, *out, st_atim);
+	TS_CP(*in, *out, st_mtim);
+	TS_CP(*in, *out, st_ctim);
 	CP(*in, *out, st_size);
 	CP(*in, *out, st_blocks);
 	CP(*in, *out, st_blksize);

Modified: head/sys/compat/linux/linux_stats.c
==============================================================================
--- head/sys/compat/linux/linux_stats.c	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/compat/linux/linux_stats.c	Sun Mar 28 13:13:22 2010	(r205792)
@@ -173,9 +173,12 @@ newstat_copyout(struct stat *buf, void *
 	tbuf.st_gid = buf->st_gid;
 	tbuf.st_rdev = buf->st_rdev;
 	tbuf.st_size = buf->st_size;
-	tbuf.st_atime = buf->st_atime;
-	tbuf.st_mtime = buf->st_mtime;
-	tbuf.st_ctime = buf->st_ctime;
+	tbuf.st_atim.tv_sec = buf->st_atim.tv_sec;
+	tbuf.st_atim.tv_nsec = buf->st_atim.tv_nsec;
+	tbuf.st_mtim.tv_sec = buf->st_mtim.tv_sec;
+	tbuf.st_mtim.tv_nsec = buf->st_mtim.tv_nsec;
+	tbuf.st_ctim.tv_sec = buf->st_ctim.tv_sec;
+	tbuf.st_ctim.tv_nsec = buf->st_ctim.tv_nsec;
 	tbuf.st_blksize = buf->st_blksize;
 	tbuf.st_blocks = buf->st_blocks;
 
@@ -260,9 +263,12 @@ stat_copyout(struct stat *buf, void *ubu
 		lbuf.st_size = buf->st_size;
 	else
 		lbuf.st_size = -2;
-	lbuf.st_atime = buf->st_atime;
-	lbuf.st_mtime = buf->st_mtime;
-	lbuf.st_ctime = buf->st_ctime;
+	lbuf.st_atim.tv_sec = buf->st_atim.tv_sec;
+	lbuf.st_atim.tv_nsec = buf->st_atim.tv_nsec;
+	lbuf.st_mtim.tv_sec = buf->st_mtim.tv_sec;
+	lbuf.st_mtim.tv_nsec = buf->st_mtim.tv_nsec;
+	lbuf.st_ctim.tv_sec = buf->st_ctim.tv_sec;
+	lbuf.st_ctim.tv_nsec = buf->st_ctim.tv_nsec;
 	lbuf.st_blksize = buf->st_blksize;
 	lbuf.st_blocks = buf->st_blocks;
 	lbuf.st_flags = buf->st_flags;
@@ -498,9 +504,12 @@ stat64_copyout(struct stat *buf, void *u
 	lbuf.st_gid = buf->st_gid;
 	lbuf.st_rdev = buf->st_rdev;
 	lbuf.st_size = buf->st_size;
-	lbuf.st_atime = buf->st_atime;
-	lbuf.st_mtime = buf->st_mtime;
-	lbuf.st_ctime = buf->st_ctime;
+	lbuf.st_atim.tv_sec = buf->st_atim.tv_sec;
+	lbuf.st_atim.tv_nsec = buf->st_atim.tv_nsec;
+	lbuf.st_mtim.tv_sec = buf->st_mtim.tv_sec;
+	lbuf.st_mtim.tv_nsec = buf->st_mtim.tv_nsec;
+	lbuf.st_ctim.tv_sec = buf->st_ctim.tv_sec;
+	lbuf.st_ctim.tv_nsec = buf->st_ctim.tv_nsec;
 	lbuf.st_blksize = buf->st_blksize;
 	lbuf.st_blocks = buf->st_blocks;
 

Modified: head/sys/compat/svr4/svr4_stat.c
==============================================================================
--- head/sys/compat/svr4/svr4_stat.c	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/compat/svr4/svr4_stat.c	Sun Mar 28 13:13:22 2010	(r205792)
@@ -106,9 +106,9 @@ bsd_to_svr4_stat(st, st4)
 	st4->st_gid = st->st_gid;
 	st4->st_rdev = bsd_to_svr4_odev_t(st->st_rdev);
 	st4->st_size = st->st_size;
-	st4->st_atim = st->st_atimespec.tv_sec;
-	st4->st_mtim = st->st_mtimespec.tv_sec;
-	st4->st_ctim = st->st_ctimespec.tv_sec;
+	st4->st_atim = st->st_atim.tv_sec;
+	st4->st_mtim = st->st_mtim.tv_sec;
+	st4->st_ctim = st->st_ctim.tv_sec;
 }
 #endif
 
@@ -127,9 +127,9 @@ bsd_to_svr4_xstat(st, st4)
 	st4->st_gid = st->st_gid;
 	st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
 	st4->st_size = st->st_size;
-	st4->st_atim = st->st_atimespec;
-	st4->st_mtim = st->st_mtimespec;
-	st4->st_ctim = st->st_ctimespec;
+	st4->st_atim = st->st_atim;
+	st4->st_mtim = st->st_mtim;
+	st4->st_ctim = st->st_ctim;
 	st4->st_blksize = st->st_blksize;
 	st4->st_blocks = st->st_blocks;
 	strcpy(st4->st_fstype, "unknown");
@@ -150,9 +150,9 @@ bsd_to_svr4_stat64(st, st4)
 	st4->st_gid = st->st_gid;
 	st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
 	st4->st_size = st->st_size;
-	st4->st_atim = st->st_atimespec;
-	st4->st_mtim = st->st_mtimespec;
-	st4->st_ctim = st->st_ctimespec;
+	st4->st_atim = st->st_atim;
+	st4->st_mtim = st->st_mtim;
+	st4->st_ctim = st->st_ctim;
 	st4->st_blksize = st->st_blksize;
 	st4->st_blocks = st->st_blocks;
 	strcpy(st4->st_fstype, "unknown");

Modified: head/sys/i386/ibcs2/ibcs2_stat.c
==============================================================================
--- head/sys/i386/ibcs2/ibcs2_stat.c	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/i386/ibcs2/ibcs2_stat.c	Sun Mar 28 13:13:22 2010	(r205792)
@@ -72,9 +72,9 @@ bsd_stat2ibcs_stat(st, st4)
 		st4->st_size = (ibcs2_off_t)st->st_size;
 	else
 		st4->st_size = -2;
-	st4->st_atim = (ibcs2_time_t)st->st_atime;
-	st4->st_mtim = (ibcs2_time_t)st->st_mtime;
-	st4->st_ctim = (ibcs2_time_t)st->st_ctime;
+	st4->st_atim = (ibcs2_time_t)st->st_atim.tv_sec;
+	st4->st_mtim = (ibcs2_time_t)st->st_mtim.tv_sec;
+	st4->st_ctim = (ibcs2_time_t)st->st_ctim.tv_sec;
 }
 
 static int

Modified: head/sys/i386/linux/linux.h
==============================================================================
--- head/sys/i386/linux/linux.h	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/i386/linux/linux.h	Sun Mar 28 13:13:22 2010	(r205792)
@@ -178,9 +178,9 @@ struct l_newstat {
 	l_ulong		st_size;
 	l_ulong		st_blksize;
 	l_ulong		st_blocks;
-	struct l_timespec	st_atimespec;
-	struct l_timespec	st_mtimespec;
-	struct l_timespec	st_ctimespec;
+	struct l_timespec	st_atim;
+	struct l_timespec	st_mtim;
+	struct l_timespec	st_ctim;
 	l_ulong		__unused4;
 	l_ulong		__unused5;
 };
@@ -194,9 +194,9 @@ struct l_stat {
 	l_ushort	st_gid;
 	l_ushort	st_rdev;
 	l_long		st_size;
-	struct l_timespec	st_atimespec;
-	struct l_timespec	st_mtimespec;
-	struct l_timespec	st_ctimespec;
+	struct l_timespec	st_atim;
+	struct l_timespec	st_mtim;
+	struct l_timespec	st_ctim;
 	l_long		st_blksize;
 	l_long		st_blocks;
 	l_ulong		st_flags;
@@ -217,9 +217,9 @@ struct l_stat64 {
 	l_ulong		st_blksize;
 	l_ulong		st_blocks;
 	l_ulong		__pad4;
-	struct l_timespec	st_atimespec;
-	struct l_timespec	st_mtimespec;
-	struct l_timespec	st_ctimespec;
+	struct l_timespec	st_atim;
+	struct l_timespec	st_mtim;
+	struct l_timespec	st_ctim;
 	l_ulonglong	st_ino;
 };
 

Modified: head/sys/kern/sys_pipe.c
==============================================================================
--- head/sys/kern/sys_pipe.c	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/kern/sys_pipe.c	Sun Mar 28 13:13:22 2010	(r205792)
@@ -1428,9 +1428,9 @@ pipe_stat(fp, ub, active_cred, td)
 	else
 		ub->st_size = pipe->pipe_buffer.cnt;
 	ub->st_blocks = (ub->st_size + ub->st_blksize - 1) / ub->st_blksize;
-	ub->st_atimespec = pipe->pipe_atime;
-	ub->st_mtimespec = pipe->pipe_mtime;
-	ub->st_ctimespec = pipe->pipe_ctime;
+	ub->st_atim = pipe->pipe_atime;
+	ub->st_mtim = pipe->pipe_mtime;
+	ub->st_ctim = pipe->pipe_ctime;
 	ub->st_uid = fp->f_cred->cr_uid;
 	ub->st_gid = fp->f_cred->cr_gid;
 	/*

Modified: head/sys/kern/tty_pts.c
==============================================================================
--- head/sys/kern/tty_pts.c	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/kern/tty_pts.c	Sun Mar 28 13:13:22 2010	(r205792)
@@ -556,9 +556,9 @@ ptsdev_stat(struct file *fp, struct stat
 #endif /* PTS_EXTERNAL */
 		sb->st_ino = sb->st_rdev = tty_udev(tp);
 
-	sb->st_atimespec = dev->si_atime;
-	sb->st_ctimespec = dev->si_ctime;
-	sb->st_mtimespec = dev->si_mtime;
+	sb->st_atim = dev->si_atime;
+	sb->st_ctim = dev->si_ctime;
+	sb->st_mtim = dev->si_mtime;
 	sb->st_uid = dev->si_uid;
 	sb->st_gid = dev->si_gid;
 	sb->st_mode = dev->si_mode | S_IFCHR;

Modified: head/sys/kern/uipc_mqueue.c
==============================================================================
--- head/sys/kern/uipc_mqueue.c	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/kern/uipc_mqueue.c	Sun Mar 28 13:13:22 2010	(r205792)
@@ -2447,10 +2447,10 @@ mqf_stat(struct file *fp, struct stat *s
 	struct mqfs_node *pn = fp->f_data;
 
 	bzero(st, sizeof *st);
-	st->st_atimespec = pn->mn_atime;
-	st->st_mtimespec = pn->mn_mtime;
-	st->st_ctimespec = pn->mn_ctime;
-	st->st_birthtimespec = pn->mn_birth;
+	st->st_atim = pn->mn_atime;
+	st->st_mtim = pn->mn_mtime;
+	st->st_ctim = pn->mn_ctime;
+	st->st_birthtim = pn->mn_birth;
 	st->st_uid = pn->mn_uid;
 	st->st_gid = pn->mn_gid;
 	st->st_mode = S_IFIFO | pn->mn_mode;

Modified: head/sys/kern/uipc_sem.c
==============================================================================
--- head/sys/kern/uipc_sem.c	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/kern/uipc_sem.c	Sun Mar 28 13:13:22 2010	(r205792)
@@ -219,10 +219,10 @@ ksem_stat(struct file *fp, struct stat *
 	bzero(sb, sizeof(*sb));
 	sb->st_mode = S_IFREG | ks->ks_mode;		/* XXX */
 
-	sb->st_atimespec = ks->ks_atime;
-	sb->st_ctimespec = ks->ks_ctime;
-	sb->st_mtimespec = ks->ks_mtime;
-	sb->st_birthtimespec = ks->ks_birthtime;	
+	sb->st_atim = ks->ks_atime;
+	sb->st_ctim = ks->ks_ctime;
+	sb->st_mtim = ks->ks_mtime;
+	sb->st_birthtim = ks->ks_birthtime;	
 	sb->st_uid = ks->ks_uid;
 	sb->st_gid = ks->ks_gid;
 

Modified: head/sys/kern/uipc_shm.c
==============================================================================
--- head/sys/kern/uipc_shm.c	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/kern/uipc_shm.c	Sun Mar 28 13:13:22 2010	(r205792)
@@ -219,10 +219,10 @@ shm_stat(struct file *fp, struct stat *s
 	sb->st_blksize = PAGE_SIZE;
 	sb->st_size = shmfd->shm_size;
 	sb->st_blocks = (sb->st_size + sb->st_blksize - 1) / sb->st_blksize;
-	sb->st_atimespec = shmfd->shm_atime;
-	sb->st_ctimespec = shmfd->shm_ctime;
-	sb->st_mtimespec = shmfd->shm_mtime;
-	sb->st_birthtimespec = shmfd->shm_birthtime;	
+	sb->st_atim = shmfd->shm_atime;
+	sb->st_ctim = shmfd->shm_ctime;
+	sb->st_mtim = shmfd->shm_mtime;
+	sb->st_birthtim = shmfd->shm_birthtime;	
 	sb->st_uid = shmfd->shm_uid;
 	sb->st_gid = shmfd->shm_gid;
 

Modified: head/sys/kern/vfs_syscalls.c
==============================================================================
--- head/sys/kern/vfs_syscalls.c	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/kern/vfs_syscalls.c	Sun Mar 28 13:13:22 2010	(r205792)
@@ -2269,9 +2269,9 @@ cvtstat(st, ost)
 		ost->st_size = st->st_size;
 	else
 		ost->st_size = -2;
-	ost->st_atime = st->st_atime;
-	ost->st_mtime = st->st_mtime;
-	ost->st_ctime = st->st_ctime;
+	ost->st_atim = st->st_atim;
+	ost->st_mtim = st->st_mtim;
+	ost->st_ctim = st->st_ctim;
 	ost->st_blksize = st->st_blksize;
 	ost->st_blocks = st->st_blocks;
 	ost->st_flags = st->st_flags;
@@ -2431,15 +2431,15 @@ cvtnstat(sb, nsb)
 	nsb->st_uid = sb->st_uid;
 	nsb->st_gid = sb->st_gid;
 	nsb->st_rdev = sb->st_rdev;
-	nsb->st_atimespec = sb->st_atimespec;
-	nsb->st_mtimespec = sb->st_mtimespec;
-	nsb->st_ctimespec = sb->st_ctimespec;
+	nsb->st_atim = sb->st_atim;
+	nsb->st_mtim = sb->st_mtim;
+	nsb->st_ctim = sb->st_ctim;
 	nsb->st_size = sb->st_size;
 	nsb->st_blocks = sb->st_blocks;
 	nsb->st_blksize = sb->st_blksize;
 	nsb->st_flags = sb->st_flags;
 	nsb->st_gen = sb->st_gen;
-	nsb->st_birthtimespec = sb->st_birthtimespec;
+	nsb->st_birthtim = sb->st_birthtim;
 }
 
 #ifndef _SYS_SYSPROTO_H_

Modified: head/sys/kern/vfs_vnops.c
==============================================================================
--- head/sys/kern/vfs_vnops.c	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/kern/vfs_vnops.c	Sun Mar 28 13:13:22 2010	(r205792)
@@ -782,10 +782,10 @@ vn_stat(vp, sb, active_cred, file_cred, 
 	if (vap->va_size > OFF_MAX)
 		return (EOVERFLOW);
 	sb->st_size = vap->va_size;
-	sb->st_atimespec = vap->va_atime;
-	sb->st_mtimespec = vap->va_mtime;
-	sb->st_ctimespec = vap->va_ctime;
-	sb->st_birthtimespec = vap->va_birthtime;
+	sb->st_atim = vap->va_atime;
+	sb->st_mtim = vap->va_mtime;
+	sb->st_ctim = vap->va_ctime;
+	sb->st_birthtim = vap->va_birthtime;
 
         /*
 	 * According to www.opengroup.org, the meaning of st_blksize is 

Modified: head/sys/sys/_timespec.h
==============================================================================
--- head/sys/sys/_timespec.h	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/sys/_timespec.h	Sun Mar 28 13:13:22 2010	(r205792)
@@ -31,26 +31,18 @@
  *	$FreeBSD$
  */
 
-/*
- * Prerequisite: <sys/_types.h>
- *
- * This file must be kept synchronized with <sys/timespec.h>.
- * It defines a structure which must be a type pun for
- * `struct timespec'; this structure is used in header files where
- * the ABI uses a `struct timespec' but standards prohibit its
- * definition.  (Currently only <sys/stat.h>.)
- *
- * XXX should just declare struct __timespec as necessary.  It's simple,
- * so is easy to keep synchronized, and hopefully not needed in as many
- * places as struct timespec, so we don't need this extra header.
- * Perhaps we don't need timespec.h either.
- */
-
 #ifndef _SYS__TIMESPEC_H_
 #define	_SYS__TIMESPEC_H_
 
-struct __timespec {
-	__time_t tv_sec;	/* seconds */
+#include <sys/_types.h>
+
+#ifndef _TIME_T_DECLARED
+typedef	__time_t	time_t;
+#define	_TIME_T_DECLARED
+#endif
+
+struct timespec {
+	time_t	tv_sec;		/* seconds */
 	long	tv_nsec;	/* and nanoseconds */
 };
 

Modified: head/sys/sys/stat.h
==============================================================================
--- head/sys/sys/stat.h	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/sys/stat.h	Sun Mar 28 13:13:22 2010	(r205792)
@@ -39,6 +39,7 @@
 #define	_SYS_STAT_H_
 
 #include <sys/cdefs.h>
+#include <sys/_timespec.h>
 #include <sys/_types.h>
 
 #ifndef _BLKSIZE_T_DECLARED
@@ -86,11 +87,6 @@ typedef	__off_t		off_t;
 #define	_OFF_T_DECLARED
 #endif
 
-#ifndef _TIME_T_DECLARED
-typedef	__time_t	time_t;
-#define	_TIME_T_DECLARED
-#endif
-
 #ifndef _UID_T_DECLARED
 typedef	__uid_t		uid_t;
 #define	_UID_T_DECLARED
@@ -98,16 +94,11 @@ typedef	__uid_t		uid_t;
 
 #if !defined(_KERNEL) && __BSD_VISIBLE
 /*
- * XXX we need this for struct timespec.  We get miscellaneous namespace
- * pollution with it.
+ * XXX We get miscellaneous namespace pollution with this.
  */
 #include <sys/time.h>
 #endif
 
-#if !__BSD_VISIBLE
-#include <sys/_timespec.h>
-#endif
-
 #if __BSD_VISIBLE
 struct ostat {
 	__uint16_t st_dev;		/* inode's device */
@@ -118,9 +109,9 @@ struct ostat {
 	__uint16_t st_gid;		/* group ID of the file's group */
 	__uint16_t st_rdev;		/* device type */
 	__int32_t st_size;		/* file size, in bytes */
-	struct	timespec st_atimespec;	/* time of last access */
-	struct	timespec st_mtimespec;	/* time of last data modification */
-	struct	timespec st_ctimespec;	/* time of last file status change */
+	struct	timespec st_atim;	/* time of last access */
+	struct	timespec st_mtim;	/* time of last data modification */
+	struct	timespec st_ctim;	/* time of last file status change */
 	__int32_t st_blksize;		/* optimal blocksize for I/O */
 	__int32_t st_blocks;		/* blocks allocated for file */
 	fflags_t  st_flags;		/* user defined flags for file */
@@ -136,28 +127,18 @@ struct stat {
 	uid_t	  st_uid;		/* user ID of the file's owner */
 	gid_t	  st_gid;		/* group ID of the file's group */
 	__dev_t   st_rdev;		/* device type */
-#if __BSD_VISIBLE
-	struct	timespec st_atimespec;	/* time of last access */
-	struct	timespec st_mtimespec;	/* time of last data modification */
-	struct	timespec st_ctimespec;	/* time of last file status change */
-#else
-	time_t	  st_atime;		/* time of last access */
-	long	  __st_atimensec;	/* nsec of last access */
-	time_t	  st_mtime;		/* time of last data modification */
-	long	  __st_mtimensec;	/* nsec of last data modification */
-	time_t	  st_ctime;		/* time of last file status change */
-	long	  __st_ctimensec;	/* nsec of last file status change */
-#endif
+	struct	timespec st_atim;	/* time of last access */
+	struct	timespec st_mtim;	/* time of last data modification */
+	struct	timespec st_ctim;	/* time of last file status change */
 	off_t	  st_size;		/* file size, in bytes */
 	blkcnt_t st_blocks;		/* blocks allocated for file */
 	blksize_t st_blksize;		/* optimal blocksize for I/O */
 	fflags_t  st_flags;		/* user defined flags for file */
 	__uint32_t st_gen;		/* file generation number */
 	__int32_t st_lspare;
-#if __BSD_VISIBLE
-	struct timespec st_birthtimespec; /* time of file creation */
+	struct timespec st_birthtim;	/* time of file creation */
 	/*
-	 * Explicitly pad st_birthtimespec to 16 bytes so that the size of
+	 * Explicitly pad st_birthtim to 16 bytes so that the size of
 	 * struct stat is backwards compatible.  We use bitfields instead
 	 * of an array of chars so that this doesn't require a C99 compiler
 	 * to compile if the size of the padding is 0.  We use 2 bitfields
@@ -166,12 +147,6 @@ struct stat {
 	 */
 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
-#else
-	time_t	  st_birthtime;		/* time of file creation */
-	long	  st_birthtimensec;	/* nsec of file creation */
-	unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
-	unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
-#endif
 };
 
 #if __BSD_VISIBLE
@@ -183,15 +158,15 @@ struct nstat {
 	uid_t	  st_uid;		/* user ID of the file's owner */
 	gid_t	  st_gid;		/* group ID of the file's group */
 	__dev_t   st_rdev;		/* device type */
-	struct	timespec st_atimespec;	/* time of last access */
-	struct	timespec st_mtimespec;	/* time of last data modification */
-	struct	timespec st_ctimespec;	/* time of last file status change */
+	struct	timespec st_atim;	/* time of last access */
+	struct	timespec st_mtim;	/* time of last data modification */
+	struct	timespec st_ctim;	/* time of last file status change */
 	off_t	  st_size;		/* file size, in bytes */
 	blkcnt_t st_blocks;		/* blocks allocated for file */
 	blksize_t st_blksize;		/* optimal blocksize for I/O */
 	fflags_t  st_flags;		/* user defined flags for file */
 	__uint32_t st_gen;		/* file generation number */
-	struct timespec st_birthtimespec; /* time of file creation */
+	struct timespec st_birthtim;	/* time of file creation */
 	/*
 	 * See above about the following padding.
 	 */
@@ -200,13 +175,23 @@ struct nstat {
 };
 #endif
 
+#ifndef _KERNEL
+#define	st_atime		st_atim.tv_sec
+#define	st_mtime		st_mtim.tv_sec
+#define	st_ctime		st_ctim.tv_sec
 #if __BSD_VISIBLE
-#define st_atime st_atimespec.tv_sec
-#define st_mtime st_mtimespec.tv_sec
-#define st_ctime st_ctimespec.tv_sec
-#define st_birthtime st_birthtimespec.tv_sec
+#define	st_birthtime		st_birthtim.tv_sec
 #endif
 
+/* For compatibility. */
+#if __BSD_VISIBLE
+#define	st_atimespec		st_atim
+#define	st_mtimespec		st_mtim
+#define	st_ctimespec		st_ctim
+#define	st_birthtimespec	st_birthtim
+#endif
+#endif /* !_KERNEL */
+
 #define	S_ISUID	0004000			/* set user id on execution */
 #define	S_ISGID	0002000			/* set group id on execution */
 #if __BSD_VISIBLE

Modified: head/sys/sys/timespec.h
==============================================================================
--- head/sys/sys/timespec.h	Sun Mar 28 12:55:31 2010	(r205791)
+++ head/sys/sys/timespec.h	Sun Mar 28 13:13:22 2010	(r205792)
@@ -31,22 +31,11 @@
  *	$FreeBSD$
  */
 
-/*
- * Prerequisites: <sys/cdefs.h>, <sys/_types.h>
- */
-
 #ifndef _SYS_TIMESPEC_H_
 #define _SYS_TIMESPEC_H_
 
-#ifndef _TIME_T_DECLARED
-typedef	__time_t	time_t;
-#define	_TIME_T_DECLARED
-#endif
-
-struct timespec {
-	time_t	tv_sec;		/* seconds */
-	long	tv_nsec;	/* and nanoseconds */
-};
+#include <sys/cdefs.h>
+#include <sys/_timespec.h>
 
 #if __BSD_VISIBLE
 #define	TIMEVAL_TO_TIMESPEC(tv, ts)					\


More information about the svn-src-head mailing list