Skip to content

Commit cb9c814

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

29 files changed

Lines changed: 998 additions & 8 deletions

File tree

src/fuchsia/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,12 @@ 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+
#[deprecated(
1596+
since = "0.2.187",
1597+
note = "This constant, among others often used in C for the purposes of denoting the latest \
1598+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
1599+
discussion."
1600+
)]
15951601
pub const PATH_MAX: c_int = 4096;
15961602

15971603
pub const FD_SETSIZE: c_int = 1024;

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

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

60+
#[deprecated(
61+
since = "0.2.187",
62+
note = "This constant, among others often used in C for the purposes of denoting the latest \
63+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
64+
discussion."
65+
)]
6066
pub const J1939_FILTER_MAX: c_int = 512;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
pub use crate::linux::can::*;
44

55
pub const SOL_CAN_RAW: c_int = SOL_CAN_BASE + CAN_RAW;
6+
#[deprecated(
7+
since = "0.2.187",
8+
note = "This constant, among others often used in C for the purposes of denoting the latest \
9+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
10+
discussion."
11+
)]
612
pub const CAN_RAW_FILTER_MAX: c_int = 512;
713

814
// FIXME(cleanup): use `c_enum!`, which needs to be adapted to allow omitting a type.

src/new/qurt/limits.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,29 @@ 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+
#[deprecated(
31+
since = "0.2.187",
32+
note = "This constant, among others often used in C for the purposes of denoting the latest \
33+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
34+
discussion."
35+
)]
3036
pub const LINK_MAX: c_int = 8;
3137
pub const MAX_CANON: c_int = 255;
3238
pub const MAX_INPUT: c_int = 255;
39+
#[deprecated(
40+
since = "0.2.187",
41+
note = "This constant, among others often used in C for the purposes of denoting the latest \
42+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
43+
discussion."
44+
)]
3345
pub const NAME_MAX: c_int = 255;
3446
pub const OPEN_MAX: c_int = 20;
47+
#[deprecated(
48+
since = "0.2.187",
49+
note = "This constant, among others often used in C for the purposes of denoting the latest \
50+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
51+
discussion."
52+
)]
3553
pub const PATH_MAX: c_int = 260;
3654
pub const PIPE_BUF: c_int = 512;
3755
pub const STREAM_MAX: c_int = 20;

src/new/qurt/signal.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ pub const SIG_SETMASK: c_int = 3;
5050
pub const POSIX_MSG: c_int = 7;
5151
pub const POSIX_NOTIF: c_int = 8;
5252
pub const SIGRTMIN: c_int = 10;
53+
#[deprecated(
54+
since = "0.2.187",
55+
note = "This constant, among others often used in C for the purposes of denoting the latest \
56+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
57+
discussion."
58+
)]
5359
pub const SIGRTMAX: c_int = 32;
5460

5561
// Notification types (from QuRT signal.h)

src/unix/aix/mod.rs

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,12 @@ 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+
#[deprecated(
936+
since = "0.2.187",
937+
note = "This constant, among others often used in C for the purposes of denoting the latest \
938+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
939+
discussion."
940+
)]
935941
pub const RTAX_MAX: c_int = 8;
936942
pub const RTF_UP: c_int = 0x1;
937943
pub const RTF_GATEWAY: c_int = 0x2;
@@ -1445,6 +1451,12 @@ pub const L_GETPROCINFO: c_int = 7;
14451451
pub const L_GETXINFO: c_int = 8;
14461452

