public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Cc: "Daniel Krügler" <daniel.kruegler@gmail.com>,
	"Rainer Orth" <ro@CeBiTec.Uni-Bielefeld.DE>,
	"Luke Allardyce" <lukeallardyce@gmail.com>
Subject: Re: [patch] Implement ISO/IEC TS 18822 C++ File system TS
Date: Sat, 02 May 2015 09:52:00 -0000	[thread overview]
Message-ID: <20150502095155.GS3618@redhat.com> (raw)
In-Reply-To: <20150501194853.GK3618@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 327 bytes --]

Another portability fix, to avoid using &stat::st_atime because
st_atime might be a macro, and &stat::st_atim.tv_sec is not valid.

Also POSIX doesn't actually require any particular structure for
timespec, so set the fields explicitly instead of using braces.

Tested powerpc64le-linux and powerpc-aix7, committed to trunk.



[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1694 bytes --]

commit 2a89701d33798b1b5425e56e3050024327879b5f
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri May 1 23:46:21 2015 +0100

    	* src/filesystem/ops.cc (last_write_time) [_GLIBCXX_USE_UTIMENSAT]:
    	Set timespec members explicitly instead of with a braced-init-list.
    	[_GLIBCXX_HAVE_UTIME_H]: Use lambda to handle st_atime being a macro.

diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc
index c7e3960..aa1ab04 100644
--- a/libstdc++-v3/src/filesystem/ops.cc
+++ b/libstdc++-v3/src/filesystem/ops.cc
@@ -871,20 +871,22 @@ fs::last_write_time(const path& p __attribute__((__unused__)),
 {
   auto d = new_time.time_since_epoch();
   auto s = chrono::duration_cast<chrono::seconds>(d);
+#if _GLIBCXX_USE_UTIMENSAT
   auto ns = chrono::duration_cast<chrono::nanoseconds>(d - s);
-#ifdef _GLIBCXX_USE_UTIMENSAT
-  struct ::timespec ts[2] = {
-    { 0, UTIME_OMIT },
-    { static_cast<std::time_t>(s.count()), static_cast<long>(ns.count()) }
-  };
-  if (utimensat(AT_FDCWD, p.c_str(), ts, 0))
+  struct ::timespec ts[2];
+  ts[0].tv_sec = 0;
+  ts[0].tv_nsec = UTIME_OMIT;
+  ts[1].tv_sec = static_cast<std::time_t>(s.count());
+  ts[1].tv_nsec = static_cast<long>(ns.count());
+  if (::utimensat(AT_FDCWD, p.c_str(), ts, 0))
     ec.assign(errno, std::generic_category());
   else
     ec.clear();
 #elif _GLIBCXX_HAVE_UTIME_H
   ::utimbuf times;
   times.modtime = s.count();
-  times.actime = do_stat(p, ec, std::mem_fn(&stat::st_atime), times.modtime);
+  times.actime = do_stat(p, ec, [](const auto& st) { return st.st_atime; },
+			 times.modtime);
   if (::utime(p.c_str(), &times))
     ec.assign(errno, std::generic_category());
   else

  reply	other threads:[~2015-05-02  9:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-30 17:42 Jonathan Wakely
2015-04-30 19:33 ` Jonathan Wakely
     [not found]   ` <CAFW6PZB9WvskzrKCsNKK4s-5oXWjcwkuZGMrWbrfgJ7fpJiCXQ@mail.gmail.com>
     [not found]     ` <20150501105351.GY3618@redhat.com>
2015-05-01 19:49       ` Jonathan Wakely
2015-05-02  9:52         ` Jonathan Wakely [this message]
2015-05-08 11:43         ` Rainer Orth
2015-05-13 10:56           ` Jonathan Wakely
2015-05-01 12:45 ` Rainer Orth
2015-05-01 15:11   ` Jonathan Wakely
2015-05-01 15:14     ` Rainer Orth
2015-05-01 17:03 ` Daniel Krügler
2015-05-01 17:55   ` Jonathan Wakely
2015-05-01 18:22   ` Jonathan Wakely
2015-05-01 19:28     ` Daniel Krügler
2015-05-01 19:38       ` Jonathan Wakely
2015-05-01 20:05         ` Jonathan Wakely

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=20150502095155.GS3618@redhat.com \
    --to=jwakely@redhat.com \
    --cc=daniel.kruegler@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    --cc=lukeallardyce@gmail.com \
    --cc=ro@CeBiTec.Uni-Bielefeld.DE \
    /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).