Skip to content

Commit d36f780

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 2364caf commit d36f780

4 files changed

Lines changed: 150 additions & 32 deletions

File tree

src/unix/bsd/apple/mod.rs

Lines changed: 132 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3733,6 +3733,12 @@ pub const MNT_NOWAIT: c_int = 2;
37333733

37343734
// <mach/thread_policy.h>
37353735
pub const THREAD_STANDARD_POLICY: c_int = 1;
3736+
#[deprecated(
3737+
since = "1.0.0",
3738+
note = "This constant, among others often used in C for the purposes of denoting the latest \
3739+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
3740+
discussion."
3741+
)]
37363742
pub const THREAD_STANDARD_POLICY_COUNT: c_int = 0;
37373743
pub const THREAD_EXTENDED_POLICY: c_int = 1;
37383744
pub const THREAD_TIME_CONSTRAINT_POLICY: c_int = 2;
@@ -3795,6 +3801,12 @@ pub const VM_PAGE_QUERY_PAGE_CS_NX: i32 = 0x400;
37953801

37963802
// mach/task_info.h
37973803
pub const TASK_THREAD_TIMES_INFO: u32 = 3;
3804+
#[deprecated(
3805+
since = "1.0.0",
3806+
note = "This constant, among others often used in C for the purposes of denoting the latest \
3807+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
3808+
discussion."
3809+
)]
37983810
pub const HOST_CPU_LOAD_INFO_COUNT: u32 = 4;
37993811
pub const MACH_TASK_BASIC_INFO: u32 = 20;
38003812

@@ -3858,6 +3870,12 @@ pub const COPYFILE_STATE_DST_BSIZE: c_int = 12;
38583870
pub const COPYFILE_STATE_BSIZE: c_int = 13;
38593871

38603872
// <sys/attr.h>
3873+
#[deprecated(
3874+
since = "1.0.0",
3875+
note = "This constant, among others often used in C for the purposes of denoting the latest \
3876+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
3877+
discussion."
3878+
)]
38613879
pub const ATTR_BIT_MAP_COUNT: c_ushort = 5;
38623880
pub const FSOPT_NOFOLLOW: u32 = 0x1;
38633881
pub const FSOPT_NOFOLLOW_ANY: u32 = 0x800;
@@ -4029,38 +4047,120 @@ const fn __DARWIN_ALIGN32(p: usize) -> usize {
40294047
(p + __DARWIN_ALIGNBYTES32) & !__DARWIN_ALIGNBYTES32
40304048
}
40314049

