Skip to content

Commit 0debe88

Browse files
committed
refactor: deprecate *COUNT consts fitting #3131
These constants were already part of prior deprecation efforts in #3620, though this was not completed. Alongside the work and comments there, a few other constants have been researched and marked for deprecation. The accompnying PR contains sources to upstream kernels/libraries with reasoning as to why some constants were deprecated and others weren't.
1 parent 00183a7 commit 0debe88

4 files changed

Lines changed: 60 additions & 38 deletions

File tree

src/unix/bsd/apple/mod.rs

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3736,7 +3736,11 @@ pub const MNT_NOWAIT: c_int = 2;
37363736

37373737
// <mach/thread_policy.h>
37383738
pub const THREAD_STANDARD_POLICY: c_int = 1;
3739-
pub const THREAD_STANDARD_POLICY_COUNT: c_int = 0;
3739+
3740+
ct! {
3741+
pub const THREAD_STANDARD_POLICY_COUNT: c_int = 0;
3742+
}
3743+
37403744
pub const THREAD_EXTENDED_POLICY: c_int = 1;
37413745
pub const THREAD_TIME_CONSTRAINT_POLICY: c_int = 2;
37423746
pub const THREAD_PRECEDENCE_POLICY: c_int = 3;
@@ -3798,7 +3802,11 @@ pub const VM_PAGE_QUERY_PAGE_CS_NX: i32 = 0x400;
37983802

37993803
// mach/task_info.h
38003804
pub const TASK_THREAD_TIMES_INFO: u32 = 3;
3801-
pub const HOST_CPU_LOAD_INFO_COUNT: u32 = 4;
3805+
3806+
ct! {
3807+
pub const HOST_CPU_LOAD_INFO_COUNT: u32 = 4;
3808+
}
3809+
38023810
pub const MACH_TASK_BASIC_INFO: u32 = 20;
38033811

38043812
pub const MACH_PORT_NULL: i32 = 0;
@@ -3861,7 +3869,10 @@ pub const COPYFILE_STATE_DST_BSIZE: c_int = 12;
38613869
pub const COPYFILE_STATE_BSIZE: c_int = 13;
38623870

38633871
// <sys/attr.h>
3864-
pub const ATTR_BIT_MAP_COUNT: c_ushort = 5;
3872+
ct! {
3873+
pub const ATTR_BIT_MAP_COUNT: c_ushort = 5;
3874+
}
3875+
38653876
pub const FSOPT_NOFOLLOW: u32 = 0x1;
38663877
pub const FSOPT_NOFOLLOW_ANY: u32 = 0x800;
38673878
pub const FSOPT_REPORT_FULLSIZE: u32 = 0x4;
@@ -4032,38 +4043,40 @@ const fn __DARWIN_ALIGN32(p: usize) -> usize {
40324043
(p + __DARWIN_ALIGNBYTES32) & !__DARWIN_ALIGNBYTES32
40334044
}
40344045

