Misc: Fix build on Debian Bullseye

This commit is contained in:
Stenzek 2023-10-02 21:33:44 +10:00
parent a96111eaeb
commit 6fd7eda68f
6 changed files with 81 additions and 46 deletions

View File

@ -47,6 +47,14 @@ struct transparent_string_less
};
} // namespace detail
template<typename ValueType>
using StringMap = std::map<std::string, ValueType, detail::transparent_string_less>;
template<typename ValueType>
using StringMultiMap = std::multimap<std::string, ValueType, detail::transparent_string_less>;
using StringSet = std::set<std::string, detail::transparent_string_less>;
using StringMultiSet = std::multiset<std::string, detail::transparent_string_less>;
#if defined(__cpp_lib_generic_unordered_lookup) && __cpp_lib_generic_unordered_lookup >= 201811L
template<typename ValueType>
using UnorderedStringMap =
std::unordered_map<std::string, ValueType, detail::transparent_string_hash, detail::transparent_string_equal>;
@ -59,8 +67,21 @@ using UnorderedStringMultiSet =
std::unordered_multiset<std::string, detail::transparent_string_hash, detail::transparent_string_equal>;
template<typename ValueType>
using StringMap = std::map<std::string, ValueType, detail::transparent_string_less>;
using PreferUnorderedStringMap = UnorderedStringMap<ValueType>;
template<typename ValueType>
using StringMultiMap = std::multimap<std::string, ValueType, detail::transparent_string_less>;
using StringSet = std::set<std::string, detail::transparent_string_less>;
using StringMultiSet = std::multiset<std::string, detail::transparent_string_less>;
using PreferUnorderedStringMultimap = UnorderedStringMultimap<ValueType>;
using PreferUnorderedStringSet = UnorderedStringSet;
using PreferUnorderedStringMultiSet = UnorderedStringMultiSet;
#else
#pragma message "__cpp_lib_generic_unordered_lookup is missing, performance will be slower."
// GCC 10 doesn't support generic_unordered_lookup...
template<typename ValueType>
using PreferUnorderedStringMap = StringMap<ValueType>;
template<typename ValueType>
using PreferUnorderedStringMultimap = StringMultiMap<ValueType>;
using PreferUnorderedStringSet = StringSet;
using PreferUnorderedStringMultiSet = StringMultiSet;
#endif

View File

@ -9,52 +9,52 @@
class MemorySettingsInterface final : public SettingsInterface
{
public:
MemorySettingsInterface();
~MemorySettingsInterface();
MemorySettingsInterface();
~MemorySettingsInterface();
bool Save() override;
bool Save() override;
void Clear() override;
void Clear() override;
bool GetIntValue(const char* section, const char* key, s32* value) const override;
bool GetUIntValue(const char* section, const char* key, u32* value) const override;
bool GetFloatValue(const char* section, const char* key, float* value) const override;
bool GetDoubleValue(const char* section, const char* key, double* value) const override;
bool GetBoolValue(const char* section, const char* key, bool* value) const override;
bool GetStringValue(const char* section, const char* key, std::string* value) const override;
bool GetIntValue(const char* section, const char* key, s32* value) const override;
bool GetUIntValue(const char* section, const char* key, u32* value) const override;
bool GetFloatValue(const char* section, const char* key, float* value) const override;
bool GetDoubleValue(const char* section, const char* key, double* value) const override;
bool GetBoolValue(const char* section, const char* key, bool* value) const override;
bool GetStringValue(const char* section, const char* key, std::string* value) const override;
void SetIntValue(const char* section, const char* key, s32 value) override;
void SetUIntValue(const char* section, const char* key, u32 value) override;
void SetFloatValue(const char* section, const char* key, float value) override;
void SetDoubleValue(const char* section, const char* key, double value) override;
void SetBoolValue(const char* section, const char* key, bool value) override;
void SetStringValue(const char* section, const char* key, const char* value) override;
void SetIntValue(const char* section, const char* key, s32 value) override;
void SetUIntValue(const char* section, const char* key, u32 value) override;
void SetFloatValue(const char* section, const char* key, float value) override;
void SetDoubleValue(const char* section, const char* key, double value) override;
void SetBoolValue(const char* section, const char* key, bool value) override;
void SetStringValue(const char* section, const char* key, const char* value) override;
std::vector<std::pair<std::string, std::string>> GetKeyValueList(const char* section) const override;
void SetKeyValueList(const char* section, const std::vector<std::pair<std::string, std::string>>& items) override;
std::vector<std::pair<std::string, std::string>> GetKeyValueList(const char* section) const override;
void SetKeyValueList(const char* section, const std::vector<std::pair<std::string, std::string>>& items) override;
bool ContainsValue(const char* section, const char* key) const override;
void DeleteValue(const char* section, const char* key) override;
void ClearSection(const char* section) override;
bool ContainsValue(const char* section, const char* key) const override;
void DeleteValue(const char* section, const char* key) override;
void ClearSection(const char* section) override;
std::vector<std::string> GetStringList(const char* section, const char* key) const override;
void SetStringList(const char* section, const char* key, const std::vector<std::string>& items) override;
bool RemoveFromStringList(const char* section, const char* key, const char* item) override;
bool AddToStringList(const char* section, const char* key, const char* item) override;
std::vector<std::string> GetStringList(const char* section, const char* key) const override;
void SetStringList(const char* section, const char* key, const std::vector<std::string>& items) override;
bool RemoveFromStringList(const char* section, const char* key, const char* item) override;
bool AddToStringList(const char* section, const char* key, const char* item) override;
// default parameter overloads
using SettingsInterface::GetBoolValue;
using SettingsInterface::GetDoubleValue;
using SettingsInterface::GetFloatValue;
using SettingsInterface::GetIntValue;
using SettingsInterface::GetStringValue;
using SettingsInterface::GetUIntValue;
// default parameter overloads
using SettingsInterface::GetBoolValue;
using SettingsInterface::GetDoubleValue;
using SettingsInterface::GetFloatValue;
using SettingsInterface::GetIntValue;
using SettingsInterface::GetStringValue;
using SettingsInterface::GetUIntValue;
private:
using KeyMap = UnorderedStringMultimap<std::string>;
using SectionMap = UnorderedStringMap<KeyMap>;
using KeyMap = PreferUnorderedStringMultimap<std::string>;
using SectionMap = PreferUnorderedStringMap<KeyMap>;
void SetValue(const char* section, const char* key, std::string value);
void SetValue(const char* section, const char* key, std::string value);
SectionMap m_sections;
};
SectionMap m_sections;
};