4032-
pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t =
4033-
(size_of::<thread_extended_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4034-
pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t =
4035-
(size_of::<thread_time_constraint_policy_data_t>() / size_of::<integer_t>())
4036-
as mach_msg_type_number_t;
4037-
pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t =
4038-
(size_of::<thread_precedence_policy_data_t>() / size_of::<integer_t>())
4039-
as mach_msg_type_number_t;
4040-
pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t =
4041-
(size_of::<thread_affinity_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4042-
pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t =
4043-
(size_of::<thread_background_policy_data_t>() / size_of::<integer_t>())
4044-
as mach_msg_type_number_t;
4045-
pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t =
4046-
(size_of::<thread_latency_qos_policy_data_t>() / size_of::<integer_t>())
4047-
as mach_msg_type_number_t;
4048-
pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t =
4049-
(size_of::<thread_throughput_qos_policy_data_t>() / size_of::<integer_t>())
4050-
as mach_msg_type_number_t;
4051-
pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t =
4052-
(size_of::<thread_basic_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4053-
pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t =
4054-
(size_of::<thread_identifier_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4055-
pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t =
4056-
(size_of::<thread_extended_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4057-
4058-
pub const TASK_THREAD_TIMES_INFO_COUNT: u32 =
4059-
(size_of::<task_thread_times_info_data_t>() / size_of::<natural_t>()) as u32;
4060-
pub const MACH_TASK_BASIC_INFO_COUNT: u32 =
4061-
(size_of::<mach_task_basic_info_data_t>() / size_of::<natural_t>()) as u32;
4062-
pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t =
4063-
(size_of::<vm_statistics64_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4050+
#[deprecated(
4051+
since = "1.0.0",
4052+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4053+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4054+
discussion."
4055+
)]
4056+
pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t = (size_of::<
4057+
thread_extended_policy_data_t,
4058+
>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4059+
#[deprecated(
4060+
since = "1.0.0",
4061+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4062+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4063+
discussion."
4064+
)]
4065+
pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t = (size_of::<
4066+
thread_time_constraint_policy_data_t,
4067+
>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4068+
#[deprecated(
4069+
since = "1.0.0",
4070+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4071+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4072+
discussion."
4073+
)]
4074+
pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t = (size_of::<
4075+
thread_precedence_policy_data_t,
4076+
>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4077+
#[deprecated(
4078+
since = "1.0.0",
4079+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4080+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4081+
discussion."
4082+
)]
4083+
pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t = (size_of::<
4084+
thread_affinity_policy_data_t,
4085+
>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4086+
#[deprecated(
4087+
since = "1.0.0",
4088+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4089+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4090+
discussion."
4091+
)]
4092+
pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t = (size_of::<
4093+
thread_background_policy_data_t,
4094+
>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4095+
#[deprecated(
4096+
since = "1.0.0",
4097+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4098+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4099+
discussion."
4100+
)]
4101+
pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t = (size_of::<
4102+
thread_latency_qos_policy_data_t,
4103+
>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4104+
#[deprecated(
4105+
since = "1.0.0",
4106+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4107+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4108+
discussion."
4109+
)]
4110+
pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t = (size_of::<
4111+
thread_throughput_qos_policy_data_t,
4112+
>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4113+
#[deprecated(
4114+
since = "1.0.0",
4115+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4116+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4117+
discussion."
4118+
)]
4119+
pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t = (size_of::<thread_basic_info_data_t>()
4120+
/ size_of::<integer_t>()) as mach_msg_type_number_t;
4121+
#[deprecated(
4122+
since = "1.0.0",
4123+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4124+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4125+
discussion."
4126+
)]
4127+
pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t = (size_of::<
4128+
thread_identifier_info_data_t,
4129+
>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4130+
#[deprecated(
4131+
since = "1.0.0",
4132+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4133+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4134+
discussion."
4135+
)]
4136+
pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t = (size_of::<
4137+
thread_extended_info_data_t,
4138+
>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4139+
4140+
#[deprecated(
4141+
since = "1.0.0",
4142+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4143+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4144+
discussion."
4145+
)]
4146+
pub const TASK_THREAD_TIMES_INFO_COUNT: u32 = (size_of::<task_thread_times_info_data_t>()
4147+
/ size_of::<natural_t>()) as u32;
4148+
#[deprecated(
4149+
since = "1.0.0",
4150+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4151+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4152+
discussion."
4153+
)]
4154+
pub const MACH_TASK_BASIC_INFO_COUNT: u32 = (size_of::<mach_task_basic_info_data_t>()
4155+
/ size_of::<natural_t>()) as u32;
4156+
#[deprecated(
4157+
since = "1.0.0",
4158+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4159+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4160+
discussion."
4161+
)]
4162+
pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t = (size_of::<vm_statistics64_data_t>()
4163+
/ size_of::<integer_t>()) as mach_msg_type_number_t;
40644164

40654165
// bsd/net/if_mib.h
40664166
/// Non-interface-specific

src/unix/linux_like/android/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,12 @@ 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+
#[deprecated(
1573+
since = "1.0.0",
1574+
note = "This constant, among others often used in C for the purposes of denoting the latest \
1575+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
1576+
discussion."
1577+
)]
15721578
pub const NFNL_SUBSYS_COUNT: c_int = 12;
15731579

15741580
pub const NFNL_MSG_BATCH_BEGIN: c_int = NLMSG_MIN_TYPE;

src/unix/linux_like/linux/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,6 +1899,12 @@ pub const NFNL_SUBSYS_CTHELPER: c_int = 9;
18991899
pub const NFNL_SUBSYS_NFTABLES: c_int = 10;
19001900
pub const NFNL_SUBSYS_NFT_COMPAT: c_int = 11;
19011901
pub const NFNL_SUBSYS_HOOK: c_int = 12;
1902+
#[deprecated(
1903+
since = "1.0.0",
1904+
note = "This constant, among others often used in C for the purposes of denoting the latest \
1905+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
1906+
discussion."
1907+
)]
19021908
pub const NFNL_SUBSYS_COUNT: c_int = 13;
19031909

19041910
pub const NFNL_MSG_BATCH_BEGIN: c_int = crate::NLMSG_MIN_TYPE;

src/unix/solarish/illumos.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ pub const PRIV_USER: c_uint = PRIV_DEBUG
186186
| PRIV_AWARE_RESET
187187
| PRIV_PFEXEC;
188188

189+
#[deprecated(
190+
since = "1.0.0",
191+
note = "This constant, among others often used in C for the purposes of denoting the latest \
192+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
193+
discussion."
194+
)]
189195
pub const LGRP_RSRC_COUNT: crate::lgrp_rsrc_t = 2;
190196
pub const LGRP_RSRC_CPU: crate::lgrp_rsrc_t = 0;
191197
pub const LGRP_RSRC_MEM: crate::lgrp_rsrc_t = 1;

0 commit comments

Comments
 (0)