From: Yaakov Selkowitz <yselkowi@redhat.com>
To: newlib@sourceware.org
Subject: Re: [PATCH] Make st_*tim visible in stat for POSIX.1-2008
Date: Wed, 14 Aug 2019 19:25:00 -0000 [thread overview]
Message-ID: <b07435a703609c3997cb2c63b8cebb0e2f3d38a9.camel@redhat.com> (raw)
In-Reply-To: <CAAH4kHZa3+Wgkg3DWzGu=26rryzjPSwu0UjVXk8i4b1NDLeG=Q@mail.gmail.com>
On Wed, 2019-08-14 at 12:06 -0700, Dionna Amalie Glaze wrote:
> Ah you're right, I didn't properly handle the block size definitions.
> Here's another go at it that splits the timestamp declarations from the
> blocksize declarations.
>
> ---
> newlib/libc/include/sys/stat.h | 64 ++++++++++++++++++----------------
> 1 file changed, 34 insertions(+), 30 deletions(-)
>
> diff --git a/newlib/libc/include/sys/stat.h b/newlib/libc/include/sys/stat.h
> index eee98db64..4a05081e4 100644
> --- a/newlib/libc/include/sys/stat.h
> +++ b/newlib/libc/include/sys/stat.h
> @@ -24,7 +24,7 @@ extern "C" {
> #define stat64 stat
> #endif
> #else
> -struct stat
> +struct stat
> {
> dev_t st_dev;
> ino_t st_ino;
> @@ -34,15 +34,11 @@ struct stat
> gid_t st_gid;
> dev_t st_rdev;
> off_t st_size;
> -#if defined(__rtems__)
> +#if defined(__MISC_VISIBLE) || __POSIX_VISIBLE >= 200809 || defined(__rtems__)
The __*_VISIBLE macros are *always* defined, question is to what.
These must therefore be used as #if __MISC_VISIBLE etc.
> struct timespec st_atim;
> struct timespec st_mtim;
> struct timespec st_ctim;
> - blksize_t st_blksize;
> - blkcnt_t st_blocks;
> -#else
> - /* SysV/sco doesn't have the rest... But Solaris, eabi does. */
> -#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__)
> +#elif defined(__svr4__) && !defined(__PPC__) && !defined(__sun__)
What defined __srv4__ that should trigger this section? It probably
needs to be moved before the #if __MISC_VISIBLE etc. hunk.
> time_t st_atime;
> time_t st_mtime;
> time_t st_ctime;
> @@ -53,14 +49,19 @@ struct stat
> long st_spare2;
> time_t st_ctime;
> long st_spare3;
> +#endif
> +#if defined(__rtems__)
> + blksize_t st_blksize;
> + blkcnt_t st_blocks;
> +/* SysV/sco doesn't have the rest... But Solaris, eabi does. */
> +#elif !defined(__svr4__) || defined(__PPC__) || defined(__sun__)
> blksize_t st_blksize;
> blkcnt_t st_blocks;
> long st_spare4[2];
> #endif
> -#endif
> };
>
> -#if defined(__rtems__)
> +#if __POSIX_VISIBLE >= 200809 || defined(__rtems__)
>
> On Wed, Aug 14, 2019 at 11:53 AM Yaakov Selkowitz wrote:
> > 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.
next prev parent reply other threads:[~2019-08-14 19:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-13 18:30 Dionna Amalie Glaze via newlib
2019-08-13 18:46 ` Joel Sherrill
2019-08-14 8:41 ` Corinna Vinschen
2019-08-14 18:45 ` Dionna Amalie Glaze via newlib
2019-08-14 18:52 ` Yaakov Selkowitz
2019-08-14 19:06 ` Dionna Amalie Glaze via newlib
2019-08-14 19:25 ` Yaakov Selkowitz [this message]
2019-08-14 19:50 ` Dionna Amalie Glaze via newlib
2019-08-15 10:03 ` Corinna Vinschen
2019-08-15 15:59 ` Dionna Amalie Glaze via newlib
2019-08-15 18:29 ` Joel Sherrill
2019-08-16 8:59 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b07435a703609c3997cb2c63b8cebb0e2f3d38a9.camel@redhat.com \
--to=yselkowi@redhat.com \
--cc=newlib@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).