summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2022-04-21 15:29:43 +0200
committerJustus Winter <justus@sequoia-pgp.org>2022-04-21 15:29:43 +0200
commit595212d3c04d0f3cb0648c3dd6832cb0a1d5c1fa (patch)
tree29821c30a4f6ca8b928910d410c6ebe61aeef751 /ipc
parentfae04096cc6c239ca3ad5c17e686ff4706a0712e (diff)
ipc: Move platform! macro.
Diffstat (limited to 'ipc')
-rw-r--r--ipc/src/lib.rs15
-rw-r--r--ipc/src/macros.rs18
2 files changed, 18 insertions, 15 deletions
diff --git a/ipc/src/lib.rs b/ipc/src/lib.rs
index f6f2525a..7dbe78e2 100644
--- a/ipc/src/lib.rs
+++ b/ipc/src/lib.rs
@@ -74,21 +74,6 @@ pub use crate::core::{Config, Context, IPCPolicy};
#[cfg(test)]
mod tests;
-macro_rules! platform {
- { unix => { $($unix:tt)* }, windows => { $($windows:tt)* } } => {
- if cfg!(unix) {
- #[cfg(unix)] { $($unix)* }
- #[cfg(not(unix))] { unreachable!() }
- } else if cfg!(windows) {
- #[cfg(windows)] { $($windows)* }
- #[cfg(not(windows))] { unreachable!() }
- } else {
- #[cfg(not(any(unix, windows)))] compile_error!("Unsupported platform");
- unreachable!()
- }
- }
-}
-
/// Servers need to implement this trait.
pub trait Handler {
/// Called on every connection.
diff --git a/ipc/src/macros.rs b/ipc/src/macros.rs
index c0fc6091..b38405b1 100644
--- a/ipc/src/macros.rs
+++ b/ipc/src/macros.rs
@@ -55,6 +55,24 @@ macro_rules! tracer {
}
}
+/// Platform abstraction.
+///
+/// Using this macro makes sure that missing support for new platform
+/// is a compile-time error.
+macro_rules! platform {
+ { unix => { $($unix:tt)* }, windows => { $($windows:tt)* } } => {
+ if cfg!(unix) {
+ #[cfg(unix)] { $($unix)* }
+ #[cfg(not(unix))] { unreachable!() }
+ } else if cfg!(windows) {
+ #[cfg(windows)] { $($windows)* }
+ #[cfg(not(windows))] { unreachable!() }
+ } else {
+ #[cfg(not(any(unix, windows)))] compile_error!("Unsupported platform");
+ unreachable!()
+ }
+ }
+}
/// A very simple profiling tool.
///