src/core/abort.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 24 Oct 2008 10:29:06 +0200
changeset 3781 0eea20a7b592
child 3937 04f9377661b8
permissions -rw-r--r--
bug 339: unconditional assert API.

/* -*- 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_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 */