View File

@ -1558,6 +1558,8 @@ static constexpr std::array<RT, 256> GetHardwareRegisterHandlerTable()
ret[i] = UnmappedWriteHandler<size>;
}
#if 0
// Verifies no region has >1 handler, but doesn't compile on older GCC.
#define SET(raddr, rsize, read_handler, write_handler) \
static_assert(raddr >= 0x1F801000 && (raddr + rsize) <= 0x1F802000); \
for (u32 taddr = raddr; taddr < (raddr + rsize); taddr += 16) \
@ -1568,6 +1570,18 @@ static constexpr std::array<RT, 256> GetHardwareRegisterHandlerTable()
else \
ret[i] = (ret[i] == UnmappedWriteHandler<size>) ? write_handler<size> : (abort(), write_handler<size>); \
}
#else
#define SET(raddr, rsize, read_handler, write_handler) \
static_assert(raddr >= 0x1F801000 && (raddr + rsize) <= 0x1F802000); \
for (u32 taddr = raddr; taddr < (raddr + rsize); taddr += 16) \
{ \
const u32 i = (taddr >> 4) & 0xFFu; \
if constexpr (type == MemoryAccessType::Read) \
ret[i] = read_handler<size>; \
else \
ret[i] = write_handler<size>; \
}
#endif
SET(MEMCTRL_BASE, MEMCTRL_SIZE, MemCtrlRead, MemCtrlWrite);
SET(PAD_BASE, PAD_SIZE, PADRead, PADWrite);

View File

@ -75,7 +75,7 @@ static bool s_loaded = false;
static bool s_track_hashes_loaded = false;
static std::vector<GameDatabase::Entry> s_entries;
static UnorderedStringMap<u32> s_code_lookup;
static PreferUnorderedStringMap<u32> s_code_lookup;
static TrackHashesMap s_track_hashes_map;
} // namespace GameDatabase

View File

@ -54,8 +54,8 @@ struct PlayedTimeEntry
std::time_t total_played_time;
};
using CacheMap = UnorderedStringMap<Entry>;
using PlayedTimeMap = UnorderedStringMap<PlayedTimeEntry>;
using CacheMap = PreferUnorderedStringMap<Entry>;
using PlayedTimeMap = PreferUnorderedStringMap<PlayedTimeEntry>;
static_assert(std::is_same_v<decltype(Entry::hash), System::GameHash>);

View File

@ -18,8 +18,8 @@ static std::pair<const char*, u32> LookupTranslationString(const std::string_vie
const std::string_view& msg);
static constexpr u32 TRANSLATION_STRING_CACHE_SIZE = 4 * 1024 * 1024;
using TranslationStringMap = UnorderedStringMap<std::pair<u32, u32>>;
using TranslationStringContextMap = UnorderedStringMap<TranslationStringMap>;
using TranslationStringMap = PreferUnorderedStringMap<std::pair<u32, u32>>;
using TranslationStringContextMap = PreferUnorderedStringMap<TranslationStringMap>;
static std::shared_mutex s_translation_string_mutex;
static TranslationStringContextMap s_translation_string_map;
static std::vector<char> s_translation_string_cache;