4035-
pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t =
4036-
(size_of::<thread_extended_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4037-
pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t =
4038-
(size_of::<thread_time_constraint_policy_data_t>() / size_of::<integer_t>())
4039-
as mach_msg_type_number_t;
4040-
pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t =
4041-
(size_of::<thread_precedence_policy_data_t>() / size_of::<integer_t>())
4042-
as mach_msg_type_number_t;
4043-
pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t =
4044-
(size_of::<thread_affinity_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4045-
pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t =
4046-
(size_of::<thread_background_policy_data_t>() / size_of::<integer_t>())
4047-
as mach_msg_type_number_t;
4048-
pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t =
4049-
(size_of::<thread_latency_qos_policy_data_t>() / size_of::<integer_t>())
4050-
as mach_msg_type_number_t;
4051-
pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t =
4052-
(size_of::<thread_throughput_qos_policy_data_t>() / size_of::<integer_t>())
4053-
as mach_msg_type_number_t;
4054-
pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t =
4055-
(size_of::<thread_basic_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4056-
pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t =
4057-
(size_of::<thread_identifier_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4058-
pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t =
4059-
(size_of::<thread_extended_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4060-
4061-
pub const TASK_THREAD_TIMES_INFO_COUNT: u32 =
4062-
(size_of::<task_thread_times_info_data_t>() / size_of::<natural_t>()) as u32;
4063-
pub const MACH_TASK_BASIC_INFO_COUNT: u32 =
4064-
(size_of::<mach_task_basic_info_data_t>() / size_of::<natural_t>()) as u32;
4065-
pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t =
4066-
(size_of::<vm_statistics64_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4046+
ct! {
4047+
pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t =
4048+
(size_of::<thread_extended_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4049+
pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t =
4050+
(size_of::<thread_time_constraint_policy_data_t>() / size_of::<integer_t>())
4051+
as mach_msg_type_number_t;
4052+
pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t =
4053+
(size_of::<thread_precedence_policy_data_t>() / size_of::<integer_t>())
4054+
as mach_msg_type_number_t;
4055+
pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t =
4056+
(size_of::<thread_affinity_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4057+
pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t =
4058+
(size_of::<thread_background_policy_data_t>() / size_of::<integer_t>())
4059+
as mach_msg_type_number_t;
4060+
pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t =
4061+
(size_of::<thread_latency_qos_policy_data_t>() / size_of::<integer_t>())
4062+
as mach_msg_type_number_t;
4063+
pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t =
4064+
(size_of::<thread_throughput_qos_policy_data_t>() / size_of::<integer_t>())
4065+
as mach_msg_type_number_t;
4066+
pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t =
4067+
(size_of::<thread_basic_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4068+
pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t =
4069+
(size_of::<thread_identifier_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4070+
pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t =
4071+
(size_of::<thread_extended_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4072+
4073+
pub const TASK_THREAD_TIMES_INFO_COUNT: u32 =
4074+
(size_of::<task_thread_times_info_data_t>() / size_of::<natural_t>()) as u32;
4075+
pub const MACH_TASK_BASIC_INFO_COUNT: u32 =
4076+
(size_of::<mach_task_basic_info_data_t>() / size_of::<natural_t>()) as u32;
4077+
pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t =
4078+
(size_of::<vm_statistics64_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4079+
}
40674080

40684081
// bsd/net/if_mib.h
40694082
/// Non-interface-specific

src/unix/linux_like/android/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,10 @@ pub const NFNL_SUBSYS_CTNETLINK_TIMEOUT: c_int = 8;
15691569
pub const NFNL_SUBSYS_CTHELPER: c_int = 9;
15701570
pub const NFNL_SUBSYS_NFTABLES: c_int = 10;
15711571
pub const NFNL_SUBSYS_NFT_COMPAT: c_int = 11;
1572-
pub const NFNL_SUBSYS_COUNT: c_int = 12;
1572+
1573+
ct! {
1574+
pub const NFNL_SUBSYS_COUNT: c_int = 12;
1575+
}
15731576

15741577
pub const NFNL_MSG_BATCH_BEGIN: c_int = NLMSG_MIN_TYPE;
15751578
pub const NFNL_MSG_BATCH_END: c_int = NLMSG_MIN_TYPE + 1;

src/unix/linux_like/linux/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,10 @@ pub const NFNL_SUBSYS_CTHELPER: c_int = 9;
16781678
pub const NFNL_SUBSYS_NFTABLES: c_int = 10;
16791679
pub const NFNL_SUBSYS_NFT_COMPAT: c_int = 11;
16801680
pub const NFNL_SUBSYS_HOOK: c_int = 12;
1681-
pub const NFNL_SUBSYS_COUNT: c_int = 13;
1681+
1682+
ct! {
1683+
pub const NFNL_SUBSYS_COUNT: c_int = 13;
1684+
}
16821685

16831686
pub const NFNL_MSG_BATCH_BEGIN: c_int = crate::NLMSG_MIN_TYPE;
16841687
pub const NFNL_MSG_BATCH_END: c_int = crate::NLMSG_MIN_TYPE + 1;

src/unix/solarish/illumos.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ pub const PRIV_USER: c_uint = PRIV_DEBUG
186186
| PRIV_AWARE_RESET
187187
| PRIV_PFEXEC;
188188

189-
pub const LGRP_RSRC_COUNT: crate::lgrp_rsrc_t = 2;
189+
ct! {
190+
pub const LGRP_RSRC_COUNT: crate::lgrp_rsrc_t = 2;
191+
}
192+
190193
pub const LGRP_RSRC_CPU: crate::lgrp_rsrc_t = 0;
191194
pub const LGRP_RSRC_MEM: crate::lgrp_rsrc_t = 1;
192195

0 commit comments

Comments
 (0)