platform_info.cpp
1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <ion.h>
#include <assert.h>
#ifndef PATCH_LEVEL
#error This file expects PATCH_LEVEL to be defined
#endif
#ifndef EPSILON_VERSION
#error This file expects EPSILON_VERSION to be defined
#endif
#ifndef HEADER_SECTION
#define HEADER_SECTION
#endif
namespace Ion {
extern char staticStorageArea[];
}
constexpr void * storageAddress = &(Ion::staticStorageArea);
class PlatformInfo {
public:
constexpr PlatformInfo() :
m_header(Magic),
m_version{EPSILON_VERSION},
m_patchLevel{PATCH_LEVEL},
m_storageAddress(storageAddress),
m_footer(Magic) { }
const char * version() const {
assert(m_storageAddress != nullptr);
assert(m_header == Magic);
assert(m_footer == Magic);
return m_version;
}
const char * patchLevel() const {
assert(m_storageAddress != nullptr);
assert(m_header == Magic);
assert(m_footer == Magic);
return m_patchLevel;
}
private:
constexpr static uint32_t Magic = 0xDEC00DF0;
uint32_t m_header;
const char m_version[8];
const char m_patchLevel[8];
void * m_storageAddress;
uint32_t m_footer;
};
constexpr PlatformInfo HEADER_SECTION platform_infos;
const char * Ion::softwareVersion() {
return platform_infos.version();
}
const char * Ion::patchLevel() {
return platform_infos.patchLevel();
}