mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 11:36:13 +00:00
fixed_typemap.hpp: remove <algorithm> dep in header
Create fixed_typemap.cpp
This commit is contained in:
parent
bacd1698fc
commit
4474757162
5 changed files with 39 additions and 14 deletions
|
@ -30,6 +30,7 @@ target_sources(rpcs3_emu PRIVATE
|
|||
../util/atomic.cpp
|
||||
../util/atomic2.cpp
|
||||
../util/shared_cptr.cpp
|
||||
../util/fixed_typemap.cpp
|
||||
../../Utilities/bin_patch.cpp
|
||||
../../Utilities/cond.cpp
|
||||
../../Utilities/Config.cpp
|
||||
|
|
|
@ -88,6 +88,9 @@
|
|||
<ClCompile Include="util\shared_cptr.cpp">
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="util\fixed_typemap.cpp">
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Utilities\bin_patch.cpp">
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
|
|
|
@ -869,6 +869,9 @@
|
|||
<ClCompile Include="util\shared_cptr.cpp">
|
||||
<Filter>Utilities</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="util\fixed_typemap.cpp">
|
||||
<Filter>Utilities</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Crypto\aesni.cpp">
|
||||
<Filter>Crypto</Filter>
|
||||
</ClCompile>
|
||||
|
|
15
rpcs3/util/fixed_typemap.cpp
Normal file
15
rpcs3/util/fixed_typemap.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include "fixed_typemap.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace stx::detail
|
||||
{
|
||||
void destroy_info::sort_by_reverse_creation_order(destroy_info* begin, destroy_info* end)
|
||||
{
|
||||
std::sort(begin, end, [](const destroy_info& a, const destroy_info& b)
|
||||
{
|
||||
// Destroy order is the inverse of creation order
|
||||
return a.created > b.created;
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,13 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <typeinfo>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
#include <algorithm>
|
||||
#include <util/typeindices.hpp>
|
||||
|
||||
namespace stx
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
// Destroy list element
|
||||
struct destroy_info
|
||||
{
|
||||
void** object_pointer;
|
||||
unsigned long long created;
|
||||
void(*destroy)(void*& ptr) noexcept;
|
||||
const char* name;
|
||||
|
||||
static void sort_by_reverse_creation_order(destroy_info* begin, destroy_info* end);
|
||||
};
|
||||
}
|
||||
|
||||
// Typemap with exactly one object of each used type, created on init() and destroyed on clear()
|
||||
template <typename /*Tag*/, bool Report = true>
|
||||
class manual_fixed_typemap
|
||||
|
@ -111,14 +125,7 @@ namespace stx
|
|||
return;
|
||||
}
|
||||
|
||||
// Destroy list element
|
||||
struct destroy_info
|
||||
{
|
||||
void** object_pointer;
|
||||
unsigned long long created;
|
||||
void(*destroy)(void*& ptr) noexcept;
|
||||
const char* name;
|
||||
};
|
||||
using detail::destroy_info;
|
||||
|
||||
auto all_data = std::make_unique<destroy_info[]>(stx::typelist<typeinfo>().count());
|
||||
|
||||
|
@ -145,11 +152,7 @@ namespace stx
|
|||
}
|
||||
|
||||
// Sort destroy list according to absolute creation order
|
||||
std::sort(all_data.get(), all_data.get() + _max, [](const destroy_info& a, const destroy_info& b)
|
||||
{
|
||||
// Destroy order is the inverse of creation order
|
||||
return a.created > b.created;
|
||||
});
|
||||
destroy_info::sort_by_reverse_creation_order(all_data.get(), all_data.get() + _max);
|
||||
|
||||
// Destroy objects in correct order
|
||||
for (unsigned i = 0; i < _max; i++)
|
||||
|
|
Loading…
Add table
Reference in a new issue