From: Eric Blake Date: Mon, 12 Oct 2009 16:36:33 +0000 (-0600) Subject: sys_stat: guarantee struct timespec X-Git-Tag: v0.1~5324 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=4754ac9d681d36e16e92a1b08efb1d334d7b3829;p=gnulib.git sys_stat: guarantee struct timespec * lib/sys_stat.in.h (includes): Always include * 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 --- diff --git a/ChangeLog b/ChangeLog index b46babd08..1768d740d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-10-12 Eric Blake + + sys_stat: guarantee struct timespec + * lib/sys_stat.in.h (includes): Always include + * 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 futimens: new module diff --git a/doc/posix-headers/sys_stat.texi b/doc/posix-headers/sys_stat.texi index 33c8683d2..6cfbe3d60 100644 --- a/doc/posix-headers/sys_stat.texi +++ b/doc/posix-headers/sys_stat.texi @@ -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: diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h index e54377096..296cedde3 100644 --- a/lib/sys_stat.in.h +++ b/lib/sys_stat.in.h @@ -38,6 +38,9 @@ /* Get nlink_t. */ #include +/* Get struct timespec. */ +#include + /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@ diff --git a/modules/sys_stat b/modules/sys_stat index 5d8b0ef05..708491f73 100644 --- a/modules/sys_stat +++ b/modules/sys_stat @@ -9,6 +9,7 @@ m4/unistd_h.m4 Depends-on: include_next link-warning +time configure.ac: gl_HEADER_SYS_STAT_H diff --git a/tests/test-sys_stat.c b/tests/test-sys_stat.c index 25fe30d08..a73f9b81c 100644 --- a/tests/test-sys_stat.c +++ b/tests/test-sys_stat.c @@ -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 () {