mirror of
https://github.com/wolfpld/tracy.git
synced 2026-09-02 16:38:30 +00:00
36 lines
651 B
C++
36 lines
651 B
C++
#ifndef __TRACYALIGN_HPP__
|
|
#define __TRACYALIGN_HPP__
|
|
|
|
#include <string.h>
|
|
#include <type_traits>
|
|
|
|
#include "TracyForceInline.hpp"
|
|
|
|
#if defined _MSC_VER && !defined _M_IX86
|
|
# define TracyUnaligned __unaligned
|
|
#else
|
|
# define TracyUnaligned
|
|
#endif
|
|
|
|
namespace tracy
|
|
{
|
|
|
|
template<typename T>
|
|
tracy_force_inline T MemRead( const TracyUnaligned T* ptr )
|
|
{
|
|
T val;
|
|
memcpy( &val, ptr, sizeof( T ) );
|
|
return val;
|
|
}
|
|
|
|
template<typename T, typename U>
|
|
tracy_force_inline void MemWrite( TracyUnaligned T* ptr, U val )
|
|
{
|
|
static_assert( std::is_same<T, U>::value, "MemWrite type mismatch" );
|
|
memcpy( (void*)ptr, &val, sizeof( T ) );
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|