|
|
| 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 |
/* |
| 3 |
* Copyright (c) 2008 INRIA |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License version 2 as |
| 7 |
* published by the Free Software Foundation; |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with this program; if not, write to the Free Software |
| 16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 |
* |
| 18 |
*/ |
| 19 |
#ifndef NS3_ABORT_H |
| 20 |
#define NS3_ABORT_H |
| 21 |
|
| 22 |
#include "fatal-error.h" |
| 23 |
|
| 24 |
#define NS_ABORT_IF(cond) \ |
| 25 |
do { \ |
| 26 |
if (cond) \ |
| 27 |
{ \ |
| 28 |
std::cerr << "file=" << __FILE__ << \ |
| 29 |
", line=" << __LINE__ << ", abort on=\""#cond << \ |
| 30 |
"\"" << std::endl; \ |
| 31 |
int *a = 0; \ |
| 32 |
*a = 0; \ |
| 33 |
} \ |
| 34 |
} while (false) |
| 35 |
|
| 36 |
#define NS_ABORT_MSG_IF(cond, msg) \ |
| 37 |
do { \ |
| 38 |
if (cond) \ |
| 39 |
{ \ |
| 40 |
std::cerr << "file=" << __FILE__ << \ |
| 41 |
", line=" << __LINE__ << ", abort on=\""#cond << \ |
| 42 |
"\", msg=\"" << msg << "\"" << std::endl; \ |
| 43 |
int *a = 0; \ |
| 44 |
*a = 0; \ |
| 45 |
} \ |
| 46 |
} while (false) |
| 47 |
|
| 48 |
#define NS_ABORT_IF_NOT(cond) \ |
| 49 |
NS_ABORT_IF(!(cond)) |
| 50 |
|
| 51 |
#define NS_ABORT_MSG_IF_NOT(cond, msg) \ |
| 52 |
NS_ABORT_MSG_IF(!(cond),msg) |
| 53 |
|
| 54 |
#endif /* NS3_ABORT_H */ |