Skip to content

Commit c6d3aaa

Browse files
committed
refactor: deprecate *MAX constants fitting #3131
These constants, beyond their naming scehem, have been deemed to be a hindrance to the SemVer breakage guarantees that follows `libc`. This stems from the deprecation efforts in #3131. More information about background knowledge on the decision to deprecate each constant can be found in the accompanying PR.
1 parent 8372b50 commit c6d3aaa

28 files changed

Lines changed: 407 additions & 226 deletions

File tree

src/fuchsia/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,9 @@ pub const LOCK_UN: c_int = 8;
15921592
pub const SS_ONSTACK: c_int = 1;
15931593
pub const SS_DISABLE: c_int = 2;
15941594

1595-
pub const PATH_MAX: c_int = 4096;
1595+
ct! {
1596+
pub const PATH_MAX: c_int = 4096;
1597+
}
15961598

15971599
pub const FD_SETSIZE: c_int = 1024;
15981600

src/new/linux_uapi/linux/can/j1939.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,6 @@ s! {
5757
}
5858
}
5959

60-
pub const J1939_FILTER_MAX: c_int = 512;
60+
ct! {
61+
pub const J1939_FILTER_MAX: c_int = 512;
62+
}

src/new/linux_uapi/linux/can/raw.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
pub use crate::linux::can::*;
44

55
pub const SOL_CAN_RAW: c_int = SOL_CAN_BASE + CAN_RAW;
6-
pub const CAN_RAW_FILTER_MAX: c_int = 512;
6+
7+
ct! {
8+
pub const CAN_RAW_FILTER_MAX: c_int = 512;
9+
}
710

811
// FIXME(cleanup): use `c_enum!`, which needs to be adapted to allow omitting a type.
912
pub const CAN_RAW_FILTER: c_int = 1;

src/new/qurt/limits.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ pub const USHRT_MAX: c_ushort = 65535;
2727
// POSIX Limits
2828
pub const ARG_MAX: c_int = 4096;
2929
pub const CHILD_MAX: c_int = 25;
30-
pub const LINK_MAX: c_int = 8;
30+
31+
ct! {
32+
pub const LINK_MAX: c_int = 8;
33+
pub const NAME_MAX: c_int = 255;
34+
pub const PATH_MAX: c_int = 260;
35+
}
36+
3137
pub const MAX_CANON: c_int = 255;
3238
pub const MAX_INPUT: c_int = 255;
33-
pub const NAME_MAX: c_int = 255;
3439
pub const OPEN_MAX: c_int = 20;
35-
pub const PATH_MAX: c_int = 260;
3640
pub const PIPE_BUF: c_int = 512;
3741
pub const STREAM_MAX: c_int = 20;
3842
pub const TZNAME_MAX: c_int = 50;

src/new/qurt/signal.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ pub const SIG_SETMASK: c_int = 3;
5151
pub const POSIX_MSG: c_int = 7;
5252
pub const POSIX_NOTIF: c_int = 8;
5353
pub const SIGRTMIN: c_int = 10;
54-
pub const SIGRTMAX: c_int = 32;
54+
55+
ct! {
56+
pub const SIGRTMAX: c_int = 32;
57+
}
5558

5659
// Notification types (from QuRT signal.h)
5760
pub const SIGEV_NONE: c_int = 0;

src/unix/aix/mod.rs

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,11 @@ pub const RTAX_IFP: c_int = 4;
932932
pub const RTAX_IFA: c_int = 5;
933933
pub const RTAX_AUTHOR: c_int = 6;
934934
pub const RTAX_BRD: c_int = 7;
935-
pub const RTAX_MAX: c_int = 8;
935+
936+
ct! {
937+
pub const RTAX_MAX: c_int = 8;
938+
}
939+
936940
pub const RTF_UP: c_int = 0x1;
937941
pub const RTF_GATEWAY: c_int = 0x2;
938942
pub const RTF_HOST: c_int = 0x4;
@@ -1445,7 +1449,18 @@ pub const L_GETPROCINFO: c_int = 7;
14451449
pub const L_GETXINFO: c_int = 8;
14461450

