1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Workaround for Clang: move bless to its own header file

This commit is contained in:
oltolm 2023-08-19 12:30:46 +02:00 committed by GitHub
parent f1d9e89418
commit 373e502501
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 19 deletions

View File

@ -2,7 +2,7 @@
#include "util/types.hpp"
#include "util/atomic.hpp"
#include "util/asm.hpp"
#include "util/bless.hpp"
//! Simple unshrinkable array base for concurrent access. Only growths automatically.
//! There is no way to know the current size. The smaller index is, the faster it's accessed.

View File

@ -611,6 +611,7 @@
<ClInclude Include="Loader\mself.hpp" />
<ClInclude Include="io_buffer.h" />
<ClInclude Include="util\atomic.hpp" />
<ClInclude Include="util\bless.hpp" />
<ClInclude Include="util\image_sink.h" />
<ClInclude Include="util\video_provider.h" />
<ClInclude Include="util\media_utils.h" />

View File

@ -2371,6 +2371,9 @@
<ClInclude Include="Emu\RSX\Common\unordered_map.hpp">
<Filter>Emu\GPU\RSX\Common</Filter>
</ClInclude>
<ClInclude Include="util\bless.hpp">
<Filter>Utilities</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="Emu\RSX\Program\GLSLSnippets\GPUDeswizzle.glsl">

View File

@ -410,23 +410,6 @@ namespace utils
return factor1 > 0 && T{umax} / factor1 < factor2 ? T{umax} : static_cast<T>(factor1 * factor2);
}
// Hack. Pointer cast util to workaround UB. Use with extreme care.
template <typename T, typename U>
[[nodiscard]] T* bless(U* ptr)
{
#ifdef _MSC_VER
return (T*)ptr;
#elif defined(ARCH_X64)
T* result;
__asm__("movq %1, %0;" : "=r" (result) : "r" (ptr) : "memory");
return result;
#elif defined(ARCH_ARM64)
T* result;
__asm__("mov %0, %1" : "=r" (result) : "r" (ptr) : "memory");
return result;
#endif
}
inline void trap()
{
#ifdef _M_X64

21
rpcs3/util/bless.hpp Normal file
View File

@ -0,0 +1,21 @@
#pragma once
namespace utils
{
// Hack. Pointer cast util to workaround UB. Use with extreme care.
template <typename T, typename U>
[[nodiscard]] T* bless(U* ptr)
{
#ifdef _MSC_VER
return (T*)ptr;
#elif defined(ARCH_X64)
T* result;
__asm__("movq %1, %0;" : "=r" (result) : "r" (ptr) : "memory");
return result;
#elif defined(ARCH_ARM64)
T* result;
__asm__("mov %0, %1" : "=r" (result) : "r" (ptr) : "memory");
return result;
#endif
}
}

View File

@ -3,7 +3,7 @@
#include <cstdint>
#include <memory>
#include "atomic.hpp"
#include "asm.hpp"
#include "bless.hpp"
namespace stx
{