Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/fuchsia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,9 @@ pub const LOCK_UN: c_int = 8;
pub const SS_ONSTACK: c_int = 1;
pub const SS_DISABLE: c_int = 2;

pub const PATH_MAX: c_int = 4096;
ct! {
pub const PATH_MAX: c_int = 4096;
}

pub const FD_SETSIZE: c_int = 1024;

Expand Down
15 changes: 15 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,21 @@ macro_rules! offset_of {
}};
}

/// Defines constants with an accompanying doc comment pointing out their
/// instability, and links to the crate documentation for usage guidelines.
macro_rules! ct {
($($it:item)+) => {
$(
/// This constant, among others often used in C for the purposes of denoting the
/// latest value or limit in a set of constants, is likely to change upstream.
/// For correct usage, see the [crate-level documentation][docs].
///
/// [docs]: index.html#usage-recommendations
$it
)+
};
}

#[cfg(test)]
mod tests {
use core::any::TypeId;
Expand Down
4 changes: 3 additions & 1 deletion src/new/linux_uapi/linux/can/j1939.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ s! {
}
}

pub const J1939_FILTER_MAX: c_int = 512;
ct! {
pub const J1939_FILTER_MAX: c_int = 512;
}
5 changes: 4 additions & 1 deletion src/new/linux_uapi/linux/can/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
pub use crate::linux::can::*;

pub const SOL_CAN_RAW: c_int = SOL_CAN_BASE + CAN_RAW;
pub const CAN_RAW_FILTER_MAX: c_int = 512;

ct! {
pub const CAN_RAW_FILTER_MAX: c_int = 512;
}

// FIXME(cleanup): use `c_enum!`, which needs to be adapted to allow omitting a type.
pub const CAN_RAW_FILTER: c_int = 1;
Expand Down
10 changes: 7 additions & 3 deletions src/new/qurt/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ pub const USHRT_MAX: c_ushort = 65535;
// POSIX Limits
pub const ARG_MAX: c_int = 4096;
pub const CHILD_MAX: c_int = 25;
pub const LINK_MAX: c_int = 8;

ct! {
pub const LINK_MAX: c_int = 8;
pub const NAME_MAX: c_int = 255;
pub const PATH_MAX: c_int = 260;
}

pub const MAX_CANON: c_int = 255;
pub const MAX_INPUT: c_int = 255;
pub const NAME_MAX: c_int = 255;
pub const OPEN_MAX: c_int = 20;
pub const PATH_MAX: c_int = 260;
pub const PIPE_BUF: c_int = 512;
pub const STREAM_MAX: c_int = 20;
pub const TZNAME_MAX: c_int = 50;
Expand Down
5 changes: 4 additions & 1 deletion src/new/qurt/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ pub const SIG_SETMASK: c_int = 3;
pub const POSIX_MSG: c_int = 7;
pub const POSIX_NOTIF: c_int = 8;
pub const SIGRTMIN: c_int = 10;
pub const SIGRTMAX: c_int = 32;

ct! {
pub const SIGRTMAX: c_int = 32;
}

// Notification types (from QuRT signal.h)
pub const SIGEV_NONE: c_int = 0;
Expand Down
50 changes: 37 additions & 13 deletions src/unix/aix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,11 @@ pub const RTAX_IFP: c_int = 4;
pub const RTAX_IFA: c_int = 5;
pub const RTAX_AUTHOR: c_int = 6;
pub const RTAX_BRD: c_int = 7;
pub const RTAX_MAX: c_int = 8;

ct! {
pub const RTAX_MAX: c_int = 8;
}

pub const RTF_UP: c_int = 0x1;
pub const RTF_GATEWAY: c_int = 0x2;
pub const RTF_HOST: c_int = 0x4;
Expand Down Expand Up @@ -1445,7 +1449,18 @@ pub const L_GETPROCINFO: c_int = 7;
pub const L_GETXINFO: c_int = 8;

// sys/limits.h
pub const PATH_MAX: c_int = 1023;

ct! {
pub const PATH_MAX: c_int = 1023;
pub const BC_BASE_MAX: c_int = 99;
pub const BC_DIM_MAX: c_int = 0x800;
pub const BC_SCALE_MAX: c_int = 99;
pub const BC_STRING_MAX: c_int = 0x800;
pub const CHARCLASS_NAME_MAX: c_int = 14;
pub const COLL_WEIGHTS_MAX: c_int = 4;
pub const EXPR_NEST_MAX: c_int = 32;
}

