summaryrefslogtreecommitdiffstats
path: root/vendor/sysinfo/src/macros.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sysinfo/src/macros.rs')
-rw-r--r--vendor/sysinfo/src/macros.rs58
1 files changed, 58 insertions, 0 deletions
diff --git a/vendor/sysinfo/src/macros.rs b/vendor/sysinfo/src/macros.rs
new file mode 100644
index 000000000..3bb4defa1
--- /dev/null
+++ b/vendor/sysinfo/src/macros.rs
@@ -0,0 +1,58 @@
+// Take a look at the license at the top of the repository in the LICENSE file.
+
+#[cfg(feature = "debug")]
+#[doc(hidden)]
+#[allow(unused)]
+macro_rules! sysinfo_debug {
+ ($($x:tt)*) => {{
+ eprintln!($($x)*);
+ }}
+}
+
+#[cfg(not(feature = "debug"))]
+#[doc(hidden)]
+#[allow(unused)]
+macro_rules! sysinfo_debug {
+ ($($x:tt)*) => {{}};
+}
+
+macro_rules! declare_signals {
+ ($kind:ty, _ => None,) => (
+ use crate::Signal;
+
+ pub(crate) const fn supported_signals() -> &'static [Signal] {
+ &[]
+ }
+ );
+
+ ($kind:ty, $(Signal::$signal:ident => $map:expr,)+ _ => None,) => (
+ use crate::Signal;
+
+ pub(crate) const fn supported_signals() -> &'static [Signal] {
+ &[$(Signal::$signal,)*]
+ }
+
+ #[inline]
+ pub(crate) fn convert_signal(s: Signal) -> Option<$kind> {
+ match s {
+ $(Signal::$signal => Some($map),)*
+ _ => None,
+ }
+ }
+ );
+
+ ($kind:ty, $(Signal::$signal:ident => $map:expr,)+) => (
+ use crate::Signal;
+
+ pub(crate) const fn supported_signals() -> &'static [Signal] {
+ &[$(Signal::$signal,)*]
+ }
+
+ #[inline]
+ pub(crate) fn convert_signal(s: Signal) -> Option<$kind> {
+ match s {
+ $(Signal::$signal => Some($map),)*
+ }
+ }
+ )
+}