mirror of
https://github.com/yse/easy_profiler.git
synced 2025-01-14 00:27:55 +08:00
#108 fix [Core] clang build for arbitrary values
This commit is contained in:
parent
1301dd05dc
commit
8623fa81bb
@ -54,7 +54,7 @@ namespace profiler
|
|||||||
class ValueId EASY_FINAL
|
class ValueId EASY_FINAL
|
||||||
{
|
{
|
||||||
friend ::ThreadStorage;
|
friend ::ThreadStorage;
|
||||||
vin_t m_id;
|
const void* m_id;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -66,14 +66,14 @@ namespace profiler
|
|||||||
inline EASY_CONSTEXPR_FCN ValueId(ValueId&&) = default;
|
inline EASY_CONSTEXPR_FCN ValueId(ValueId&&) = default;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
explicit inline EASY_CONSTEXPR_FCN ValueId() : m_id(0) {}
|
explicit inline EASY_CONSTEXPR_FCN ValueId() : m_id(nullptr) {}
|
||||||
explicit inline EASY_CONSTEXPR_FCN ValueId(const void* _member) : m_id(reinterpret_cast<vin_t>(_member)) {}
|
explicit inline EASY_CONSTEXPR_FCN ValueId(const void* _member) : m_id(_member) {}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
explicit inline EASY_CONSTEXPR_FCN ValueId(const T& _member) : m_id(reinterpret_cast<vin_t>(&_member)) {}
|
explicit inline EASY_CONSTEXPR_FCN ValueId(const T& _member) : m_id(&_member) {}
|
||||||
|
|
||||||
template <class T, size_t N>
|
template <class T, size_t N>
|
||||||
explicit inline EASY_CONSTEXPR_FCN ValueId(const T (&_member)[N]) : m_id(reinterpret_cast<vin_t>((void*)_member)) {}
|
explicit inline EASY_CONSTEXPR_FCN ValueId(const T (&_member)[N]) : m_id(_member) {}
|
||||||
|
|
||||||
ValueId& operator = (const ValueId&) = delete;
|
ValueId& operator = (const ValueId&) = delete;
|
||||||
ValueId& operator = (ValueId&&) = delete;
|
ValueId& operator = (ValueId&&) = delete;
|
||||||
|
@ -44,6 +44,17 @@ The Apache License, Version 2.0 (the "License");
|
|||||||
#include "current_thread.h"
|
#include "current_thread.h"
|
||||||
#include "current_time.h"
|
#include "current_time.h"
|
||||||
|
|
||||||
|
static profiler::vin_t ptr2vin(const void* ptr)
|
||||||
|
{
|
||||||
|
static_assert(sizeof(uintptr_t) == sizeof(void*),
|
||||||
|
"Can not cast void* to uintptr_t. Different sizes.");
|
||||||
|
|
||||||
|
static_assert(sizeof(profiler::vin_t) >= sizeof(uintptr_t),
|
||||||
|
"Can not cast uintptr_t to vin_t. Possible truncation.");
|
||||||
|
|
||||||
|
return static_cast<profiler::vin_t>(reinterpret_cast<uintptr_t>(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
ThreadStorage::ThreadStorage()
|
ThreadStorage::ThreadStorage()
|
||||||
: nonscopedBlocks(16)
|
: nonscopedBlocks(16)
|
||||||
, frameStartTime(0)
|
, frameStartTime(0)
|
||||||
@ -62,7 +73,7 @@ void ThreadStorage::storeValue(profiler::timestamp_t _timestamp, profiler::block
|
|||||||
const uint16_t serializedDataSize = _size + static_cast<uint16_t>(sizeof(profiler::ArbitraryValue));
|
const uint16_t serializedDataSize = _size + static_cast<uint16_t>(sizeof(profiler::ArbitraryValue));
|
||||||
void* data = blocks.closedList.allocate(serializedDataSize);
|
void* data = blocks.closedList.allocate(serializedDataSize);
|
||||||
|
|
||||||
::new (data) profiler::ArbitraryValue(_timestamp, _vin.m_id, _id, _size, _type, _isArray);
|
::new (data) profiler::ArbitraryValue(_timestamp, ptr2vin(_vin.m_id), _id, _size, _type, _isArray);
|
||||||
|
|
||||||
char* cdata = reinterpret_cast<char*>(data);
|
char* cdata = reinterpret_cast<char*>(data);
|
||||||
memcpy(cdata + sizeof(profiler::ArbitraryValue), _data, _size);
|
memcpy(cdata + sizeof(profiler::ArbitraryValue), _data, _size);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user