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 } // 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> template<typename ValueType>
using UnorderedStringMap = using UnorderedStringMap =
std::unordered_map<std::string, ValueType, detail::transparent_string_hash, detail::transparent_string_equal>; 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>; std::unordered_multiset<std::string, detail::transparent_string_hash, detail::transparent_string_equal>;
template<typename ValueType> template<typename ValueType>
using StringMap = std::map<std::string, ValueType, detail::transparent_string_less>; using PreferUnorderedStringMap = UnorderedStringMap<ValueType>;
template<typename ValueType> template<typename ValueType>
using StringMultiMap = std::multimap<std::string, ValueType, detail::transparent_string_less>; using PreferUnorderedStringMultimap = UnorderedStringMultimap<ValueType>;
using StringSet = std::set<std::string, detail::transparent_string_less>; using PreferUnorderedStringSet = UnorderedStringSet;
using StringMultiSet = std::multiset<std::string, detail::transparent_string_less>; 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

@ -51,8 +51,8 @@ public:
using SettingsInterface::GetUIntValue; using SettingsInterface::GetUIntValue;
private: private:
using KeyMap = UnorderedStringMultimap<std::string>; using KeyMap = PreferUnorderedStringMultimap<std::string>;
using SectionMap = UnorderedStringMap<KeyMap>; 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);

View file

@ -1558,6 +1558,8 @@ static constexpr std::array<RT, 256> GetHardwareRegisterHandlerTable()
ret[i] = UnmappedWriteHandler<size>; 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) \ #define SET(raddr, rsize, read_handler, write_handler) \
static_assert(raddr >= 0x1F801000 && (raddr + rsize) <= 0x1F802000); \ static_assert(raddr >= 0x1F801000 && (raddr + rsize) <= 0x1F802000); \
for (u32 taddr = raddr; taddr < (raddr + rsize); taddr += 16) \ for (u32 taddr = raddr; taddr < (raddr + rsize); taddr += 16) \
@ -1568,6 +1570,18 @@ static constexpr std::array<RT, 256> GetHardwareRegisterHandlerTable()
else \ else \
ret[i] = (ret[i] == UnmappedWriteHandler<size>) ? write_handler<size> : (abort(), write_handler<size>); \ 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(MEMCTRL_BASE, MEMCTRL_SIZE, MemCtrlRead, MemCtrlWrite);
SET(PAD_BASE, PAD_SIZE, PADRead, PADWrite); 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 bool s_track_hashes_loaded = false;
static std::vector<GameDatabase::Entry> s_entries; 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; static TrackHashesMap s_track_hashes_map;
} // namespace GameDatabase } // namespace GameDatabase

View file

@ -54,8 +54,8 @@ struct PlayedTimeEntry
std::time_t total_played_time; std::time_t total_played_time;
}; };
using CacheMap = UnorderedStringMap<Entry>; using CacheMap = PreferUnorderedStringMap<Entry>;
using PlayedTimeMap = UnorderedStringMap<PlayedTimeEntry>; using PlayedTimeMap = PreferUnorderedStringMap<PlayedTimeEntry>;
static_assert(std::is_same_v<decltype(Entry::hash), System::GameHash>); 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); const std::string_view& msg);
static constexpr u32 TRANSLATION_STRING_CACHE_SIZE = 4 * 1024 * 1024; static constexpr u32 TRANSLATION_STRING_CACHE_SIZE = 4 * 1024 * 1024;
using TranslationStringMap = UnorderedStringMap<std::pair<u32, u32>>; using TranslationStringMap = PreferUnorderedStringMap<std::pair<u32, u32>>;
using TranslationStringContextMap = UnorderedStringMap<TranslationStringMap>; using TranslationStringContextMap = PreferUnorderedStringMap<TranslationStringMap>;
static std::shared_mutex s_translation_string_mutex; static std::shared_mutex s_translation_string_mutex;
static TranslationStringContextMap s_translation_string_map; static TranslationStringContextMap s_translation_string_map;
static std::vector<char> s_translation_string_cache; static std::vector<char> s_translation_string_cache;