src/core/abort.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sat, 04 Jul 2009 08:15:48 +0200
changeset 4654 2eaebe77d66b
parent 3937 04f9377661b8
permissions -rw-r--r--
Added tag ns-3.5 for changeset c975274c9707

/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2008 INRIA
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
#ifndef NS3_ABORT_H
#define NS3_ABORT_H

#include "fatal-error.h"

#define NS_ABORT_MSG(msg)                                       \
  do {								\
    std::cerr << "file=" << __FILE__ <<                         \
      ", line=" << __LINE__ << ", abort, msg=\"" <<             \
      msg << "\"" << std::endl;                                 \
    int *a = 0;                                                 \
    *a = 0;							\
  } while (false)


#define NS_ABORT_IF(cond)					\
  do {								\
    if (cond)							\
      {								\
	std::cerr << "file=" << __FILE__ <<			\
	  ", line=" << __LINE__ << ", abort on=\""#cond <<	\
            "\"" << std::endl;                                  \
	int *a = 0;						\
	*a = 0;							\
      }								\
  } while (false)

#define NS_ABORT_MSG_IF(cond, msg)				\
  do {								\
    if (cond)							\
      {								\
	std::cerr << "file=" << __FILE__ <<			\
	  ", line=" << __LINE__ << ", abort on=\""#cond <<	\
	  "\", msg=\"" << msg << "\"" << std::endl;		\
	int *a = 0;						\
	*a = 0;							\
      }								\
  } while (false)

#define NS_ABORT_UNLESS(cond)				\
  NS_ABORT_IF(!(cond))

#define NS_ABORT_MSG_UNLESS(cond, msg)			\
  NS_ABORT_MSG_IF(!(cond),msg)

#endif /* NS3_ABORT_H */