#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Object/Binary.h"
+#include "llvm/Support/Chrono.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/TimeValue.h"
namespace llvm {
namespace object {
Expected<uint32_t> getSize() const;
Expected<sys::fs::perms> getAccessMode() const;
- Expected<sys::TimeValue> getLastModified() const;
+ Expected<sys::TimePoint<std::chrono::seconds>> getLastModified() const;
llvm::StringRef getRawLastModified() const {
return StringRef(ArMemHdr->LastModified,
sizeof(ArMemHdr->LastModified)).rtrim(' ');
Expected<StringRef> getName() const;
Expected<std::string> getFullName() const;
Expected<StringRef> getRawName() const { return Header.getRawName(); }
- Expected<sys::TimeValue> getLastModified() const {
+ Expected<sys::TimePoint<std::chrono::seconds>> getLastModified() const {
return Header.getLastModified();
}
StringRef getRawLastModified() const {
NewArchiveMember M;
M.Buf = MemoryBuffer::getMemBuffer(*BufOrErr, false);
if (!Deterministic) {
- Expected<sys::TimeValue> ModTimeOrErr = OldMember.getLastModified();
+ auto ModTimeOrErr = OldMember.getLastModified();
if (!ModTimeOrErr)
return ModTimeOrErr.takeError();
M.ModTime = ModTimeOrErr.get();
NewArchiveMember M;
M.Buf = std::move(*MemberBufferOrErr);
if (!Deterministic) {
- M.ModTime = Status.getLastModificationTime();
+ M.ModTime = std::chrono::time_point_cast<std::chrono::seconds>(
+ Status.getLastModificationTime());
M.UID = Status.getUser();
M.GID = Status.getGroup();
M.Perms = Status.permissions();
support::endian::Writer<support::little>(Out).write(Val);
}
-static void printRestOfMemberHeader(raw_fd_ostream &Out,
- const sys::TimeValue &ModTime, unsigned UID,
- unsigned GID, unsigned Perms,
- unsigned Size) {
- printWithSpacePadding(Out, ModTime.toEpochTime(), 12);
+static void printRestOfMemberHeader(
+ raw_fd_ostream &Out, const sys::TimePoint<std::chrono::seconds> &ModTime,
+ unsigned UID, unsigned GID, unsigned Perms, unsigned Size) {
+ printWithSpacePadding(Out, sys::toTimeT(ModTime), 12);
printWithSpacePadding(Out, UID, 6, true);
printWithSpacePadding(Out, GID, 6, true);
printWithSpacePadding(Out, format("%o", Perms), 8);
Out << "`\n";
}
-static void printGNUSmallMemberHeader(raw_fd_ostream &Out, StringRef Name,
- const sys::TimeValue &ModTime,
- unsigned UID, unsigned GID,
- unsigned Perms, unsigned Size) {
+static void
+printGNUSmallMemberHeader(raw_fd_ostream &Out, StringRef Name,
+ const sys::TimePoint<std::chrono::seconds> &ModTime,
+ unsigned UID, unsigned GID, unsigned Perms,
+ unsigned Size) {
printWithSpacePadding(Out, Twine(Name) + "/", 16);
printRestOfMemberHeader(Out, ModTime, UID, GID, Perms, Size);
}
-static void printBSDMemberHeader(raw_fd_ostream &Out, StringRef Name,
- const sys::TimeValue &ModTime, unsigned UID,
- unsigned GID, unsigned Perms, unsigned Size) {
+static void
+printBSDMemberHeader(raw_fd_ostream &Out, StringRef Name,
+ const sys::TimePoint<std::chrono::seconds> &ModTime,
+ unsigned UID, unsigned GID, unsigned Perms,
+ unsigned Size) {
uint64_t PosAfterHeader = Out.tell() + 60 + Name.size();
// Pad so that even 64 bit object files are aligned.
unsigned Pad = OffsetToAlignment(PosAfterHeader, 8);
printMemberHeader(raw_fd_ostream &Out, object::Archive::Kind Kind, bool Thin,
StringRef Name,
std::vector<unsigned>::iterator &StringMapIndexIter,
- const sys::TimeValue &ModTime, unsigned UID, unsigned GID,
- unsigned Perms, unsigned Size) {
+ const sys::TimePoint<std::chrono::seconds> &ModTime,
+ unsigned UID, unsigned GID, unsigned Perms, unsigned Size) {
if (Kind == object::Archive::K_BSD)
return printBSDMemberHeader(Out, Name, ModTime, UID, GID, Perms, Size);
if (!useStringTable(Thin, Name))
Out.seek(Pos);
}
-static sys::TimeValue now(bool Deterministic) {
+static sys::TimePoint<std::chrono::seconds> now(bool Deterministic) {
+ using namespace std::chrono;
+
if (!Deterministic)
- return sys::TimeValue::now();
- sys::TimeValue TV;
- TV.fromEpochTime(0);
- return TV;
+ return time_point_cast<seconds>(system_clock::now());
+ return sys::TimePoint<seconds>();
}
// Returns the offset of the first reference to a member offset.