pub const PAGESIZE: c_int = 4096;
pub const IOV_MAX: c_int = 16;
pub const AIO_LISTIO_MAX: c_int = 4096;
Expand All @@ -1454,14 +1469,7 @@ pub const OPEN_MAX: c_int = 65534;
pub const MAX_INPUT: c_int = 512;
pub const MAX_CANON: c_int = 256;
pub const ARG_MAX: c_int = 1048576;
pub const BC_BASE_MAX: c_int = 99;
pub const BC_DIM_MAX: c_int = 0x800;
pub const BC_SCALE_MAX: c_int = 99;
pub const BC_STRING_MAX: c_int = 0x800;
pub const CHARCLASS_NAME_MAX: c_int = 14;
pub const CHILD_MAX: c_int = 128;
pub const COLL_WEIGHTS_MAX: c_int = 4;
pub const EXPR_NEST_MAX: c_int = 32;
pub const NZERO: c_int = 20;

// sys/lockf.h
Expand Down Expand Up @@ -1541,7 +1549,11 @@ pub const MAXPATHLEN: c_int = PATH_MAX + 1;
pub const MAXSYMLINKS: c_int = 20;
pub const MAXHOSTNAMELEN: c_int = 256;
pub const MAXUPRC: c_int = 128;
pub const NGROUPS_MAX: c_ulong = 2048;

ct! {
pub const NGROUPS_MAX: c_ulong = 2048;
}

pub const NGROUPS: c_ulong = NGROUPS_MAX;
pub const NOFILE: c_int = OPEN_MAX;

Expand Down Expand Up @@ -1739,7 +1751,11 @@ pub const SIGXCPU: c_int = 24;
pub const SIGXFSZ: c_int = 25;
pub const SIGTRAP: c_int = 5;
pub const SIGCLD: c_int = 20;
pub const SIGRTMAX: c_int = 57;

ct! {
pub const SIGRTMAX: c_int = 57;
}

pub const SIGRTMIN: c_int = 50;
pub const SI_USER: c_int = 0;
pub const SI_UNDEFINED: c_int = 8;
Expand Down Expand Up @@ -1817,7 +1833,11 @@ pub const AF_INET6: c_int = 24;
pub const AF_INTF: c_int = 20;
pub const AF_RIF: c_int = 21;
pub const AF_NDD: c_int = 23;
pub const AF_MAX: c_int = 30;

ct! {
pub const AF_MAX: c_int = 30;
}

pub const PF_UNSPEC: c_int = AF_UNSPEC;
pub const PF_UNIX: c_int = AF_UNIX;
pub const PF_INET: c_int = AF_INET;
Expand All @@ -1843,7 +1863,11 @@ pub const PF_RIF: c_int = AF_RIF;
pub const PF_INTF: c_int = AF_INTF;
pub const PF_NDD: c_int = AF_NDD;
pub const PF_INET6: c_int = AF_INET6;
pub const PF_MAX: c_int = AF_MAX;

ct! {
pub const PF_MAX: c_int = AF_MAX;
}

pub const SF_CLOSE: c_int = 1;
pub const SF_REUSE: c_int = 2;
pub const SF_DONT_CACHE: c_int = 4;
Expand Down
33 changes: 19 additions & 14 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,10 @@ pub const CPU_STATE_USER: c_int = 0;
pub const CPU_STATE_SYSTEM: c_int = 1;
pub const CPU_STATE_IDLE: c_int = 2;
pub const CPU_STATE_NICE: c_int = 3;
pub const CPU_STATE_MAX: c_int = 4;

ct! {
pub const CPU_STATE_MAX: c_int = 4;
}

pub const PROCESSOR_BASIC_INFO: c_int = 1;
pub const PROCESSOR_CPU_LOAD_INFO: c_int = 2;
Expand Down Expand Up @@ -3396,14 +3399,18 @@ pub const HW_TARGET: c_int = 26;
pub const HW_PRODUCT: c_int = 27;
pub const HW_MAXID: c_int = 28;
pub const USER_CS_PATH: c_int = 1;
pub const USER_BC_BASE_MAX: c_int = 2;
pub const USER_BC_DIM_MAX: c_int = 3;
pub const USER_BC_SCALE_MAX: c_int = 4;
pub const USER_BC_STRING_MAX: c_int = 5;
pub const USER_COLL_WEIGHTS_MAX: c_int = 6;
pub const USER_EXPR_NEST_MAX: c_int = 7;
pub const USER_LINE_MAX: c_int = 8;
pub const USER_RE_DUP_MAX: c_int = 9;

