[PATCH] Make st_*tim visible in stat for POSIX.1-2008

Yaakov Selkowitz yselkowi@redhat.com
Wed Aug 14 18:52:00 GMT 2019


On Tue, 2019-08-13 at 11:29 -0700, Dionna Amalie Glaze via newlib
wrote:
> The st_{a,c,m}tim fields are needed for POSIX.1-2008, not just RTEMS.
> 
> Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
> ---
>  newlib/libc/include/sys/stat.h | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/newlib/libc/include/sys/stat.h b/newlib/libc/include/sys/stat.h
> index eee98db64..052ef5a66 100644
> --- a/newlib/libc/include/sys/stat.h
> +++ b/newlib/libc/include/sys/stat.h
> @@ -34,10 +34,12 @@ struct      stat
>    gid_t                st_gid;
>    dev_t                st_rdev;
>    off_t                st_size;
> -#if defined(__rtems__)
> +#if defined(__USE_MISC) || __POSIX_VISIBLE >= 200809

Nak.

1) __USE_MISC is a glibc internal and has no meaning within Newlib. 
The proper guards must be used.

2) This would cause the struct size to vary based on FTMs.  This is a
big no-no.  There needs to be size equivalent no-ops in an #else chunk
to match this.

>    struct timespec st_atim;
>    struct timespec st_mtim;
>    struct timespec st_ctim;
> +#endif
> +#if defined(__rtems__)
>    blksize_t     st_blksize;
>    blkcnt_t     st_blocks;
>  #else
> @@ -60,7 +62,7 @@ struct        stat
>  #endif
>  };
> 
> -#if defined(__rtems__)
> +#if __POSIX_VISIBLE >= 200809
>  #define st_atime st_atim.tv_sec
>  #define st_ctime st_ctim.tv_sec
>  #define st_mtime st_mtim.tv_sec
> 

-- 
Yaakov Selkowitz
Senior Software Engineer - Platform Enablement
Red Hat, Inc.




More information about the Newlib mailing list