Debian Codegraph @

third_party/rust/mach2/src/thread_policy.rs

raw
1 //! This module corresponds to `mach/thread_policy.h`.
2
3 use boolean::boolean_t;
4 use kern_return::kern_return_t;
5 use libc::thread_policy_t;
6 use mach_types::thread_t;
7 use message::mach_msg_type_number_t;
8 use vm_types::{integer_t, natural_t};
9
10 pub type thread_policy_flavor_t = natural_t;
11
12 pub const THREAD_STANDARD_POLICY: thread_policy_flavor_t = 1;
13 pub const THREAD_EXTENDED_POLICY: thread_policy_flavor_t = 1;
14 pub const THREAD_TIME_CONSTRAINT_POLICY: thread_policy_flavor_t = 2;
15 pub const THREAD_PRECEDENCE_POLICY: thread_policy_flavor_t = 3;
16 pub const THREAD_AFFINITY_POLICY: thread_policy_flavor_t = 4;
17 pub const THREAD_BACKGROUND_POLICY: thread_policy_flavor_t = 5;
18 pub const THREAD_LATENCY_QOS_POLICY: thread_policy_flavor_t = 7;
19 pub const THREAD_THROUGHPUT_QOS_POLICY: thread_policy_flavor_t = 8;
20
21 #[repr(C)]
22 #[derive(Clone, Copy, Debug)]
23 pub struct thread_standard_policy {
24 pub no_data: natural_t,
25 }
26
27 #[repr(C)]
28 #[derive(Clone, Copy, Debug)]
29 pub struct thread_extended_policy {
30 pub timeshare: boolean_t,
31 }
32
33 #[repr(C)]
34 #[derive(Clone, Copy, Debug)]
35 pub struct thread_time_constraint_policy {
36 pub period: u32,
37 pub computation: u32,
38 pub constraint: u32,
39 pub preemptible: boolean_t,
40 }
41
42 #[repr(C)]
43 #[derive(Clone, Copy, Debug)]
44 pub struct thread_precedence_policy {
45 pub importance: integer_t,
46 }
47
48 #[repr(C)]
49 #[derive(Clone, Copy, Debug)]
50 pub struct thread_affinity_policy {
51 pub affinity_tag: integer_t,
52 }
53
54 pub const THREAD_AFFINITY_TAG_NULL: integer_t = 0;
55
56 #[repr(C)]
57 #[derive(Clone, Copy, Debug)]
58 pub struct thread_background_policy {
59 pub priority: integer_t,
60 }
61
62 pub type thread_latency_qos_t = integer_t;
63
64 #[repr(C)]
65 #[derive(Clone, Copy, Debug)]
66 pub struct thread_latency_qos_policy {
67 thread_latency_qos_tier: thread_latency_qos_t,
68 }
69
70 pub type thread_throughput_qos_t = integer_t;
71
72 #[repr(C)]
73 #[derive(Clone, Copy, Debug)]
74 pub struct thread_throughput_qos_policy {
75 thread_throughput_qos_tier: thread_throughput_qos_t,
76 }
77
78 pub type thread_standard_policy_data_t = thread_standard_policy;
79 pub type thread_extended_policy_data_t = thread_extended_policy;
80 pub type thread_time_constraint_policy_data_t = thread_time_constraint_policy;
81 pub type thread_precedence_policy_data_t = thread_precedence_policy;
82 pub type thread_affinity_policy_data_t = thread_affinity_policy;
83 pub type thread_background_policy_data_t = thread_background_policy;
84 pub type thread_latency_qos_policy_data_t = thread_latency_qos_policy;
85 pub type thread_throughput_qos_policy_data_t = thread_throughput_qos_policy;
86
87 pub const THREAD_STANDARD_POLICY_COUNT: mach_msg_type_number_t = 0;
88 pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t =
89 (core::mem::size_of::<thread_extended_policy>() / core::mem::size_of::<integer_t>()) as _;
90 pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t =
91 (core::mem::size_of::<thread_time_constraint_policy>() / core::mem::size_of::<integer_t>())
92 as _;
93 pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t =
94 (core::mem::size_of::<thread_precedence_policy>() / core::mem::size_of::<integer_t>()) as _;
95 pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t =
96 (core::mem::size_of::<thread_affinity_policy>() / core::mem::size_of::<integer_t>()) as _;
97 pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t =
98 (core::mem::size_of::<thread_background_policy>() / core::mem::size_of::<integer_t>()) as _;
99 pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t =
100 (core::mem::size_of::<thread_latency_qos_policy>() / core::mem::size_of::<integer_t>()) as _;
101 pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t =
102 (core::mem::size_of::<thread_throughput_qos_policy>() / core::mem::size_of::<integer_t>()) as _;
103
104 extern "C" {
105 pub fn thread_policy_set(
106 thread: thread_t,
107 flavor: thread_policy_flavor_t,
108 policy_info: thread_policy_t,
109 count: mach_msg_type_number_t,
110 ) -> kern_return_t;
111 }
112
113 extern "C" {
114 pub fn thread_policy_get(
115 thread: thread_t,
116 flavor: thread_policy_flavor_t,
117 policy_info: thread_policy_t,
118 count: *mut mach_msg_type_number_t,
119 get_default: *mut boolean_t,
120 ) -> kern_return_t;
121 }