2 // TaskEffectivePolicy.hpp
5 // Created by James McIlree on 6/19/14.
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)
14 class TaskEffectivePolicy {
17 Kernel32::ptr_t _kernel_32[2];
18 Kernel64::ptr_t _kernel_64;
19 struct task_effective_policy _policy;
23 TaskEffectivePolicy() {}
25 TaskEffectivePolicy(struct task_effective_policy policy) {
26 static_assert(sizeof(_content) == sizeof(struct task_effective_policy), "Sanity");
27 _content._policy = policy;
30 TaskEffectivePolicy(Kernel64::ptr_t teffective_0) {
31 static_assert(sizeof(_content) == sizeof(teffective_0), "Sanity");
32 _content._kernel_64 = teffective_0;
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;
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); }
44 TaskEffectivePolicy operator~() const { return TaskEffectivePolicy(~this->_content._kernel_64); }
46 struct task_effective_policy as_struct() { return _content._policy; }