]>
Commit | Line | Data |
---|---|---|
bd6521f0 A |
1 | // |
2 | // TaskRequestedPolicy.hpp | |
3 | // system_cmds | |
4 | // | |
5 | // Created by James McIlree on 6/23/14. | |
6 | // | |
7 | // | |
8 | ||
9 | ||
10 | // Using the raw struct was causing alignment issues on arm32; it seems that | |
11 | // structs have very relaxed alignment requirements on the v7 architectures. | |
12 | // The class wrapper forces a higher alignment and allows for some convenience | |
13 | // operators (compare, xor, etc) | |
14 | ||
15 | class TaskRequestedPolicy { | |
16 | protected: | |
17 | union { | |
18 | Kernel32::ptr_t _kernel_32[2]; | |
19 | Kernel64::ptr_t _kernel_64; | |
20 | struct task_requested_policy _policy; | |
21 | } _content; | |
22 | ||
23 | public: | |
24 | TaskRequestedPolicy() {} | |
25 | ||
26 | TaskRequestedPolicy(struct task_requested_policy policy) { | |
27 | static_assert(sizeof(_content) == sizeof(struct task_requested_policy), "Sanity"); | |
28 | _content._policy = policy; | |
29 | } | |
30 | ||
31 | TaskRequestedPolicy(Kernel64::ptr_t trequested_0) { | |
32 | static_assert(sizeof(_content) == sizeof(trequested_0), "Sanity"); | |
33 | _content._kernel_64 = trequested_0; | |
34 | } | |
35 | ||
36 | TaskRequestedPolicy(Kernel32::ptr_t trequested_0, Kernel32::ptr_t trequested_1) { | |
37 | static_assert(sizeof(_content) == (sizeof(trequested_0) + sizeof(trequested_1)), "Sanity"); | |
38 | _content._kernel_32[0] = trequested_0; | |
39 | _content._kernel_32[1] = trequested_1; | |
40 | } | |
41 | ||
42 | bool operator==(const TaskRequestedPolicy& other) const { return this->_content._kernel_64 == other._content._kernel_64; } | |
43 | bool operator!=(const TaskRequestedPolicy& other) const { return !(*this == other); } | |
44 | ||
45 | TaskRequestedPolicy operator~() const { return TaskRequestedPolicy(~this->_content._kernel_64); } | |
46 | ||
47 | struct task_requested_policy as_struct() { return _content._policy; } | |
48 | }; |