| 1 |
//! Utility macro for converting priority values to literals. |
| 2 |
|
| 3 |
/// Make a macro that zero-pads priority values to 3 digits. |
| 4 |
macro_rules! __make_priority_literal { |
| 5 |
($dollar:tt $( |
| 6 |
($prefix:literal $( $priority:tt )*) |
| 7 |
)*) => { |
| 8 |
/// Convert a priority value to a literal if 0 < N < 1000, otherwise pass through the value. |
| 9 |
#[doc(hidden)] |
| 10 |
#[macro_export] |
| 11 |
macro_rules! __priority_to_literal { |
| 12 |
$( |
| 13 |
$( |
| 14 |
($dollar n:path, $dollar a:tt = $priority ) => { |
| 15 |
$n!($a, (concat!(stringify!($prefix), stringify!($priority)))); |
| 16 |
}; |
| 17 |
)* |
| 18 |
)* |
| 19 |
|
| 20 |
($n:path, $a:tt=$dollar priority:tt) => { |
| 21 |
$n!($a, ($dollar priority)); |
| 22 |
}; |
| 23 |
} |
| 24 |
}; |
| 25 |
} |
| 26 |
|
| 27 |
#[cfg(target_os = "aix")] |
| 28 |
pub(crate) mod aix { |
| 29 |
macro_rules! __make_aix_priority_literal { |
| 30 |
( $dollar:tt $($priority:tt $d0:tt $d1:tt $d2:tt)* ) => { |
| 31 |
#[doc(hidden)] |
| 32 |
#[macro_export] |
| 33 |
macro_rules! __priority_to_literal { |
| 34 |
$( |
| 35 |
($dollar n:path, $dollar a:tt = $priority ) => { |
| 36 |
$n!($a, (concat!("80000", $d0, $d1, $d2))); |
| 37 |
}; |
| 38 |
)* |
| 39 |
|
| 40 |
($n:path, $a:tt=$dollar priority:tt) => { |
| 41 |
$n!($a, ($dollar priority)); |
| 42 |
}; |
| 43 |
} |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
pub(crate) use __make_aix_priority_literal; |
| 48 |
} |
| 49 |
|
| 50 |
#[cfg(not(target_os = "aix"))] |
| 51 |
__make_priority_literal! { $ |
| 52 |
(00 0 1 2 3 4 5 6 7 8 9) |
| 53 |
(0 10 11 12 13 14 15 16 17 18 19) |
| 54 |
(0 20 21 22 23 24 25 26 27 28 29) |
| 55 |
(0 30 31 32 33 34 35 36 37 38 39) |
| 56 |
(0 40 41 42 43 44 45 46 47 48 49) |
| 57 |
(0 50 51 52 53 54 55 56 57 58 59) |
| 58 |
(0 60 61 62 63 64 65 66 67 68 69) |
| 59 |
(0 70 71 72 73 74 75 76 77 78 79) |
| 60 |
(0 80 81 82 83 84 85 86 87 88 89) |
| 61 |
(0 90 91 92 93 94 95 96 97 98 99) |
| 62 |
} |