ReXGlue SDK
Toggle main menu visibility
Loading...
Searching...
No Matches
host.h
Go to the documentation of this file.
1
10
11
#pragma once
12
13
#include <array>
14
#include <cstddef>
15
16
#include <
rex/platform.h
>
17
#include <
rex/types.h
>
18
19
namespace
rex::memory
{
20
22
enum class
Tag
: u8 {
23
kCore
= 0,
24
kThirdParty
= 1,
25
};
26
28
inline
constexpr
size_t
kMaxTags
= 16;
29
30
struct
TagStats
{
31
u64
live_bytes
= 0;
32
u64
live_count
= 0;
33
u64
peak_bytes
= 0;
34
u64
total_count
= 0;
35
};
36
37
struct
HostStats
{
38
std::array<TagStats, kMaxTags>
39
tags
{};
40
TagStats
total;
41
};
42
50
REX_API
void
*
HostAlloc
(
size_t
size,
size_t
align = 0) noexcept;
51
59
REX_API
void
HostFree
(
void
* ptr,
size_t
size = 0,
size_t
align = 0) noexcept;
60
66
REX_API
size_t
HostSize
(const
void
* ptr) noexcept;
67
69
REX_API
HostStats
GetHostStats
() noexcept;
70
76
REX_API
void
SetAllocStackDepth
(i32 depth) noexcept;
77
79
[[nodiscard]]
REX_API
i32
GetAllocStackDepth
() noexcept;
80
82
REX_API
Tag
GetThreadTag
() noexcept;
83
87
REX_API
const
char
*
GetTagName
(
Tag
tag) noexcept;
88
95
REX_API
void
SetTagName
(
Tag
tag, const
char
* name) noexcept;
96
98
class
REX_API
TagScope
{
99
public
:
105
explicit
TagScope
(
Tag
tag)
noexcept
;
106
108
~TagScope
();
109
110
TagScope
(
const
TagScope
&) =
delete
;
111
TagScope
& operator=(
const
TagScope
&) =
delete
;
112
113
private
:
114
Tag
previous_;
115
};
116
117
namespace
detail {
118
120
enum class
BlockError : u8 {
121
kForeignPointer,
122
kTypeMismatch,
123
kSizeMismatch,
124
};
125
127
using
BlockErrorHandler = void (*)(BlockError error,
const
void
* ptr);
128
135
REX_API
BlockErrorHandler SetBlockErrorHandler(BlockErrorHandler handler)
noexcept
;
136
142
REX_API
void
FailNextAllocations(u32 count)
noexcept
;
143
145
enum class
AllocType : u8 {
146
kScalar,
147
kArray,
148
kRaw,
149
};
150
160
REX_API
void
* NewBlock(
size_t
size,
size_t
align, AllocType type,
bool
can_throw);
161
169
REX_API
void
DeleteBlock(
void
* ptr,
size_t
size, AllocType type)
noexcept
;
170
171
}
// namespace detail
172
173
}
// namespace rex::memory
rex::memory::TagScope::~TagScope
~TagScope()
rex::memory::TagScope::TagScope
TagScope(Tag tag) noexcept
rex::memory
Definition
endian.h:27
rex::memory::HostSize
size_t HostSize(const void *ptr) noexcept
rex::memory::GetTagName
const char * GetTagName(Tag tag) noexcept
rex::memory::kMaxTags
constexpr size_t kMaxTags
Definition
host.h:28
rex::memory::HostFree
void HostFree(void *ptr, size_t size=0, size_t align=0) noexcept
rex::memory::GetHostStats
HostStats GetHostStats() noexcept
rex::memory::SetAllocStackDepth
void SetAllocStackDepth(i32 depth) noexcept
rex::memory::HostAlloc
void * HostAlloc(size_t size, size_t align=0) noexcept
rex::memory::GetAllocStackDepth
i32 GetAllocStackDepth() noexcept
rex::memory::SetTagName
void SetTagName(Tag tag, const char *name) noexcept
rex::memory::GetThreadTag
Tag GetThreadTag() noexcept
rex::memory::Tag
Tag
Definition
host.h:22
rex::memory::Tag::kThirdParty
@ kThirdParty
Definition
host.h:24
rex::memory::Tag::kCore
@ kCore
Definition
host.h:23
platform.h
Platform flags, packing macros and export markers.
REX_API
#define REX_API
Definition
platform.h:177
rex::memory::HostStats
Definition
host.h:37
rex::memory::HostStats::tags
std::array< TagStats, kMaxTags > tags
Definition
host.h:39
rex::memory::TagStats
Definition
host.h:30
rex::memory::TagStats::total_count
u64 total_count
Definition
host.h:34
rex::memory::TagStats::live_count
u64 live_count
Definition
host.h:32
rex::memory::TagStats::live_bytes
u64 live_bytes
Definition
host.h:31
rex::memory::TagStats::peak_bytes
u64 peak_bytes
Definition
host.h:33
types.h
Integer types, byte order wrappers and size literals.
rex
memory
host.h
Generated by
1.18.0