Mercurial > hg > octave-lojdl > gnulib-hg
changeset 12163:e16b6783660e
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.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Mon, 12 Oct 2009 10:36:33 -0600 |
parents | fe82ecf4f214 |
children | 0f120c1de4c5 |
files | ChangeLog doc/posix-headers/sys_stat.texi lib/sys_stat.in.h modules/sys_stat tests/test-sys_stat.c |
diffstat | 5 files changed, 37 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- a/doc/posix-headers/sys_stat.texi +++ b/doc/posix-headers/sys_stat.texi @@ -20,6 +20,10 @@ @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:
--- a/lib/sys_stat.in.h +++ b/lib/sys_stat.in.h @@ -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@
--- a/modules/sys_stat +++ b/modules/sys_stat @@ -9,6 +9,7 @@ Depends-on: include_next link-warning +time configure.ac: gl_HEADER_SYS_STAT_H
--- a/tests/test-sys_stat.c +++ b/tests/test-sys_stat.c @@ -253,6 +253,23 @@ 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 @@ /* Check the existence of some types. */ nlink_t t1; +struct timespec t2; + int main () {