qemu-cr16/rust/trace/src/lib.rs
Tanish Desai 1461752f0f tracetool/syslog: add Rust support
The syslog backend needs the syslog function from libc and the LOG_INFO enum
value; they are re-exported as "::trace::syslog" and "::trace::LOG_INFO"
so that device crates do not all have to add the libc dependency, but
otherwise there is nothing special.

Signed-off-by: Tanish Desai <tanishdesai37@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-ID: <20250929154938.594389-17-pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2025-10-01 11:22:07 -04:00

39 lines
1.1 KiB
Rust

// SPDX-License-Identifier: GPL-2.0-or-later
//! This crate provides macros that aid in using QEMU's tracepoint
//! functionality.
#[doc(hidden)]
/// Re-exported item to avoid adding libc as a dependency everywhere.
pub use libc::{syslog, LOG_INFO};
#[macro_export]
/// Define the trace-points from the named directory (which should have slashes
/// replaced by underscore characters) as functions in a module called `trace`.
///
/// ```ignore
/// ::trace::include_trace!("hw_char");
/// // ...
/// trace::trace_pl011_read_fifo_rx_full();
/// ```
macro_rules! include_trace {
($name:literal) => {
#[allow(
clippy::ptr_as_ptr,
clippy::cast_lossless,
clippy::used_underscore_binding
)]
mod trace {
#[cfg(not(MESON))]
include!(concat!(
env!("MESON_BUILD_ROOT"),
"/trace/trace-",
$name,
".rs"
));
#[cfg(MESON)]
include!(concat!("@MESON_BUILD_ROOT@/trace/trace-", $name, ".rs"));
}
};
}