sys_stat: guarantee struct timespec
authorEric Blake <ebb9@byu.net>
Mon, 12 Oct 2009 16:36:33 +0000 (10:36 -0600)
committerEric Blake <ebb9@byu.net>
Tue, 13 Oct 2009 02:38:51 +0000 (20:38 -0600)
* lib/sys_stat.in.h (includes): Always include <time.h>
* modules/sys_stat (Depends-on): Add time.
* tests/test-sys_stat.c: Guarantee struct timespec, as well as
mode_t permission values.
* doc/posix-headers/sys_stat.texi (sys/stat.h): Document how to
get at subsecond timestamps.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
doc/posix-headers/sys_stat.texi
lib/sys_stat.in.h
modules/sys_stat
tests/test-sys_stat.c

index b46babd..1768d74 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-10-12  Eric Blake  <ebb9@byu.net>
+
+       sys_stat: guarantee struct timespec
+       * lib/sys_stat.in.h (includes): Always include <time.h>
+       * modules/sys_stat (Depends-on): Add time.
+       * tests/test-sys_stat.c: Guarantee struct timespec, as well as
+       mode_t permission values.
+       * doc/posix-headers/sys_stat.texi (sys/stat.h): Document how to
+       get at subsecond timestamps.
+
 2009-10-10  Eric Blake  <ebb9@byu.net>
 
        futimens: new module
index 33c8683..6cfbe3d 100644 (file)
@@ -20,6 +20,10 @@ The functions @code{lstat} and @code{mkdir} are not declared on mingw.
 @item
 The macros @code{UTIME_NOW} and @code{UTIME_OMIT} are missing on some
 platforms.
+@item
+On some platforms, @code{struct stat} does not include @code{st_atim},
+@code{st_mtim}, or @code{st_ctim} members.  Use the gnulib module
+@samp{stat-time} for accessors to portably get at subsecond resolution.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index e543770..296cedd 100644 (file)
@@ -38,6 +38,9 @@
 /* Get nlink_t.  */
 #include <sys/types.h>
 
+/* Get struct timespec.  */
+#include <time.h>
+
 /* The include_next requires a split double-inclusion guard.  */
 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
 
index 5d8b0ef..708491f 100644 (file)
@@ -9,6 +9,7 @@ m4/unistd_h.m4
 Depends-on:
 include_next
 link-warning
+time
 
 configure.ac:
 gl_HEADER_SYS_STAT_H
index 25fe30d..a73f9b8 100644 (file)
@@ -253,6 +253,23 @@ verify (!S_ISWHT (S_IFLNK));
 verify (!S_ISWHT (S_IFSOCK));
 #endif
 
+/* POSIX 2008 requires traditional encoding of permission constants.  */
+verify (S_IRWXU == 00700);
+verify (S_IRUSR == 00400);
+verify (S_IWUSR == 00200);
+verify (S_IXUSR == 00100);
+verify (S_IRWXG == 00070);
+verify (S_IRGRP == 00040);
+verify (S_IWGRP == 00020);
+verify (S_IXGRP == 00010);
+verify (S_IRWXO == 00007);
+verify (S_IROTH == 00004);
+verify (S_IWOTH == 00002);
+verify (S_IXOTH == 00001);
+verify (S_ISUID == 04000);
+verify (S_ISGID == 02000);
+verify (S_ISVTX == 01000);
+
 #if ((0 <= UTIME_NOW && UTIME_NOW < 1000000000)           \
      || (0 <= UTIME_OMIT && UTIME_OMIT < 1000000000)      \
      || UTIME_NOW == UTIME_OMIT)
@@ -262,6 +279,8 @@ invalid UTIME macros
 /* Check the existence of some types.  */
 nlink_t t1;
 
+struct timespec t2;
+
 int
 main ()
 {