Kinoko
v0.6
A reimplementation of Mario Kart Wii's physics engine in C++
Toggle main menu visibility
Loading...
Searching...
No Matches
Memory.hh
Go to the documentation of this file.
1
#pragma once
2
3
#include <
Logger.hh
>
4
5
#include <cstdint>
6
7
namespace
Kinoko
{
8
9
// We can't include Common.hh, because we have a cyclic dependency
10
// Instead, we redefine the types for use in memory code
11
typedef
int8_t
s8
;
12
typedef
int16_t
s16
;
13
typedef
int32_t
s32
;
14
typedef
int64_t
s64
;
15
16
typedef
uint8_t
u8
;
17
typedef
uint16_t
u16
;
18
typedef
uint32_t
u32
;
19
typedef
uint64_t
u64
;
20
21
typedef
float
f32
;
22
typedef
double
f64
;
23
24
static
inline
uintptr_t
GetAddrNum
(
const
void
*p) {
25
return
reinterpret_cast<
uintptr_t
>
(p);
26
}
27
28
static
inline
void
*
GetAddrPtr
(uintptr_t n) {
29
return
reinterpret_cast<
void
*
>
(n);
30
}
31
32
static
inline
void
*
AddOffset
(
const
void
*p,
size_t
offset) {
33
return
GetAddrPtr
(
GetAddrNum
(p) + offset);
34
}
35
36
static
inline
void
*
SubOffset
(
const
void
*p,
size_t
offset) {
37
return
GetAddrPtr
(
GetAddrNum
(p) - offset);
38
}
39
40
static
inline
uintptr_t
RoundUp
(uintptr_t value, uintptr_t alignment) {
41
return
(value + alignment - 1) & ~(alignment - 1);
42
}
43
44
static
inline
void
*
RoundUp
(
void
*ptr, uintptr_t alignment) {
45
return
GetAddrPtr
(
RoundUp
(
GetAddrNum
(ptr), alignment));
46
}
47
48
static
inline
uintptr_t
RoundDown
(uintptr_t value, uintptr_t alignment) {
49
return
value & ~(alignment - 1);
50
}
51
52
static
inline
void
*
RoundDown
(
void
*ptr, uintptr_t alignment) {
53
return
GetAddrPtr
(
RoundDown
(
GetAddrNum
(ptr), alignment));
54
}
55
56
}
// namespace Kinoko
Logger.hh
uint16_t
Kinoko
Definition
abstract/Archive.cc:5
Kinoko::GetAddrPtr
static void * GetAddrPtr(uintptr_t n)
Definition
Memory.hh:28
Kinoko::SubOffset
static void * SubOffset(const void *p, size_t offset)
Definition
Memory.hh:36
Kinoko::s64
int64_t s64
Definition
Memory.hh:14
Kinoko::u64
uint64_t u64
Definition
Memory.hh:19
Kinoko::f32
float f32
Definition
Memory.hh:21
Kinoko::RoundDown
static uintptr_t RoundDown(uintptr_t value, uintptr_t alignment)
Definition
Memory.hh:48
Kinoko::GetAddrNum
static uintptr_t GetAddrNum(const void *p)
Definition
Memory.hh:24
Kinoko::u8
uint8_t u8
Definition
Memory.hh:16
Kinoko::f64
double f64
Definition
Memory.hh:22
Kinoko::s8
int8_t s8
Definition
Memory.hh:11
Kinoko::s16
int16_t s16
Definition
Memory.hh:12
Kinoko::AddOffset
static void * AddOffset(const void *p, size_t offset)
Definition
Memory.hh:32
Kinoko::u16
uint16_t u16
Definition
Memory.hh:17
Kinoko::s32
int32_t s32
Definition
Memory.hh:13
Kinoko::RoundUp
static uintptr_t RoundUp(uintptr_t value, uintptr_t alignment)
Definition
Memory.hh:40
Kinoko::u32
uint32_t u32
Definition
Memory.hh:18
abstract
memory
Memory.hh
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.18.0