optee_utee/macros.rs
1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18/// Macro for printing to the trace output, without a newline.
19///
20/// Equivalent to the `trace_println!` macro expect that a newline is not
21/// printed at the end of the message.
22///
23/// # Examples
24///
25/// ``` rust,no_run
26/// # use optee_utee::trace_print;
27///
28/// trace_print!("this ");
29/// trace_print!("will ");
30/// trace_print!("be ");
31/// trace_print!("on ");
32/// trace_print!("the ");
33/// trace_print!("same ");
34/// trace_print!("line ");
35/// trace_print!("this string has a newline, why not choose println! instead?\n");
36/// ```
37#[macro_export]
38macro_rules! trace_print {
39 ($($arg:tt)*) => ($crate::trace::Trace::_print(format_args!($($arg)*)));
40}
41
42/// Macro for printing to the trace output, with a newline.
43/// Use the `format!` syntax to write data to the standard output. See
44/// `std::fmt` for more information.
45///
46/// # Examples
47///
48/// ``` rust,no_run
49/// # use optee_utee::trace_println;
50/// trace_println!("Hello, World!");
51/// trace_println!("format {} arguments", "some");
52/// ```
53#[macro_export]
54macro_rules! trace_println {
55 () => {
56 $crate::trace::Trace::_print(format_args!("\n"));
57 };
58 ($s:expr) => {
59 $crate::trace::Trace::_print(format_args!(concat!($s, "\n")));
60 };
61 ($s:expr, $($tt:tt)*) => {
62 $crate::trace::Trace::_print(format_args!(concat!($s, "\n"), $($tt)*));
63 };
64}