summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/common_funcs.h4
-rw-r--r--src/common/logging/backend.cpp4
-rw-r--r--src/common/logging/log.h4
-rw-r--r--src/common/logging/text_formatter.h1
-rw-r--r--src/common/string_util.cpp8
-rw-r--r--src/common/swap.h2
-rw-r--r--src/common/timer.cpp95
-rw-r--r--src/common/timer.h17
8 files changed, 47 insertions, 88 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index 93f1c0044..8b0d34da6 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -6,7 +6,7 @@
#include <string>
-#if !defined(ARCHITECTURE_x86_64) && !defined(ARCHITECTURE_ARM)
+#if !defined(ARCHITECTURE_x86_64)
#include <cstdlib> // for exit
#endif
#include "common/common_types.h"
@@ -32,8 +32,6 @@
#ifdef ARCHITECTURE_x86_64
#define Crash() __asm__ __volatile__("int $3")
-#elif defined(ARCHITECTURE_ARM)
-#define Crash() __asm__ __volatile__("trap")
#else
#define Crash() exit(1)
#endif
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 38cc85e23..d86c40d26 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -169,7 +169,9 @@ void FileBackend::Write(const Entry& entry) {
SUB(Service, AOC) \
SUB(Service, APM) \
SUB(Service, BCAT) \
+ SUB(Service, BTM) \
SUB(Service, Fatal) \
+ SUB(Service, FGM) \
SUB(Service, Friend) \
SUB(Service, FS) \
SUB(Service, HID) \
@@ -184,6 +186,7 @@ void FileBackend::Write(const Entry& entry) {
SUB(Service, NIFM) \
SUB(Service, NS) \
SUB(Service, NVDRV) \
+ SUB(Service, PCIE) \
SUB(Service, PCTL) \
SUB(Service, PREPO) \
SUB(Service, SET) \
@@ -192,6 +195,7 @@ void FileBackend::Write(const Entry& entry) {
SUB(Service, SSL) \
SUB(Service, Time) \
SUB(Service, VI) \
+ SUB(Service, WLAN) \
CLS(HW) \
SUB(HW, Memory) \
SUB(HW, LCD) \
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index db4a80d0a..140cd8e47 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -56,7 +56,9 @@ enum class Class : ClassType {
Service_APM, ///< The APM (Performance) service
Service_Audio, ///< The Audio (Audio control) service
Service_BCAT, ///< The BCAT service
+ Service_BTM, ///< The BTM service
Service_Fatal, ///< The Fatal service
+ Service_FGM, ///< The FGM service
Service_Friend, ///< The friend service
Service_FS, ///< The FS (Filesystem) service
Service_HID, ///< The HID (Human interface device) service
@@ -71,6 +73,7 @@ enum class Class : ClassType {
Service_NIFM, ///< The NIFM (Network interface) service
Service_NS, ///< The NS services
Service_NVDRV, ///< The NVDRV (Nvidia driver) service
+ Service_PCIE, ///< The PCIe service
Service_PCTL, ///< The PCTL (Parental control) service
Service_PREPO, ///< The PREPO (Play report) service
Service_SET, ///< The SET (Settings) service
@@ -79,6 +82,7 @@ enum class Class : ClassType {
Service_SSL, ///< The SSL service
Service_Time, ///< The time service
Service_VI, ///< The VI (Video interface) service
+ Service_WLAN, ///< The WLAN (Wireless local area network) service
HW, ///< Low-level hardware emulation
HW_Memory, ///< Memory-map and address translation
HW_LCD, ///< LCD register emulation
diff --git a/src/common/logging/text_formatter.h b/src/common/logging/text_formatter.h
index c587faefb..9609cec7c 100644
--- a/src/common/logging/text_formatter.h
+++ b/src/common/logging/text_formatter.h
@@ -5,6 +5,7 @@
#pragma once
#include <cstddef>
+#include <string>
namespace Log {
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index 1f0456aee..0ca663032 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -2,12 +2,12 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <algorithm>
#include <cctype>
#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <cstring>
-#include <boost/range/algorithm/transform.hpp>
#include "common/common_paths.h"
#include "common/logging/log.h"
#include "common/string_util.h"
@@ -24,13 +24,15 @@ namespace Common {
/// Make a string lowercase
std::string ToLower(std::string str) {
- boost::transform(str, str.begin(), ::tolower);
+ std::transform(str.begin(), str.end(), str.begin(),
+ [](unsigned char c) { return std::tolower(c); });
return str;
}
/// Make a string uppercase
std::string ToUpper(std::string str) {
- boost::transform(str, str.begin(), ::toupper);
+ std::transform(str.begin(), str.end(), str.begin(),
+ [](unsigned char c) { return std::toupper(c); });
return str;
}
diff --git a/src/common/swap.h b/src/common/swap.h
index fc7af4280..32af0b6ac 100644
--- a/src/common/swap.h
+++ b/src/common/swap.h
@@ -69,7 +69,7 @@ inline u32 swap32(u32 _data) {
inline u64 swap64(u64 _data) {
return _byteswap_uint64(_data);
}
-#elif ARCHITECTURE_ARM
+#elif defined(ARCHITECTURE_ARM) && (__ARM_ARCH >= 6)
inline u16 swap16(u16 _data) {
u32 data = _data;
__asm__("rev16 %0, %1\n" : "=l"(data) : "l"(data));
diff --git a/src/common/timer.cpp b/src/common/timer.cpp
index f0c5b1a43..2dc15e434 100644
--- a/src/common/timer.cpp
+++ b/src/common/timer.cpp
@@ -3,31 +3,16 @@
// Refer to the license.txt file included.
#include <ctime>
-
#include <fmt/format.h>
-
-#ifdef _WIN32
-#include <windows.h>
-// windows.h needs to be included before other windows headers
-#include <mmsystem.h>
-#include <sys/timeb.h>
-#else
-#include <sys/time.h>
-#endif
#include "common/common_types.h"
#include "common/string_util.h"
#include "common/timer.h"
namespace Common {
-u32 Timer::GetTimeMs() {
-#ifdef _WIN32
- return timeGetTime();
-#else
- struct timeval t;
- (void)gettimeofday(&t, nullptr);
- return ((u32)(t.tv_sec * 1000 + t.tv_usec / 1000));
-#endif
+std::chrono::milliseconds Timer::GetTimeMs() {
+ return std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::system_clock::now().time_since_epoch());
}
// --------------------------------------------
@@ -63,7 +48,7 @@ void Timer::Update() {
// -------------------------------------
// Get the number of milliseconds since the last Update()
-u64 Timer::GetTimeDifference() {
+std::chrono::milliseconds Timer::GetTimeDifference() {
return GetTimeMs() - m_LastTime;
}
@@ -74,11 +59,11 @@ void Timer::AddTimeDifference() {
}
// Get the time elapsed since the Start()
-u64 Timer::GetTimeElapsed() {
+std::chrono::milliseconds Timer::GetTimeElapsed() {
// If we have not started yet, return 1 (because then I don't
// have to change the FPS calculation in CoreRerecording.cpp .
- if (m_StartTime == 0)
- return 1;
+ if (m_StartTime.count() == 0)
+ return std::chrono::milliseconds(1);
// Return the final timer time if the timer is stopped
if (!m_Running)
@@ -90,49 +75,34 @@ u64 Timer::GetTimeElapsed() {
// Get the formatted time elapsed since the Start()
std::string Timer::GetTimeElapsedFormatted() const {
// If we have not started yet, return zero
- if (m_StartTime == 0)
+ if (m_StartTime.count() == 0)
return "00:00:00:000";
// The number of milliseconds since the start.
// Use a different value if the timer is stopped.
- u64 Milliseconds;
+ std::chrono::milliseconds Milliseconds;
if (m_Running)
Milliseconds = GetTimeMs() - m_StartTime;
else
Milliseconds = m_LastTime - m_StartTime;
// Seconds
- u32 Seconds = (u32)(Milliseconds / 1000);
+ std::chrono::seconds Seconds = std::chrono::duration_cast<std::chrono::seconds>(Milliseconds);
// Minutes
- u32 Minutes = Seconds / 60;
+ std::chrono::minutes Minutes = std::chrono::duration_cast<std::chrono::minutes>(Milliseconds);
// Hours
- u32 Hours = Minutes / 60;
+ std::chrono::hours Hours = std::chrono::duration_cast<std::chrono::hours>(Milliseconds);
- std::string TmpStr = fmt::format("{:02}:{:02}:{:02}:{:03}", Hours, Minutes % 60, Seconds % 60,
- Milliseconds % 1000);
+ std::string TmpStr = fmt::format("{:02}:{:02}:{:02}:{:03}", Hours.count(), Minutes.count() % 60,
+ Seconds.count() % 60, Milliseconds.count() % 1000);
return TmpStr;
}
-// Get current time
-void Timer::IncreaseResolution() {
-#ifdef _WIN32
- timeBeginPeriod(1);
-#endif
-}
-
-void Timer::RestoreResolution() {
-#ifdef _WIN32
- timeEndPeriod(1);
-#endif
-}
-
// Get the number of seconds since January 1 1970
-u64 Timer::GetTimeSinceJan1970() {
- time_t ltime;
- time(&ltime);
- return ((u64)ltime);
+std::chrono::seconds Timer::GetTimeSinceJan1970() {
+ return std::chrono::duration_cast<std::chrono::seconds>(GetTimeMs());
}
-u64 Timer::GetLocalTimeSinceJan1970() {
+std::chrono::seconds Timer::GetLocalTimeSinceJan1970() {
time_t sysTime, tzDiff, tzDST;
struct tm* gmTime;
@@ -149,7 +119,7 @@ u64 Timer::GetLocalTimeSinceJan1970() {
gmTime = gmtime(&sysTime);
tzDiff = sysTime - mktime(gmTime);
- return (u64)(sysTime + tzDiff + tzDST);
+ return std::chrono::seconds(sysTime + tzDiff + tzDST);
}
// Return the current time formatted as Minutes:Seconds:Milliseconds
@@ -164,30 +134,16 @@ std::string Timer::GetTimeFormatted() {
strftime(tmp, 6, "%M:%S", gmTime);
-// Now tack on the milliseconds
-#ifdef _WIN32
- struct timeb tp;
- (void)::ftime(&tp);
- return fmt::format("{}:{:03}", tmp, tp.millitm);
-#else
- struct timeval t;
- (void)gettimeofday(&t, nullptr);
- return fmt::format("{}:{:03}", tmp, static_cast<int>(t.tv_usec / 1000));
-#endif
+ u64 milliseconds = static_cast<u64>(GetTimeMs().count()) % 1000;
+ return fmt::format("{}:{:03}", tmp, milliseconds);
}
// Returns a timestamp with decimals for precise time comparisons
// ----------------
double Timer::GetDoubleTime() {
-#ifdef _WIN32
- struct timeb tp;
- (void)::ftime(&tp);
-#else
- struct timeval t;
- (void)gettimeofday(&t, nullptr);
-#endif
// Get continuous timestamp
- u64 TmpSeconds = Common::Timer::GetTimeSinceJan1970();
+ u64 TmpSeconds = static_cast<u64>(Common::Timer::GetTimeSinceJan1970().count());
+ double ms = static_cast<u64>(GetTimeMs().count()) % 1000;
// Remove a few years. We only really want enough seconds to make
// sure that we are detecting actual actions, perhaps 60 seconds is
@@ -196,12 +152,7 @@ double Timer::GetDoubleTime() {
TmpSeconds = TmpSeconds - (38 * 365 * 24 * 60 * 60);
// Make a smaller integer that fits in the double
- u32 Seconds = (u32)TmpSeconds;
-#ifdef _WIN32
- double ms = tp.millitm / 1000.0 / 1000.0;
-#else
- double ms = t.tv_usec / 1000000.0;
-#endif
+ u32 Seconds = static_cast<u32>(TmpSeconds);
double TmpTime = Seconds + ms;
return TmpTime;
diff --git a/src/common/timer.h b/src/common/timer.h
index 78d37426b..27b521baa 100644
--- a/src/common/timer.h
+++ b/src/common/timer.h
@@ -4,6 +4,7 @@
#pragma once
+#include <chrono>
#include <string>
#include "common/common_types.h"
@@ -18,24 +19,22 @@ public:
// The time difference is always returned in milliseconds, regardless of alternative internal
// representation
- u64 GetTimeDifference();
+ std::chrono::milliseconds GetTimeDifference();
void AddTimeDifference();
- static void IncreaseResolution();
- static void RestoreResolution();
- static u64 GetTimeSinceJan1970();
- static u64 GetLocalTimeSinceJan1970();
+ static std::chrono::seconds GetTimeSinceJan1970();
+ static std::chrono::seconds GetLocalTimeSinceJan1970();
static double GetDoubleTime();
static std::string GetTimeFormatted();
std::string GetTimeElapsedFormatted() const;
- u64 GetTimeElapsed();
+ std::chrono::milliseconds GetTimeElapsed();
- static u32 GetTimeMs();
+ static std::chrono::milliseconds GetTimeMs();
private:
- u64 m_LastTime;
- u64 m_StartTime;
+ std::chrono::milliseconds m_LastTime;
+ std::chrono::milliseconds m_StartTime;
bool m_Running;
};