14471451
// sys/limits.h
1448-
pub const PATH_MAX: c_int = 1023;
1452+
1453+
ct! {
1454+
pub const PATH_MAX: c_int = 1023;
1455+
pub const BC_BASE_MAX: c_int = 99;
1456+
pub const BC_DIM_MAX: c_int = 0x800;
1457+
pub const BC_SCALE_MAX: c_int = 99;
1458+
pub const BC_STRING_MAX: c_int = 0x800;
1459+
pub const CHARCLASS_NAME_MAX: c_int = 14;
1460+
pub const COLL_WEIGHTS_MAX: c_int = 4;
1461+
pub const EXPR_NEST_MAX: c_int = 32;
1462+
}
1463+
14491464
pub const PAGESIZE: c_int = 4096;
14501465
pub const IOV_MAX: c_int = 16;
14511466
pub const AIO_LISTIO_MAX: c_int = 4096;
@@ -1454,14 +1469,7 @@ pub const OPEN_MAX: c_int = 65534;
14541469
pub const MAX_INPUT: c_int = 512;
14551470
pub const MAX_CANON: c_int = 256;
14561471
pub const ARG_MAX: c_int = 1048576;
1457-
pub const BC_BASE_MAX: c_int = 99;
1458-
pub const BC_DIM_MAX: c_int = 0x800;
1459-
pub const BC_SCALE_MAX: c_int = 99;
1460-
pub const BC_STRING_MAX: c_int = 0x800;
1461-
pub const CHARCLASS_NAME_MAX: c_int = 14;
14621472
pub const CHILD_MAX: c_int = 128;
1463-
pub const COLL_WEIGHTS_MAX: c_int = 4;
1464-
pub const EXPR_NEST_MAX: c_int = 32;
14651473
pub const NZERO: c_int = 20;
14661474

14671475
// sys/lockf.h
@@ -1541,7 +1549,11 @@ pub const MAXPATHLEN: c_int = PATH_MAX + 1;
15411549
pub const MAXSYMLINKS: c_int = 20;
15421550
pub const MAXHOSTNAMELEN: c_int = 256;
15431551
pub const MAXUPRC: c_int = 128;
1544-
pub const NGROUPS_MAX: c_ulong = 2048;
1552+
1553+
ct! {
1554+
pub const NGROUPS_MAX: c_ulong = 2048;
1555+
}
1556+
15451557
pub const NGROUPS: c_ulong = NGROUPS_MAX;
15461558
pub const NOFILE: c_int = OPEN_MAX;
15471559

@@ -1739,7 +1751,11 @@ pub const SIGXCPU: c_int = 24;
17391751
pub const SIGXFSZ: c_int = 25;
17401752
pub const SIGTRAP: c_int = 5;
17411753
pub const SIGCLD: c_int = 20;
1742-
pub const SIGRTMAX: c_int = 57;
1754+
1755+
ct! {
1756+
pub const SIGRTMAX: c_int = 57;
1757+
}
1758+
17431759
pub const SIGRTMIN: c_int = 50;
17441760
pub const SI_USER: c_int = 0;
17451761
pub const SI_UNDEFINED: c_int = 8;
@@ -1817,7 +1833,11 @@ pub const AF_INET6: c_int = 24;
18171833
pub const AF_INTF: c_int = 20;
18181834
pub const AF_RIF: c_int = 21;
18191835
pub const AF_NDD: c_int = 23;
1820-
pub const AF_MAX: c_int = 30;
1836+
1837+
ct! {
1838+
pub const AF_MAX: c_int = 30;
1839+
}
1840+
18211841
pub const PF_UNSPEC: c_int = AF_UNSPEC;
18221842
pub const PF_UNIX: c_int = AF_UNIX;
18231843
pub const PF_INET: c_int = AF_INET;
@@ -1843,7 +1863,11 @@ pub const PF_RIF: c_int = AF_RIF;
18431863
pub const PF_INTF: c_int = AF_INTF;
18441864
pub const PF_NDD: c_int = AF_NDD;
18451865
pub const PF_INET6: c_int = AF_INET6;
1846-
pub const PF_MAX: c_int = AF_MAX;
1866+
1867+
ct! {
1868+
pub const PF_MAX: c_int = AF_MAX;
1869+
}
1870+
18471871
pub const SF_CLOSE: c_int = 1;
18481872
pub const SF_REUSE: c_int = 2;
18491873
pub const SF_DONT_CACHE: c_int = 4;

src/unix/bsd/apple/mod.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,10 @@ pub const CPU_STATE_USER: c_int = 0;
20142014
pub const CPU_STATE_SYSTEM: c_int = 1;
20152015
pub const CPU_STATE_IDLE: c_int = 2;
20162016
pub const CPU_STATE_NICE: c_int = 3;
2017-
pub const CPU_STATE_MAX: c_int = 4;
2017+
2018+
ct! {
2019+
pub const CPU_STATE_MAX: c_int = 4;
2020+
}
20182021

