File tree Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,21 @@ cfg_if! {
164164 }
165165 ) * )
166166 }
167+
168+ macro_rules! const_fn {
169+ ( $( $( { $constness: ident} ) * fn $i: ident(
170+ $( $arg: ident: $argty: ty) , *
171+ ) -> $ret: ty {
172+ $( $body: stmt) ; *
173+ } ) * ) => ( $(
174+ #[ inline]
175+ $( $constness) * fn $i( $( $arg: $argty) , *
176+ ) -> $ret {
177+ $( $body) ; *
178+ }
179+ ) * )
180+ }
181+
167182 } else {
168183 #[ allow( unused_macros) ]
169184 macro_rules! f {
@@ -173,7 +188,22 @@ cfg_if! {
173188 $( $body: stmt) ; *
174189 } ) * ) => ( $(
175190 #[ inline]
176- pub unsafe extern fn $i( $( $arg: $argty) , * ) -> $ret {
191+ pub unsafe extern fn $i( $( $arg: $argty) , *
192+ ) -> $ret {
193+ $( $body) ; *
194+ }
195+ ) * )
196+ }
197+
198+ macro_rules! const_fn {
199+ ( $( $( { $constness: ident} ) * fn $i: ident(
200+ $( $arg: ident: $argty: ty) , *
201+ ) -> $ret: ty {
202+ $( $body: stmt) ; *
203+ } ) * ) => ( $(
204+ #[ inline]
205+ fn $i( $( $arg: $argty) , *
206+ ) -> $ret {
177207 $( $body) ; *
178208 }
179209 ) * )
Original file line number Diff line number Diff line change @@ -1165,8 +1165,10 @@ pub const ARPHRD_IEEE802154: u16 = 804;
11651165pub const ARPHRD_VOID : u16 = 0xFFFF ;
11661166pub const ARPHRD_NONE : u16 = 0xFFFE ;
11671167
1168- const fn CMSG_ALIGN ( len : usize ) -> usize {
1169- len + :: mem:: size_of :: < usize > ( ) - 1 & !( :: mem:: size_of :: < usize > ( ) - 1 )
1168+ const_fn ! {
1169+ { const } fn CMSG_ALIGN ( len: usize ) -> usize {
1170+ len + :: mem:: size_of:: <usize >( ) - 1 & !( :: mem:: size_of:: <usize >( ) - 1 )
1171+ }
11701172}
11711173
11721174f ! {
You can’t perform that action at this time.
0 commit comments