From 6e9ba1cb96a316e56144aa9f321ab9cba24d5113 Mon Sep 17 00:00:00 2001 From: Rushil Mehra Date: Fri, 26 Jul 2024 13:12:03 -0700 Subject: [PATCH] Clean up legacy const_fn feature gates --- boring-sys/src/lib.rs | 40 +++++++++------------------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/boring-sys/src/lib.rs b/boring-sys/src/lib.rs index db168d09..c6002db0 100644 --- a/boring-sys/src/lib.rs +++ b/boring-sys/src/lib.rs @@ -27,42 +27,20 @@ pub type BN_ULONG = u64; #[cfg(target_pointer_width = "32")] pub type BN_ULONG = u32; -#[cfg(const_fn)] -macro_rules! const_fn { - ($(pub const fn $name:ident($($arg:ident: $t:ty),*) -> $ret:ty $b:block)*) => { - $( - pub const fn $name($($arg: $t),*) -> $ret $b - )* - } +pub const fn ERR_PACK(l: c_int, f: c_int, r: c_int) -> c_ulong { + ((l as c_ulong & 0x0FF) << 24) | ((f as c_ulong & 0xFFF) << 12) | (r as c_ulong & 0xFFF) } -#[cfg(not(const_fn))] -macro_rules! const_fn { - ($(pub const fn $name:ident($($arg:ident: $t:ty),*) -> $ret:ty $b:block)*) => { - $( - pub fn $name($($arg: $t),*) -> $ret $b - )* - } +pub const fn ERR_GET_LIB(l: c_uint) -> c_int { + ((l >> 24) & 0x0FF) as c_int } -const_fn! { - pub const fn ERR_PACK(l: c_int, f: c_int, r: c_int) -> c_ulong { - ((l as c_ulong & 0x0FF) << 24) | - ((f as c_ulong & 0xFFF) << 12) | - (r as c_ulong & 0xFFF) - } +pub const fn ERR_GET_FUNC(l: c_uint) -> c_int { + ((l >> 12) & 0xFFF) as c_int +} - pub const fn ERR_GET_LIB(l: c_uint) -> c_int { - ((l >> 24) & 0x0FF) as c_int - } - - pub const fn ERR_GET_FUNC(l: c_uint) -> c_int { - ((l >> 12) & 0xFFF) as c_int - } - - pub const fn ERR_GET_REASON(l: c_uint) -> c_int { - (l & 0xFFF) as c_int - } +pub const fn ERR_GET_REASON(l: c_uint) -> c_int { + (l & 0xFFF) as c_int } pub fn init() {