diff --git a/src/macros.rs b/src/macros.rs index 0149b1fd1846..5c5b8c2deac7 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -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; diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index 041e2525d9bc..8cf206a6366f 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -690,7 +690,10 @@ pub const EI_CLASS: usize = 4; pub const ELFCLASSNONE: u8 = 0; pub const ELFCLASS32: u8 = 1; pub const ELFCLASS64: u8 = 2; -pub const ELFCLASSNUM: usize = 3; + +ct! { + pub const ELFCLASSNUM: usize = 3; +} pub const EI_DATA: usize = 5; pub const ELFDATANONE: u8 = 0; @@ -821,7 +824,10 @@ pub const EM_ALPHA: u16 = 0x9026; // elf.h - Legal values for e_version (version). pub const EV_NONE: u32 = 0; pub const EV_CURRENT: u32 = 1; -pub const EV_NUM: u32 = 2; + +ct! { + pub const EV_NUM: u32 = 2; +} // elf.h - Legal values for p_type (segment type). pub const PT_NULL: u32 = 0;