14471453
// sys/limits.h
1454+
#[deprecated(
1455+
since = "0.2.187",
1456+
note = "This constant, among others often used in C for the purposes of denoting the latest \
1457+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
1458+
discussion."
1459+
)]
14481460
pub const PATH_MAX: c_int = 1023;
14491461
pub const PAGESIZE: c_int = 4096;
14501462
pub const IOV_MAX: c_int = 16;
@@ -1454,13 +1466,55 @@ pub const OPEN_MAX: c_int = 65534;
14541466
pub const MAX_INPUT: c_int = 512;
14551467
pub const MAX_CANON: c_int = 256;
14561468
pub const ARG_MAX: c_int = 1048576;
1469+
#[deprecated(
1470+
since = "0.2.187",
1471+
note = "This constant, among others often used in C for the purposes of denoting the latest \
1472+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
1473+
discussion."
1474+
)]
14571475
pub const BC_BASE_MAX: c_int = 99;
1476+
#[deprecated(
1477+
since = "0.2.187",
1478+
note = "This constant, among others often used in C for the purposes of denoting the latest \
1479+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
1480+
discussion."
1481+
)]
14581482
pub const BC_DIM_MAX: c_int = 0x800;
1483+
#[deprecated(
1484+
since = "0.2.187",
1485+
note = "This constant, among others often used in C for the purposes of denoting the latest \
1486+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
1487+
discussion."
1488+
)]
14591489
pub const BC_SCALE_MAX: c_int = 99;
1490+
#[deprecated(
1491+
since = "0.2.187",
1492+
note = "This constant, among others often used in C for the purposes of denoting the latest \
1493+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
1494+
discussion."
1495+
)]
14601496
pub const BC_STRING_MAX: c_int = 0x800;
1497+
#[deprecated(
1498+
since = "0.2.187",
1499+
note = "This constant, among others often used in C for the purposes of denoting the latest \
1500+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
1501+
discussion."
1502+
)]
14611503
pub const CHARCLASS_NAME_MAX: c_int = 14;
14621504
pub const CHILD_MAX: c_int = 128;
1505+
#[deprecated(
1506+
since = "0.2.187",
1507+
note = "This constant, among others often used in C for the purposes of denoting the latest \
1508+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
1509+
discussion."
1510+
)]
14631511
pub const COLL_WEIGHTS_MAX: c_int = 4;
1512+
#[deprecated(
1513+
since = "0.2.187",
1514+
note = "This constant, among others often used in C for the purposes of denoting the latest \
1515+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
1516+
discussion."
1517+
)]
14641518
pub const EXPR_NEST_MAX: c_int = 32;
14651519
pub const NZERO: c_int = 20;
14661520

@@ -1537,11 +1591,25 @@ pub const SIGSTKSZ: size_t = 4096;
15371591
pub const MINSIGSTKSZ: size_t = 1200;
15381592

15391593
// sys/params.h
1594+
// FIXME(msrv): when we bump past the MSRV where `expect` and the `reason`
1595+
// parameter to that attribute got stabilized, use that to justfiy that this is
1596+
// not meant to be deprecated, but the value it relies on should be deprecated.
1597+
#[allow(deprecated)]
15401598
pub const MAXPATHLEN: c_int = PATH_MAX + 1;
15411599
pub const MAXSYMLINKS: c_int = 20;
15421600
pub const MAXHOSTNAMELEN: c_int = 256;
15431601
pub const MAXUPRC: c_int = 128;
1602+
#[deprecated(
1603+
since = "0.2.187",
1604+
note = "This constant, among others often used in C for the purposes of denoting the latest \
1605+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
1606+
discussion."
1607+
)]
15441608
pub const NGROUPS_MAX: c_ulong = 2048;
1609+
// FIXME(msrv): when we bump past the MSRV where `expect` and the `reason`
1610+
// parameter to that attribute got stabilized, use that to justfiy that this is
1611+
// not meant to be deprecated, but the value it relies on should be deprecated.
1612+
#[allow(deprecated)]
15451613
pub const NGROUPS: c_ulong = NGROUPS_MAX;
15461614
pub const NOFILE: c_int = OPEN_MAX;
15471615

@@ -1739,6 +1807,12 @@ pub const SIGXCPU: c_int = 24;
17391807
pub const SIGXFSZ: c_int = 25;
17401808
pub const SIGTRAP: c_int = 5;
17411809
pub const SIGCLD: c_int = 20;
1810+
#[deprecated(
1811+
since = "0.2.187",
1812+
note = "This constant, among others often used in C for the purposes of denoting the latest \
1813+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
1814+
discussion."
1815+
)]
17421816
pub const SIGRTMAX: c_int = 57;
17431817
pub const SIGRTMIN: c_int = 50;
17441818
pub const SI_USER: c_int = 0;
@@ -1817,6 +1891,12 @@ pub const AF_INET6: c_int = 24;
18171891
pub const AF_INTF: c_int = 20;
18181892
pub const AF_RIF: c_int = 21;
18191893
pub const AF_NDD: c_int = 23;
1894+
#[deprecated(
1895+
since = "0.2.187",
1896+
note = "This constant, among others often used in C for the purposes of denoting the latest \
1897+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
1898+
discussion."
1899+
)]
18201900
pub const AF_MAX: c_int = 30;
18211901
pub const PF_UNSPEC: c_int = AF_UNSPEC;
18221902
pub const PF_UNIX: c_int = AF_UNIX;
@@ -1843,6 +1923,16 @@ pub const PF_RIF: c_int = AF_RIF;
18431923
pub const PF_INTF: c_int = AF_INTF;
18441924
pub const PF_NDD: c_int = AF_NDD;
18451925
pub const PF_INET6: c_int = AF_INET6;
1926+
// FIXME(msrv): when we bump past the MSRV where `expect` and the `reason`
1927+
// parameter to that attribute got stabilized, use that to justfiy that this is
1928+
// both meant to be deprecated, and is defined in terms of a deprecated value.
1929+
#[allow(deprecated)]
1930+
#[deprecated(
1931+
since = "0.2.187",
1932+
note = "This constant, among others often used in C for the purposes of denoting the latest \
1933+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
1934+
discussion."
1935+
)]
18461936
pub const PF_MAX: c_int = AF_MAX;
18471937
pub const SF_CLOSE: c_int = 1;
18481938
pub const SF_REUSE: c_int = 2;

