-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdemo-userfeatures.cpp
45 lines (38 loc) · 1.14 KB
/
demo-userfeatures.cpp
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
//----------------------------------------------------------------------------
//
// Arm64 CPU system registers tools
// Copyright (c) 2023, Thierry Lelegard
// BSD-2-Clause license, see the LICENSE file.
//
// Demo program: display Arm features from userland only.
//
//----------------------------------------------------------------------------
#include "strutils.h"
#include "userfeatures.h"
#include <iostream>
#include <string>
#include <list>
// Descriptions of all features.
class Feature
{
public:
std::string name; // Feature name
bool (UserFeatures::*get)(); // Method to get that feature
};
const std::list<Feature> AllUserFeatures {
// Automatically generated file:
#include "_userfeatures.h"
};
// Program entry point
int main(int argc, char* argv[])
{
size_t name_width = 0;
for (const auto& feat : AllUserFeatures) {
name_width = std::max(name_width, feat.name.length());
}
UserFeatures features;
for (const auto& feat : AllUserFeatures) {
std::cout << Pad(feat.name + " ", name_width + 2) << " " << YesNo((features.*feat.get)()) << std::endl;
}
return EXIT_SUCCESS;
}