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! {
164
164
}
165
165
) * )
166
166
}
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
+
167
182
} else {
168
183
#[ allow( unused_macros) ]
169
184
macro_rules! f {
@@ -173,7 +188,22 @@ cfg_if! {
173
188
$( $body: stmt) ; *
174
189
} ) * ) => ( $(
175
190
#[ 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 {
177
207
$( $body) ; *
178
208
}
179
209
) * )
Original file line number Diff line number Diff line change @@ -1165,8 +1165,10 @@ pub const ARPHRD_IEEE802154: u16 = 804;
1165
1165
pub const ARPHRD_VOID : u16 = 0xFFFF ;
1166
1166
pub const ARPHRD_NONE : u16 = 0xFFFE ;
1167
1167
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
+ }
1170
1172
}
1171
1173
1172
1174
f ! {
You can’t perform that action at this time.
0 commit comments