src/unix/bsd/apple/mod.rs

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,6 +2014,12 @@ 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+
#[deprecated(
2018+
since = "0.2.187",
2019+
note = "This constant, among others often used in C for the purposes of denoting the latest \
2020+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
2021+
discussion."
2022+
)]
20172023
pub const CPU_STATE_MAX: c_int = 4;
20182024

20192025
pub const PROCESSOR_BASIC_INFO: c_int = 1;
@@ -3396,13 +3402,61 @@ pub const HW_TARGET: c_int = 26;
33963402
pub const HW_PRODUCT: c_int = 27;
33973403
pub const HW_MAXID: c_int = 28;
33983404
pub const USER_CS_PATH: c_int = 1;
3405+
#[deprecated(
3406+
since = "0.2.187",
3407+
note = "This constant, among others often used in C for the purposes of denoting the latest \
3408+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
3409+
discussion."
3410+
)]
33993411
pub const USER_BC_BASE_MAX: c_int = 2;
3412+
#[deprecated(
3413+
since = "0.2.187",
3414+
note = "This constant, among others often used in C for the purposes of denoting the latest \
3415+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
3416+
discussion."
3417+
)]
34003418
pub const USER_BC_DIM_MAX: c_int = 3;
3419+
#[deprecated(
3420+
since = "0.2.187",
3421+
note = "This constant, among others often used in C for the purposes of denoting the latest \
3422+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
3423+
discussion."
3424+
)]
34013425
pub const USER_BC_SCALE_MAX: c_int = 4;
3426+
#[deprecated(
3427+
since = "0.2.187",
3428+
note = "This constant, among others often used in C for the purposes of denoting the latest \
3429+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
3430+
discussion."
3431+
)]
34023432
pub const USER_BC_STRING_MAX: c_int = 5;
3433+
#[deprecated(
3434+
since = "0.2.187",
3435+
note = "This constant, among others often used in C for the purposes of denoting the latest \
3436+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
3437+
discussion."
3438+
)]
34033439
pub const USER_COLL_WEIGHTS_MAX: c_int = 6;
3440+
#[deprecated(
3441+
since = "0.2.187",
3442+
note = "This constant, among others often used in C for the purposes of denoting the latest \
3443+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
3444+
discussion."
3445+
)]
34043446
pub const USER_EXPR_NEST_MAX: c_int = 7;
3447+
#[deprecated(
3448+
since = "0.2.187",
3449+
note = "This constant, among others often used in C for the purposes of denoting the latest \
3450+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
3451+
discussion."
3452+
)]
34053453
pub const USER_LINE_MAX: c_int = 8;
3454+
#[deprecated(
3455+
since = "0.2.187",
3456+
note = "This constant, among others often used in C for the purposes of denoting the latest \
3457+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
3458+
discussion."
3459+
)]
34063460
pub const USER_RE_DUP_MAX: c_int = 9;
34073461
pub const USER_POSIX2_VERSION: c_int = 10;
34083462
pub const USER_POSIX2_C_BIND: c_int = 11;
@@ -3447,10 +3501,6 @@ pub const SIGEV_THREAD: c_int = 3;
34473501
pub const AIO_CANCELED: c_int = 2;
34483502
pub const AIO_NOTCANCELED: c_int = 4;
34493503
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-
)]
34543504
pub const AIO_LISTIO_MAX: c_int = 16;
34553505
pub const LIO_NOP: c_int = 0;
34563506
pub const LIO_WRITE: c_int = 2;
@@ -3526,6 +3576,12 @@ pub const RTV_SSTHRESH: c_int = 0x20;
35263576
pub const RTV_RTT: c_int = 0x40;
35273577
pub const RTV_RTTVAR: c_int = 0x80;
35283578

3579+
#[deprecated(
3580+
since = "0.2.187",
3581+
note = "This constant, among others often used in C for the purposes of denoting the latest \
3582+
value or limit in a set of constants, has been deprecated. See #3131 for details and \
3583+
discussion."
3584+
)]
35293585
pub const RTAX_MAX: c_int = 8;
35303586

35313587
pub const KERN_PROCARGS2: c_int = 49;

0 commit comments

Comments
 (0)