(index<- ) ./libstd/rt/macros.rs
git branch: * master 5200215 auto merge of #14035 : alexcrichton/rust/experimental, r=huonw
modified: Wed Apr 9 17:27:02 2014
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_escape]
17
18 macro_rules! rterrln (
19 ($($arg:tt)*) => ( {
20 format_args!(::rt::util::dumb_println, $($arg)*)
21 } )
22 )
23
24 // Some basic logging. Enabled by passing `--cfg rtdebug` to the libstd build.
25 macro_rules! rtdebug (
26 ($($arg:tt)*) => ( {
27 if cfg!(rtdebug) {
28 rterrln!($($arg)*)
29 }
30 })
31 )
32
33 macro_rules! rtassert (
34 ( $arg:expr ) => ( {
35 if ::rt::util::ENFORCE_SANITY {
36 if !$arg {
37 rtabort!(" assertion failed: {}", stringify!($arg));
38 }
39 }
40 } )
41 )
42
43
44 macro_rules! rtabort (
45 ($($arg:tt)*) => ( {
46 ::rt::util::abort(format!($($arg)*));
47 } )
48 )