20192022
pub const PROCESSOR_BASIC_INFO: c_int = 1;
20202023
pub const PROCESSOR_CPU_LOAD_INFO: c_int = 2;
@@ -3396,14 +3399,18 @@ pub const HW_TARGET: c_int = 26;
33963399
pub const HW_PRODUCT: c_int = 27;
33973400
pub const HW_MAXID: c_int = 28;
33983401
pub const USER_CS_PATH: c_int = 1;
3399-
pub const USER_BC_BASE_MAX: c_int = 2;
3400-
pub const USER_BC_DIM_MAX: c_int = 3;
3401-
pub const USER_BC_SCALE_MAX: c_int = 4;
3402-
pub const USER_BC_STRING_MAX: c_int = 5;
3403-
pub const USER_COLL_WEIGHTS_MAX: c_int = 6;
3404-
pub const USER_EXPR_NEST_MAX: c_int = 7;
3405-
pub const USER_LINE_MAX: c_int = 8;
3406-
pub const USER_RE_DUP_MAX: c_int = 9;
3402+
3403+
ct! {
3404+
pub const USER_BC_BASE_MAX: c_int = 2;
3405+
pub const USER_BC_DIM_MAX: c_int = 3;
3406+
pub const USER_BC_SCALE_MAX: c_int = 4;
3407+
pub const USER_BC_STRING_MAX: c_int = 5;
3408+
pub const USER_COLL_WEIGHTS_MAX: c_int = 6;
3409+
pub const USER_EXPR_NEST_MAX: c_int = 7;
3410+
pub const USER_LINE_MAX: c_int = 8;
3411+
pub const USER_RE_DUP_MAX: c_int = 9;
3412+
}
3413+
34073414
pub const USER_POSIX2_VERSION: c_int = 10;
34083415
pub const USER_POSIX2_C_BIND: c_int = 11;
34093416
pub const USER_POSIX2_C_DEV: c_int = 12;
@@ -3447,10 +3454,6 @@ pub const SIGEV_THREAD: c_int = 3;
34473454
pub const AIO_CANCELED: c_int = 2;
34483455
pub const AIO_NOTCANCELED: c_int = 4;
34493456
pub const AIO_ALLDONE: c_int = 1;
3450-
#[deprecated(
3451-
since = "0.2.64",
3452-
note = "Can vary at runtime. Use sysconf(3) instead"
3453-
)]
34543457
pub const AIO_LISTIO_MAX: c_int = 16;
34553458
pub const LIO_NOP: c_int = 0;
34563459
pub const LIO_WRITE: c_int = 2;
@@ -3526,7 +3529,9 @@ pub const RTV_SSTHRESH: c_int = 0x20;
35263529
pub const RTV_RTT: c_int = 0x40;
35273530
pub const RTV_RTTVAR: c_int = 0x80;
35283531

3529-
pub const RTAX_MAX: c_int = 8;
3532+
ct! {
3533+
pub const RTAX_MAX: c_int = 8;
3534+
}
35303535

35313536
pub const KERN_PROCARGS2: c_int = 49;
35323537

src/unix/bsd/freebsdlike/dragonfly/mod.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -641,14 +641,18 @@ pub const HW_MACHINE_PLATFORM: c_int = 12;
641641
pub const HW_SENSORS: c_int = 13;
642642
pub const HW_MAXID: c_int = 14;
643643
pub const USER_CS_PATH: c_int = 1;
644-
pub const USER_BC_BASE_MAX: c_int = 2;
645-
pub const USER_BC_DIM_MAX: c_int = 3;
646-
pub const USER_BC_SCALE_MAX: c_int = 4;
647-
pub const USER_BC_STRING_MAX: c_int = 5;
648-
pub const USER_COLL_WEIGHTS_MAX: c_int = 6;
649-
pub const USER_EXPR_NEST_MAX: c_int = 7;
650-
pub const USER_LINE_MAX: c_int = 8;
651-
pub const USER_RE_DUP_MAX: c_int = 9;
644+
645+
ct! {
646+
pub const USER_BC_BASE_MAX: c_int = 2;
647+
pub const USER_BC_DIM_MAX: c_int = 3;
648+
pub const USER_BC_SCALE_MAX: c_int = 4;
649+
pub const USER_BC_STRING_MAX: c_int = 5;
650+
pub const USER_COLL_WEIGHTS_MAX: c_int = 6;
651+
pub const USER_EXPR_NEST_MAX: c_int = 7;
652+
pub const USER_LINE_MAX: c_int = 8;
653+
pub const USER_RE_DUP_MAX: c_int = 9;
654+
}
655+
652656
pub const USER_POSIX2_VERSION: c_int = 10;
653657
pub const USER_POSIX2_C_BIND: c_int = 11;
654658
pub const USER_POSIX2_C_DEV: c_int = 12;
@@ -1168,7 +1172,10 @@ pub const RTM_VERSION: c_int = 7;
11681172
pub const RTAX_MPLS1: c_int = 8;
11691173
pub const RTAX_MPLS2: c_int = 9;
11701174
pub const RTAX_MPLS3: c_int = 10;
1171-
pub const RTAX_MAX: c_int = 11;
1175+
1176+
ct! {
1177+
pub const RTAX_MAX: c_int = 11;
1178+
}
11721179

11731180
const fn _CMSG_ALIGN(n: usize) -> usize {
11741181
(n + (size_of::<c_long>() - 1)) & !(size_of::<c_long>() - 1)

0 commit comments

Comments
 (0)