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