/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include"Uptime.h"
#ifdef XP_WIN # include "mozilla/DynamicallyLinkedFunctionPtr.h" #endif// XP_WIN
// Apple things #ifdefined(__APPLE__) && defined(__MACH__) # include <time.h> # include <sys/time.h> # include <sys/types.h> # include <mach/mach_time.h>
Maybe<uint64_t> NowIncludingSuspendMs() { staticconst mozilla::StaticDynamicallyLinkedFunctionPtr<void(WINAPI*)(
PULONGLONG)>
pQueryInterruptTime(L"KernelBase.dll", "QueryInterruptTime"); if (!pQueryInterruptTime) { // On Windows, this does include the time the computer was suspended so it's // an adequate fallback.
TimeStamp processCreation = TimeStamp::ProcessCreation();
TimeStamp now = TimeStamp::Now(); if (!processCreation.IsNull() && !now.IsNull()) { return Some(uint64_t((now - processCreation).ToMilliseconds()));
} else { return Nothing();
}
}
ULONGLONG interrupt_time;
pQueryInterruptTime(&interrupt_time); return Some(interrupt_time / kHNSperMS);
}
#elifdefined(XP_UNIX) // including BSDs and Android # include <time.h>
// Number of nanoseconds in a millisecond. static constexpr uint64_t kNSperMS = 1000000;
void InitializeUptime() {
MOZ_RELEASE_ASSERT(mStartIncludingSuspendMs.isNothing() &&
mStartExcludingSuspendMs.isNothing(), "Must not be called more than once");
mStartIncludingSuspendMs = NowIncludingSuspendMs();
mStartExcludingSuspendMs = NowExcludingSuspendMs();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.