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
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
5 changes: 4 additions & 1 deletion src/solid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ pub const LC_MONETARY: c_int = 3;
pub const LC_NUMERIC: c_int = 4;
pub const LC_TIME: c_int = 5;
pub const LC_MESSAGES: c_int = 6;
pub const _LC_LAST: c_int = 7;

ct! {
pub const _LC_LAST: c_int = 7;
}

pub const EPERM: c_int = 1;
pub const ENOENT: c_int = 2;
Expand Down
5 changes: 4 additions & 1 deletion src/unix/bsd/netbsdlike/openbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,10 @@ pub const LC_NUMERIC_MASK: c_int = 1 << crate::LC_NUMERIC;
pub const LC_TIME_MASK: c_int = 1 << crate::LC_TIME;
pub const LC_MESSAGES_MASK: c_int = 1 << crate::LC_MESSAGES;

const _LC_LAST: c_int = 7;
ct! {
const _LC_LAST: c_int = 7;
}

pub const LC_ALL_MASK: c_int = (1 << _LC_LAST) - 2;

pub const LC_GLOBAL_LOCALE: crate::locale_t = -1isize as crate::locale_t;
Expand Down
15 changes: 12 additions & 3 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,10 @@ pub const NF_BR_PRI_BRNF: c_int = 0;
pub const NF_BR_PRI_NAT_DST_OTHER: c_int = 100;
pub const NF_BR_PRI_FILTER_OTHER: c_int = 200;
pub const NF_BR_PRI_NAT_SRC: c_int = 300;
pub const NF_BR_PRI_LAST: c_int = crate::INT_MAX;

ct! {
pub const NF_BR_PRI_LAST: c_int = crate::INT_MAX;
}

// linux/netfilter_ipv4.h
pub const NF_IP_PRE_ROUTING: c_int = 0;
Expand All @@ -1961,7 +1964,10 @@ pub const NF_IP_PRI_NAT_SRC: c_int = 100;
pub const NF_IP_PRI_SELINUX_LAST: c_int = 225;
pub const NF_IP_PRI_CONNTRACK_HELPER: c_int = 300;
pub const NF_IP_PRI_CONNTRACK_CONFIRM: c_int = crate::INT_MAX;
pub const NF_IP_PRI_LAST: c_int = crate::INT_MAX;

ct! {
pub const NF_IP_PRI_LAST: c_int = crate::INT_MAX;
}

// linux/netfilter_ipv6.h
pub const NF_IP6_PRE_ROUTING: c_int = 0;
Expand All @@ -1984,7 +1990,10 @@ pub const NF_IP6_PRI_SECURITY: c_int = 50;
pub const NF_IP6_PRI_NAT_SRC: c_int = 100;
pub const NF_IP6_PRI_SELINUX_LAST: c_int = 225;
pub const NF_IP6_PRI_CONNTRACK_HELPER: c_int = 300;
pub const NF_IP6_PRI_LAST: c_int = crate::INT_MAX;

ct! {
pub const NF_IP6_PRI_LAST: c_int = crate::INT_MAX;
}

// linux/netfilter_ipv6/ip6_tables.h
pub const IP6T_SO_ORIGINAL_DST: c_int = 80;
Expand Down
22 changes: 17 additions & 5 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,10 @@ pub const NF_BR_PRI_BRNF: c_int = 0;
pub const NF_BR_PRI_NAT_DST_OTHER: c_int = 100;
pub const NF_BR_PRI_FILTER_OTHER: c_int = 200;
pub const NF_BR_PRI_NAT_SRC: c_int = 300;
pub const NF_BR_PRI_LAST: c_int = crate::INT_MAX;

ct! {
pub const NF_BR_PRI_LAST: c_int = crate::INT_MAX;
}

// linux/netfilter_ipv4.h
pub const NF_IP_PRE_ROUTING: c_int = 0;
Expand All @@ -2204,7 +2207,10 @@ pub const NF_IP_PRI_NAT_SRC: c_int = 100;
pub const NF_IP_PRI_SELINUX_LAST: c_int = 225;
pub const NF_IP_PRI_CONNTRACK_HELPER: c_int = 300;
pub const NF_IP_PRI_CONNTRACK_CONFIRM: c_int = crate::INT_MAX;
pub const NF_IP_PRI_LAST: c_int = crate::INT_MAX;

ct! {
pub const NF_IP_PRI_LAST: c_int = crate::INT_MAX;
}

// linux/netfilter_ipv6.h
pub const NF_IP6_PRE_ROUTING: c_int = 0;
Expand All @@ -2227,7 +2233,10 @@ pub const NF_IP6_PRI_SECURITY: c_int = 50;
pub const NF_IP6_PRI_NAT_SRC: c_int = 100;
pub const NF_IP6_PRI_SELINUX_LAST: c_int = 225;
pub const NF_IP6_PRI_CONNTRACK_HELPER: c_int = 300;
pub const NF_IP6_PRI_LAST: c_int = crate::INT_MAX;

ct! {
pub const NF_IP6_PRI_LAST: c_int = crate::INT_MAX;
}

// linux/netfilter_ipv6/ip6_tables.h
pub const IP6T_SO_ORIGINAL_DST: c_int = 80;
Expand Down Expand Up @@ -2304,10 +2313,13 @@ pub const SIOCGIWENCODEEXT: c_ulong = 0x8B35;
pub const SIOCSIWPMKSA: c_ulong = 0x8B36;

pub const SIOCIWFIRSTPRIV: c_ulong = 0x8BE0;
pub const SIOCIWLASTPRIV: c_ulong = 0x8BFF;

ct! {
pub const SIOCIWLASTPRIV: c_ulong = 0x8BFF;
pub const SIOCIWLAST: c_ulong = SIOCIWLASTPRIV;
}

pub const SIOCIWFIRST: c_ulong = 0x8B00;
pub const SIOCIWLAST: c_ulong = SIOCIWLASTPRIV;

pub const IWEVTXDROP: c_ulong = 0x8C00;
pub const IWEVQUAL: c_ulong = 0x8C01;
Expand Down
4 changes: 3 additions & 1 deletion src/unix/solarish/illumos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ pub const LOCK_EX: c_int = 2;
pub const LOCK_NB: c_int = 4;
pub const LOCK_UN: c_int = 8;

pub const _PC_LAST: c_int = 101;
ct! {
pub const _PC_LAST: c_int = 101;
}

pub const _CS_PATH: c_int = 65;

Expand Down
4 changes: 3 additions & 1 deletion src/unix/solarish/solaris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ pub const F_DUPFD_CLOFORK: c_int = 49;
pub const F_DUP2FD_CLOEXEC: c_int = 48;
pub const F_DUP2FD_CLOFORK: c_int = 50;

pub const _PC_LAST: c_int = 102;
ct! {
pub const _PC_LAST: c_int = 102;
}

pub const PRIV_PROC_SENSITIVE: c_uint = 0x0008;
pub const PRIV_PFEXEC_AUTH: c_uint = 0x0200;
Expand Down