Refactor ASSERT macro.

This commit is contained in:
Gunnar Beutner 2013-08-28 08:18:58 +02:00
parent 6f61ed761b
commit f39f69d390
23 changed files with 63 additions and 23 deletions

View File

@ -31,7 +31,7 @@
#include "livestatus/orfilter.h"
#include "livestatus/andfilter.h"
#include "icinga/externalcommandprocessor.h"
#include "base/utility.h"
#include "base/debug.h"
#include "base/convert.h"
#include "base/objectlock.h"
#include "base/logger_fwd.h"

View File

@ -15,6 +15,7 @@ libbase_la_SOURCES = \
consolelogger.h \
convert.cpp \
convert.h \
debug.h \
dictionary.cpp \
dictionary.h \
dynamicobject.cpp \

View File

@ -24,6 +24,7 @@
#include "base/exception.h"
#include "base/objectlock.h"
#include "base/utility.h"
#include "base/debug.h"
#include <sstream>
#include <boost/algorithm/string/classification.hpp>
#include <boost/thread/thread.hpp>

View File

@ -19,7 +19,7 @@
#include "base/array.h"
#include "base/objectlock.h"
#include "base/utility.h"
#include "base/debug.h"
#include <cJSON.h>
#include <boost/make_shared.hpp>
#include <boost/foreach.hpp>

40
lib/base/debug.h Normal file
View File

@ -0,0 +1,40 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
#ifndef DEBUG_H
#define DEBUG_H
#include <stdlib.h>
#include <stdio.h>
#ifdef NDEBUG
# define ASSERT(expr) ((void)0)
#else /* NDEBUG */
# define ASSERT(expr) define ASSERT(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__))
#endif /* NDEBUG */
#define VERIFY(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__))
inline void icinga_assert_fail(const char *expr, const char *file, int line)
{
fprintf(stderr, "%s:%d: assertion failed: %s\n", file, line, expr);
abort();
}
#endif /* DEBUG_H */

View File

@ -19,7 +19,7 @@
#include "base/dictionary.h"
#include "base/objectlock.h"
#include "base/utility.h"
#include "base/debug.h"
#include <cJSON.h>
#include <boost/tuple/tuple.hpp>
#include <boost/make_shared.hpp>

View File

@ -22,7 +22,7 @@
#include "base/netstring.h"
#include "base/registry.h"
#include "base/stdiostream.h"
#include "base/utility.h"
#include "base/debug.h"
#include "base/objectlock.h"
#include "base/logger_fwd.h"
#include "base/exception.h"

View File

@ -18,7 +18,7 @@
******************************************************************************/
#include "base/dynamictype.h"
#include "base/utility.h"
#include "base/debug.h"
#include "base/objectlock.h"
using namespace icinga;

View File

@ -23,7 +23,7 @@
#include "base/i2-base.h"
#include "base/registry.h"
#include "base/dynamicobject.h"
#include "base/utility.h"
#include "base/debug.h"
#include <map>
#include <set>
#include <boost/function.hpp>

View File

@ -18,7 +18,7 @@
******************************************************************************/
#include "base/netstring.h"
#include "base/utility.h"
#include "base/debug.h"
#include <sstream>
using namespace icinga;

View File

@ -18,7 +18,7 @@
******************************************************************************/
#include "base/objectlock.h"
#include "base/utility.h"
#include "base/debug.h"
using namespace icinga;

View File

@ -22,7 +22,7 @@
#include "base/dynamictype.h"
#include "base/logger_fwd.h"
#include "base/objectlock.h"
#include "base/utility.h"
#include "base/debug.h"
using namespace icinga;
@ -74,4 +74,4 @@ void Script::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
m_Language = bag->Get("language");
m_Code = bag->Get("code");
}
}

View File

@ -20,6 +20,7 @@
#include "base/threadpool.h"
#include "base/logger_fwd.h"
#include "base/convert.h"
#include "base/debug.h"
#include "base/utility.h"
#include <sstream>
#include <iostream>

View File

@ -19,6 +19,7 @@
#include "base/timer.h"
#include "base/application.h"
#include "base/debug.h"
#include "base/utility.h"
#include "base/logger_fwd.h"
#include <boost/bind.hpp>

View File

@ -20,6 +20,7 @@
#include "base/tlsstream.h"
#include "base/stream_bio.h"
#include "base/objectlock.h"
#include "base/debug.h"
#include "base/utility.h"
#include "base/exception.h"
#include <boost/bind.hpp>

View File

@ -89,11 +89,4 @@ private:
}
#ifdef _DEBUG
# include <cassert>
# define ASSERT(expr) assert(expr)
#else /* _DEBUG */
# define ASSERT(expr) __builtin_unreachable()
#endif /* _DEBUG */
#endif /* UTILITY_H */

View File

@ -22,7 +22,7 @@
#include "base/dynamictype.h"
#include "base/objectlock.h"
#include "base/logger_fwd.h"
#include "base/utility.h"
#include "base/debug.h"
#include <sstream>
#include <boost/tuple/tuple.hpp>
#include <boost/smart_ptr/make_shared.hpp>

View File

@ -20,7 +20,7 @@
#include "config/expression.h"
#include "config/expressionlist.h"
#include "base/objectlock.h"
#include "base/utility.h"
#include "base/debug.h"
#include "base/array.h"
#include <sstream>
#include <boost/tuple/tuple.hpp>

View File

@ -23,7 +23,7 @@
#include "icinga/eventcommand.h"
#include "base/dynamictype.h"
#include "base/objectlock.h"
#include "base/utility.h"
#include "base/debug.h"
#include <boost/smart_ptr/make_shared.hpp>
#include <boost/foreach.hpp>
#include <boost/tuple/tuple.hpp>

View File

@ -27,7 +27,7 @@
#include "base/timer.h"
#include "base/convert.h"
#include "base/scriptfunction.h"
#include "base/utility.h"
#include "base/debug.h"
#include "config/configitembuilder.h"
#include "config/configcompilercontext.h"
#include <boost/tuple/tuple.hpp>

View File

@ -22,6 +22,8 @@
#include "base/logger_fwd.h"
#include "base/objectlock.h"
#include "base/convert.h"
#include "base/debug.h"
#include "base/utility.h"
#include "base/timer.h"
#include <boost/smart_ptr/make_shared.hpp>

View File

@ -23,7 +23,7 @@
#include "base/exception.h"
#include "base/objectlock.h"
#include "base/logger_fwd.h"
#include "base/utility.h"
#include "base/debug.h"
#include <boost/smart_ptr/make_shared.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>

View File

@ -20,7 +20,7 @@
#include "ido/dbtype.h"
#include "ido/dbconnection.h"
#include "base/objectlock.h"
#include "base/utility.h"
#include "base/debug.h"
#include <boost/thread/once.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/foreach.hpp>