summaryrefslogtreecommitdiffstats
path: root/libcxx/src/experimental/filesystem/operations.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-09-29 01:01:26 +0000
committerEric Fiselier <eric@efcs.ca>2016-09-29 01:01:26 +0000
commit790ad869ac05d6d94dc7889f3e65e8bc7320366b (patch)
tree34966fc85cd3defc93541cc3fefe0284b2d9bc31 /libcxx/src/experimental/filesystem/operations.cpp
parent74b8fbcba75e23a62975536af7d8177e8309d7cf (diff)
downloadbcm5719-llvm-790ad869ac05d6d94dc7889f3e65e8bc7320366b.tar.gz
bcm5719-llvm-790ad869ac05d6d94dc7889f3e65e8bc7320366b.zip
Partially revert overflow checking in last_write_time
llvm-svn: 282660
Diffstat (limited to 'libcxx/src/experimental/filesystem/operations.cpp')
-rw-r--r--libcxx/src/experimental/filesystem/operations.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/libcxx/src/experimental/filesystem/operations.cpp b/libcxx/src/experimental/filesystem/operations.cpp
index 2eb05076bad..6073d3a1b46 100644
--- a/libcxx/src/experimental/filesystem/operations.cpp
+++ b/libcxx/src/experimental/filesystem/operations.cpp
@@ -544,16 +544,14 @@ file_time_type __last_write_time(const path& p, std::error_code *ec)
set_or_throw(m_ec, ec, "last_write_time", p);
return file_time_type::min();
}
+ if (ec) ec->clear();
+ auto ts = detail::extract_mtime(st);
#ifndef _LIBCPP_HAS_NO_INT128
using IntMax = __int128_t;
-#else
- using IntMax = intmax_t;
-#endif
// FIXME: The value may not be representable as file_time_type. Fix
// file_time_type so it can represent all possible values returned by the
// filesystem. For now we do the calculation with the largest possible types
// and then truncate, this prevents signed integer overflow bugs.
- auto ts = detail::extract_mtime(st);
const auto NsDur = duration<IntMax, nano>(ts.tv_nsec) + seconds(ts.tv_sec);
if (NsDur > file_time_type::max().time_since_epoch() ||
NsDur < file_time_type::min().time_since_epoch()) {
@@ -561,8 +559,12 @@ file_time_type __last_write_time(const path& p, std::error_code *ec)
"last_write_time", p);
return file_time_type::min();
}
- if (ec) ec->clear();
return file_time_type(duration_cast<file_time_type::duration>(NsDur));
+#else
+ // FIXME the under/overflow check done above overflows if we don't have
+ // a 128 bit integer type.
+ return file_time_type::clock::from_time_t(ts.tv_sec);
+#endif
}
void __last_write_time(const path& p, file_time_type new_time,
OpenPOWER on IntegriCloud