Skip to content

Commit 2ca368a

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 f4d6777 commit 2ca368a

4 files changed

Lines changed: 114 additions & 0 deletions

File tree

src/unix/bsd/apple/mod.rs

Lines changed: 96 additions & 0 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 = "0.2.187",
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 = "0.2.187",
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 = "0.2.187",
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,36 +4047,114 @@ const fn __DARWIN_ALIGN32(p: usize) -> usize {
40294047
(p + __DARWIN_ALIGNBYTES32) & !__DARWIN_ALIGNBYTES32
40304048
}
40314049

4050+
#[deprecated(
4051+
since = "0.2.187",
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+
)]
40324056
pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t =
40334057
(size_of::<thread_extended_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4058+
#[deprecated(
4059+
since = "0.2.187",
4060+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4061+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4062+
discussion."
4063+
)]
40344064
pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t =
40354065
(size_of::<thread_time_constraint_policy_data_t>() / size_of::<integer_t>())
40364066
as mach_msg_type_number_t;
4067+
#[deprecated(
4068+
since = "0.2.187",
4069+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4070+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4071+
discussion."
4072+
)]
40374073
pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t =
40384074
(size_of::<thread_precedence_policy_data_t>() / size_of::<integer_t>())
40394075
as mach_msg_type_number_t;
4076+
#[deprecated(
4077+
since = "0.2.187",
4078+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4079+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4080+
discussion."
4081+
)]
40404082
pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t =
40414083
(size_of::<thread_affinity_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4084+
#[deprecated(
4085+
since = "0.2.187",
4086+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4087+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4088+
discussion."
4089+
)]
40424090
pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t =
40434091
(size_of::<thread_background_policy_data_t>() / size_of::<integer_t>())
40444092
as mach_msg_type_number_t;
4093+
#[deprecated(
4094+
since = "0.2.187",
4095+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4096+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4097+
discussion."
4098+
)]
40454099
pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t =
40464100
(size_of::<thread_latency_qos_policy_data_t>() / size_of::<integer_t>())
40474101
as mach_msg_type_number_t;
4102+
#[deprecated(
4103+
since = "0.2.187",
4104+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4105+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4106+
discussion."
4107+
)]
40484108
pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t =
40494109
(size_of::<thread_throughput_qos_policy_data_t>() / size_of::<integer_t>())
40504110
as mach_msg_type_number_t;
4111+
#[deprecated(
4112+
since = "0.2.187",
4113+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4114+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4115+
discussion."
4116+
)]
40514117
pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t =
40524118
(size_of::<thread_basic_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4119+
#[deprecated(
4120+
since = "0.2.187",
4121+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4122+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4123+
discussion."
4124+
)]
40534125
pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t =
40544126
(size_of::<thread_identifier_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4127+
#[deprecated(
4128+
since = "0.2.187",
4129+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4130+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4131+
discussion."
4132+
)]
40554133
pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t =
40564134
(size_of::<thread_extended_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
40574135

4136+
#[deprecated(
4137+
since = "0.2.187",
4138+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4139+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4140+
discussion."
4141+
)]
40584142
pub const TASK_THREAD_TIMES_INFO_COUNT: u32 =
40594143
(size_of::<task_thread_times_info_data_t>() / size_of::<natural_t>()) as u32;
4144+
#[deprecated(
4145+
since = "0.2.187",
4146+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4147+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4148+
discussion."
4149+
)]
40604150
pub const MACH_TASK_BASIC_INFO_COUNT: u32 =
40614151
(size_of::<mach_task_basic_info_data_t>() / size_of::<natural_t>()) as u32;
4152+
#[deprecated(
4153+
since = "0.2.187",
4154+
note = "This constant, among others often used in C for the purposes of denoting the latest \
4155+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
4156+
discussion."
4157+
)]
40624158
pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t =
40634159
(size_of::<vm_statistics64_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
40644160

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 = "0.2.187",
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 = "0.2.187",
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 = "0.2.187",
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)