From 58f270df2501206548bc691b93d18b3844aef550 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Sat, 2 May 2015 10:51:49 +0100 Subject: [PATCH] ops.cc (last_write_time): Set timespec members explicitly instead of with a braced-init-list. * 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. From-SVN: r222718 --- libstdc++-v3/ChangeLog | 6 ++++++ libstdc++-v3/src/filesystem/ops.cc | 16 +++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index efea855af30..521ca9cb9df 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2015-05-02 Jonathan Wakely + + * 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. + 2015-05-02 Edward Smith-Rowland <3dw4rd@verizon.net> * include/experimental/deque: Add feature-test macro. diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc index c7e3960be86..aa1ab048c70 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(d); +#if _GLIBCXX_USE_UTIMENSAT auto ns = chrono::duration_cast(d - s); -#ifdef _GLIBCXX_USE_UTIMENSAT - struct ::timespec ts[2] = { - { 0, UTIME_OMIT }, - { static_cast(s.count()), static_cast(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(s.count()); + ts[1].tv_nsec = static_cast(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(), ×)) ec.assign(errno, std::generic_category()); else -- 2.30.2