summaryrefslogtreecommitdiffstats
path: root/vendor/sysinfo/src/macros.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/sysinfo/src/macros.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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),)*
+ }
+ }
+ )
+}