ct! {
pub const USER_BC_BASE_MAX: c_int = 2;
pub const USER_BC_DIM_MAX: c_int = 3;
pub const USER_BC_SCALE_MAX: c_int = 4;
pub const USER_BC_STRING_MAX: c_int = 5;
pub const USER_COLL_WEIGHTS_MAX: c_int = 6;
pub const USER_EXPR_NEST_MAX: c_int = 7;
pub const USER_LINE_MAX: c_int = 8;
pub const USER_RE_DUP_MAX: c_int = 9;
}

pub const USER_POSIX2_VERSION: c_int = 10;
pub const USER_POSIX2_C_BIND: c_int = 11;
pub const USER_POSIX2_C_DEV: c_int = 12;
Expand Down Expand Up @@ -3447,10 +3454,6 @@ pub const SIGEV_THREAD: c_int = 3;
pub const AIO_CANCELED: c_int = 2;
pub const AIO_NOTCANCELED: c_int = 4;
pub const AIO_ALLDONE: c_int = 1;
#[deprecated(
since = "0.2.64",
note = "Can vary at runtime. Use sysconf(3) instead"
)]
pub const AIO_LISTIO_MAX: c_int = 16;
pub const LIO_NOP: c_int = 0;
pub const LIO_WRITE: c_int = 2;
Expand Down Expand Up @@ -3526,7 +3529,9 @@ pub const RTV_SSTHRESH: c_int = 0x20;
pub const RTV_RTT: c_int = 0x40;
pub const RTV_RTTVAR: c_int = 0x80;

pub const RTAX_MAX: c_int = 8;
ct! {
pub const RTAX_MAX: c_int = 8;
}

pub const KERN_PROCARGS2: c_int = 49;

Expand Down
25 changes: 16 additions & 9 deletions src/unix/bsd/freebsdlike/dragonfly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,14 +641,18 @@ pub const HW_MACHINE_PLATFORM: c_int = 12;
pub const HW_SENSORS: c_int = 13;
pub const HW_MAXID: c_int = 14;
pub const USER_CS_PATH: c_int = 1;
pub const USER_BC_BASE_MAX: c_int = 2;
pub const USER_BC_DIM_MAX: c_int = 3;
pub const USER_BC_SCALE_MAX: c_int = 4;
pub const USER_BC_STRING_MAX: c_int = 5;
pub const USER_COLL_WEIGHTS_MAX: c_int = 6;
pub const USER_EXPR_NEST_MAX: c_int = 7;
pub const USER_LINE_MAX: c_int = 8;
pub const USER_RE_DUP_MAX: c_int = 9;

ct! {
pub const USER_BC_BASE_MAX: c_int = 2;
pub const USER_BC_DIM_MAX: c_int = 3;
pub const USER_BC_SCALE_MAX: c_int = 4;
pub const USER_BC_STRING_MAX: c_int = 5;
pub const USER_COLL_WEIGHTS_MAX: c_int = 6;
pub const USER_EXPR_NEST_MAX: c_int = 7;
pub const USER_LINE_MAX: c_int = 8;
pub const USER_RE_DUP_MAX: c_int = 9;
}

pub const USER_POSIX2_VERSION: c_int = 10;
pub const USER_POSIX2_C_BIND: c_int = 11;
pub const USER_POSIX2_C_DEV: c_int = 12;
Expand Down Expand Up @@ -1168,7 +1172,10 @@ pub const RTM_VERSION: c_int = 7;
pub const RTAX_MPLS1: c_int = 8;
pub const RTAX_MPLS2: c_int = 9;
pub const RTAX_MPLS3: c_int = 10;
pub const RTAX_MAX: c_int = 11;

ct! {
pub const RTAX_MAX: c_int = 11;
}

const fn _CMSG_ALIGN(n: usize) -> usize {
(n + (size_of::<c_long>() - 1)) & !(size_of::<c_long>() - 1)
Expand Down
Loading
Loading