2 // TaskRequestedPolicy.hpp
5 // Created by James McIlree on 6/23/14.
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)
15 class TaskRequestedPolicy {
18 Kernel32::ptr_t _kernel_32[2];
19 Kernel64::ptr_t _kernel_64;
20 struct task_requested_policy _policy;
24 TaskRequestedPolicy() {}
26 TaskRequestedPolicy(struct task_requested_policy policy) {
27 static_assert(sizeof(_content) == sizeof(struct task_requested_policy), "Sanity");
28 _content._policy = policy;
31 TaskRequestedPolicy(Kernel64::ptr_t trequested_0) {
32 static_assert(sizeof(_content) == sizeof(trequested_0), "Sanity");
33 _content._kernel_64 = trequested_0;
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;
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); }
45 TaskRequestedPolicy operator~() const { return TaskRequestedPolicy(~this->_content._kernel_64); }
47 struct task_requested_policy as_struct() { return _content._policy; }