]> git.proxmox.com Git - rustc.git/blob - src/libstd/rt/macros.rs
Imported Upstream version 1.3.0+dfsg1
[rustc.git] / src / libstd / rt / macros.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! Macros used by the runtime.
12 //!
13 //! These macros call functions which are only accessible in the `rt` module, so
14 //! they aren't defined anywhere outside of the `rt` module.
15
16 macro_rules! rterrln {
17 ($fmt:expr) => ( {
18 ::rt::util::dumb_print(format_args!(concat!($fmt, "\n")))
19 } );
20 ($fmt:expr, $($arg:expr),*) => ( {
21 ::rt::util::dumb_print(format_args!(concat!($fmt, "\n"), $($arg),*))
22 } )
23 }
24
25 // Some basic logging. Enabled by passing `--cfg rtdebug` to the libstd build.
26 macro_rules! rtdebug {
27 ($arg:expr) => ( {
28 if cfg!(rtdebug) {
29 rterrln!($arg)
30 }
31 } );
32 ($str:expr, $($arg:expr),*) => ( {
33 if cfg!(rtdebug) {
34 rterrln!($str, $($arg),*)
35 }
36 })
37 }
38
39 macro_rules! rtassert {
40 ( $arg:expr ) => ( {
41 if ::rt::util::ENFORCE_SANITY {
42 if !$arg {
43 rtabort!(" assertion failed: {}", stringify!($arg));
44 }
45 }
46 } )
47 }
48
49 macro_rules! rtabort {
50 ($($arg:tt)*) => (::rt::util::abort(format_args!($($arg)*)))
51 }