mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-12-27 12:24:17 +01:00
common: Enable warnings as errors
Cleans up common so that we can enable warnings as errors.
This commit is contained in:
parent
14a97d082e
commit
4a4b685a04
14
externals/microprofile/microprofile.h
vendored
14
externals/microprofile/microprofile.h
vendored
@ -902,8 +902,10 @@ inline uint16_t MicroProfileGetGroupIndex(MicroProfileToken t)
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable: 4244)
|
#pragma warning(disable: 4244)
|
||||||
|
#endif
|
||||||
int64_t MicroProfileTicksPerSecondCpu()
|
int64_t MicroProfileTicksPerSecondCpu()
|
||||||
{
|
{
|
||||||
static int64_t nTicksPerSecond = 0;
|
static int64_t nTicksPerSecond = 0;
|
||||||
@ -946,7 +948,7 @@ typedef HANDLE MicroProfileThread;
|
|||||||
DWORD _stdcall ThreadTrampoline(void* pFunc)
|
DWORD _stdcall ThreadTrampoline(void* pFunc)
|
||||||
{
|
{
|
||||||
MicroProfileThreadFunc F = (MicroProfileThreadFunc)pFunc;
|
MicroProfileThreadFunc F = (MicroProfileThreadFunc)pFunc;
|
||||||
return (uint32_t)F(0);
|
return (DWORD)F(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MicroProfileThreadStart(MicroProfileThread* pThread, MicroProfileThreadFunc Func)
|
inline void MicroProfileThreadStart(MicroProfileThread* pThread, MicroProfileThreadFunc Func)
|
||||||
@ -1742,10 +1744,10 @@ void MicroProfileFlip()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(uint32_t i = 0; i < MICROPROFILE_MAX_GROUPS; ++i)
|
for(uint32_t j = 0; j < MICROPROFILE_MAX_GROUPS; ++j)
|
||||||
{
|
{
|
||||||
pLog->nGroupTicks[i] += nGroupTicks[i];
|
pLog->nGroupTicks[j] += nGroupTicks[j];
|
||||||
pFrameGroup[i] += nGroupTicks[i];
|
pFrameGroup[j] += nGroupTicks[j];
|
||||||
}
|
}
|
||||||
pLog->nStackPos = nStackPos;
|
pLog->nStackPos = nStackPos;
|
||||||
}
|
}
|
||||||
@ -3328,7 +3330,7 @@ bool MicroProfileIsLocalThread(uint32_t nThreadId)
|
|||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
|
||||||
bool MicroProfileIsLocalThread(uint32_t nThreadId){return false;}
|
bool MicroProfileIsLocalThread([[maybe_unused]] uint32_t nThreadId) { return false; }
|
||||||
void MicroProfileStopContextSwitchTrace(){}
|
void MicroProfileStopContextSwitchTrace(){}
|
||||||
void MicroProfileStartContextSwitchTrace(){}
|
void MicroProfileStartContextSwitchTrace(){}
|
||||||
|
|
||||||
@ -3576,7 +3578,7 @@ int MicroProfileGetGpuTickReference(int64_t* pOutCpu, int64_t* pOutGpu)
|
|||||||
|
|
||||||
#undef S
|
#undef S
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -190,6 +190,22 @@ if(ARCHITECTURE_x86_64)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (MSVC)
|
||||||
|
target_compile_definitions(common PRIVATE
|
||||||
|
# The standard library doesn't provide any replacement for codecvt yet
|
||||||
|
# so we can disable this deprecation warning for the time being.
|
||||||
|
_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
|
||||||
|
)
|
||||||
|
target_compile_options(common PRIVATE
|
||||||
|
/W4
|
||||||
|
/WX
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
target_compile_options(common PRIVATE
|
||||||
|
-Werror
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
create_target_directory_groups(common)
|
create_target_directory_groups(common)
|
||||||
find_package(Boost 1.71 COMPONENTS context headers REQUIRED)
|
find_package(Boost 1.71 COMPONENTS context headers REQUIRED)
|
||||||
|
|
||||||
|
@ -79,9 +79,9 @@ void Fiber::Exit() {
|
|||||||
released = true;
|
released = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fiber::SetRewindPoint(std::function<void(void*)>&& rewind_func, void* start_parameter) {
|
void Fiber::SetRewindPoint(std::function<void(void*)>&& rewind_func, void* rewind_param) {
|
||||||
rewind_point = std::move(rewind_func);
|
rewind_point = std::move(rewind_func);
|
||||||
rewind_parameter = start_parameter;
|
rewind_parameter = rewind_param;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fiber::Rewind() {
|
void Fiber::Rewind() {
|
||||||
@ -161,9 +161,9 @@ Fiber::Fiber(std::function<void(void*)>&& entry_point_func, void* start_paramete
|
|||||||
boost::context::detail::make_fcontext(stack_base, impl->stack.size(), FiberStartFunc);
|
boost::context::detail::make_fcontext(stack_base, impl->stack.size(), FiberStartFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fiber::SetRewindPoint(std::function<void(void*)>&& rewind_func, void* start_parameter) {
|
void Fiber::SetRewindPoint(std::function<void(void*)>&& rewind_func, void* rewind_param) {
|
||||||
rewind_point = std::move(rewind_func);
|
rewind_point = std::move(rewind_func);
|
||||||
rewind_parameter = start_parameter;
|
rewind_parameter = rewind_param;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fiber::Fiber() : impl{std::make_unique<FiberImpl>()} {}
|
Fiber::Fiber() : impl{std::make_unique<FiberImpl>()} {}
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
static void YieldTo(std::shared_ptr<Fiber> from, std::shared_ptr<Fiber> to);
|
static void YieldTo(std::shared_ptr<Fiber> from, std::shared_ptr<Fiber> to);
|
||||||
[[nodiscard]] static std::shared_ptr<Fiber> ThreadToFiber();
|
[[nodiscard]] static std::shared_ptr<Fiber> ThreadToFiber();
|
||||||
|
|
||||||
void SetRewindPoint(std::function<void(void*)>&& rewind_func, void* start_parameter);
|
void SetRewindPoint(std::function<void(void*)>&& rewind_func, void* rewind_param);
|
||||||
|
|
||||||
void Rewind();
|
void Rewind();
|
||||||
|
|
||||||
|
@ -472,13 +472,14 @@ u64 ScanDirectoryTree(const std::string& directory, FSTEntry& parent_entry,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DeleteDirRecursively(const std::string& directory, unsigned int recursion) {
|
bool DeleteDirRecursively(const std::string& directory, unsigned int recursion) {
|
||||||
const auto callback = [recursion](u64* num_entries_out, const std::string& directory,
|
const auto callback = [recursion](u64*, const std::string& directory,
|
||||||
const std::string& virtual_name) -> bool {
|
const std::string& virtual_name) {
|
||||||
std::string new_path = directory + DIR_SEP_CHR + virtual_name;
|
const std::string new_path = directory + DIR_SEP_CHR + virtual_name;
|
||||||
|
|
||||||
if (IsDirectory(new_path)) {
|
if (IsDirectory(new_path)) {
|
||||||
if (recursion == 0)
|
if (recursion == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return DeleteDirRecursively(new_path, recursion - 1);
|
return DeleteDirRecursively(new_path, recursion - 1);
|
||||||
}
|
}
|
||||||
return Delete(new_path);
|
return Delete(new_path);
|
||||||
@ -492,7 +493,8 @@ bool DeleteDirRecursively(const std::string& directory, unsigned int recursion)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyDir(const std::string& source_path, const std::string& dest_path) {
|
void CopyDir([[maybe_unused]] const std::string& source_path,
|
||||||
|
[[maybe_unused]] const std::string& dest_path) {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (source_path == dest_path) {
|
if (source_path == dest_path) {
|
||||||
return;
|
return;
|
||||||
@ -553,7 +555,7 @@ std::optional<std::string> GetCurrentDir() {
|
|||||||
std::string strDir = dir;
|
std::string strDir = dir;
|
||||||
#endif
|
#endif
|
||||||
free(dir);
|
free(dir);
|
||||||
return std::move(strDir);
|
return strDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetCurrentDir(const std::string& directory) {
|
bool SetCurrentDir(const std::string& directory) {
|
||||||
@ -772,21 +774,23 @@ std::size_t ReadFileToString(bool text_file, const std::string& filename, std::s
|
|||||||
|
|
||||||
void SplitFilename83(const std::string& filename, std::array<char, 9>& short_name,
|
void SplitFilename83(const std::string& filename, std::array<char, 9>& short_name,
|
||||||
std::array<char, 4>& extension) {
|
std::array<char, 4>& extension) {
|
||||||
const std::string forbidden_characters = ".\"/\\[]:;=, ";
|
static constexpr std::string_view forbidden_characters = ".\"/\\[]:;=, ";
|
||||||
|
|
||||||
// On a FAT32 partition, 8.3 names are stored as a 11 bytes array, filled with spaces.
|
// On a FAT32 partition, 8.3 names are stored as a 11 bytes array, filled with spaces.
|
||||||
short_name = {{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '\0'}};
|
short_name = {{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '\0'}};
|
||||||
extension = {{' ', ' ', ' ', '\0'}};
|
extension = {{' ', ' ', ' ', '\0'}};
|
||||||
|
|
||||||
std::string::size_type point = filename.rfind('.');
|
auto point = filename.rfind('.');
|
||||||
if (point == filename.size() - 1)
|
if (point == filename.size() - 1) {
|
||||||
point = filename.rfind('.', point);
|
point = filename.rfind('.', point);
|
||||||
|
}
|
||||||
|
|
||||||
// Get short name.
|
// Get short name.
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (char letter : filename.substr(0, point)) {
|
for (char letter : filename.substr(0, point)) {
|
||||||
if (forbidden_characters.find(letter, 0) != std::string::npos)
|
if (forbidden_characters.find(letter, 0) != std::string::npos) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (j == 8) {
|
if (j == 8) {
|
||||||
// TODO(Link Mauve): also do that for filenames containing a space.
|
// TODO(Link Mauve): also do that for filenames containing a space.
|
||||||
// TODO(Link Mauve): handle multiple files having the same short name.
|
// TODO(Link Mauve): handle multiple files having the same short name.
|
||||||
@ -794,14 +798,15 @@ void SplitFilename83(const std::string& filename, std::array<char, 9>& short_nam
|
|||||||
short_name[7] = '1';
|
short_name[7] = '1';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
short_name[j++] = toupper(letter);
|
short_name[j++] = static_cast<char>(std::toupper(letter));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get extension.
|
// Get extension.
|
||||||
if (point != std::string::npos) {
|
if (point != std::string::npos) {
|
||||||
j = 0;
|
j = 0;
|
||||||
for (char letter : filename.substr(point + 1, 3))
|
for (char letter : filename.substr(point + 1, 3)) {
|
||||||
extension[j++] = toupper(letter);
|
extension[j++] = static_cast<char>(std::toupper(letter));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,6 @@ const char* GetLogClassName(Class log_class) {
|
|||||||
case Class::Count:
|
case Class::Count:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
UNREACHABLE();
|
|
||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +292,6 @@ const char* GetLevelName(Level log_level) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#undef LVL
|
#undef LVL
|
||||||
UNREACHABLE();
|
|
||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "common/common_paths.h"
|
#include "common/common_paths.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
@ -21,14 +22,14 @@ namespace Common {
|
|||||||
/// Make a string lowercase
|
/// Make a string lowercase
|
||||||
std::string ToLower(std::string str) {
|
std::string ToLower(std::string str) {
|
||||||
std::transform(str.begin(), str.end(), str.begin(),
|
std::transform(str.begin(), str.end(), str.begin(),
|
||||||
[](unsigned char c) { return std::tolower(c); });
|
[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Make a string uppercase
|
/// Make a string uppercase
|
||||||
std::string ToUpper(std::string str) {
|
std::string ToUpper(std::string str) {
|
||||||
std::transform(str.begin(), str.end(), str.begin(),
|
std::transform(str.begin(), str.end(), str.begin(),
|
||||||
[](unsigned char c) { return std::toupper(c); });
|
[](unsigned char c) { return static_cast<char>(std::toupper(c)); });
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,20 +142,18 @@ std::string Timer::GetTimeFormatted() {
|
|||||||
// ----------------
|
// ----------------
|
||||||
double Timer::GetDoubleTime() {
|
double Timer::GetDoubleTime() {
|
||||||
// Get continuous timestamp
|
// Get continuous timestamp
|
||||||
u64 TmpSeconds = static_cast<u64>(Common::Timer::GetTimeSinceJan1970().count());
|
auto tmp_seconds = static_cast<u64>(GetTimeSinceJan1970().count());
|
||||||
double ms = static_cast<u64>(GetTimeMs().count()) % 1000;
|
const auto ms = static_cast<double>(static_cast<u64>(GetTimeMs().count()) % 1000);
|
||||||
|
|
||||||
// Remove a few years. We only really want enough seconds to make
|
// Remove a few years. We only really want enough seconds to make
|
||||||
// sure that we are detecting actual actions, perhaps 60 seconds is
|
// sure that we are detecting actual actions, perhaps 60 seconds is
|
||||||
// enough really, but I leave a year of seconds anyway, in case the
|
// enough really, but I leave a year of seconds anyway, in case the
|
||||||
// user's clock is incorrect or something like that.
|
// user's clock is incorrect or something like that.
|
||||||
TmpSeconds = TmpSeconds - (38 * 365 * 24 * 60 * 60);
|
tmp_seconds = tmp_seconds - (38 * 365 * 24 * 60 * 60);
|
||||||
|
|
||||||
// Make a smaller integer that fits in the double
|
// Make a smaller integer that fits in the double
|
||||||
u32 Seconds = static_cast<u32>(TmpSeconds);
|
const auto seconds = static_cast<u32>(tmp_seconds);
|
||||||
double TmpTime = Seconds + ms;
|
return seconds + ms;
|
||||||
|
|
||||||
return TmpTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Namespace Common
|
} // Namespace Common
|
||||||
|
@ -53,7 +53,7 @@ public:
|
|||||||
return Common::Divide128On32(temporary, 1000000000).first;
|
return Common::Divide128On32(temporary, 1000000000).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pause(bool is_paused) override {
|
void Pause([[maybe_unused]] bool is_paused) override {
|
||||||
// Do nothing in this clock type.
|
// Do nothing in this clock type.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ private:
|
|||||||
/// value used to reduce the native clocks accuracy as some apss rely on
|
/// value used to reduce the native clocks accuracy as some apss rely on
|
||||||
/// undefined behavior where the level of accuracy in the clock shouldn't
|
/// undefined behavior where the level of accuracy in the clock shouldn't
|
||||||
/// be higher.
|
/// be higher.
|
||||||
static constexpr u64 inaccuracy_mask = ~(0x400 - 1);
|
static constexpr u64 inaccuracy_mask = ~(UINT64_C(0x400) - 1);
|
||||||
|
|
||||||
SpinLock rtsc_serialize{};
|
SpinLock rtsc_serialize{};
|
||||||
u64 last_measure{};
|
u64 last_measure{};
|
||||||
|
Loading…
Reference in New Issue
Block a user