]> granicus.if.org Git - icinga2/commitdiff
Refactor ASSERT macro.
authorGunnar Beutner <gunnar@beutner.name>
Wed, 28 Aug 2013 06:18:58 +0000 (08:18 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Wed, 28 Aug 2013 06:18:58 +0000 (08:18 +0200)
23 files changed:
components/livestatus/query.cpp
lib/base/Makefile.am
lib/base/application.cpp
lib/base/array.cpp
lib/base/debug.h [new file with mode: 0644]
lib/base/dictionary.cpp
lib/base/dynamicobject.cpp
lib/base/dynamictype.cpp
lib/base/dynamictype.h
lib/base/netstring.cpp
lib/base/objectlock.cpp
lib/base/script.cpp
lib/base/threadpool.cpp
lib/base/timer.cpp
lib/base/tlsstream.cpp
lib/base/utility.h
lib/config/configitem.cpp
lib/config/expression.cpp
lib/icinga/compatutility.cpp
lib/icinga/host.cpp
lib/icinga/icingaapplication.cpp
lib/icinga/legacytimeperiod.cpp
lib/ido/dbtype.cpp

index a1043891e2ef97b373c434f3adad4680e9486e1e..d250b561869eca1f12c6cac5e60fb9b6e3d01a97 100644 (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"
index 38806031e7559a207c3429f91309a317def04a61..e5faae37683d8ec5bfe7de63c08408053e65b3e1 100644 (file)
@@ -15,6 +15,7 @@ libbase_la_SOURCES =  \
        consolelogger.h \
        convert.cpp \
        convert.h \
+       debug.h \
        dictionary.cpp \
        dictionary.h \
        dynamicobject.cpp \
index e822895aee006a0f5d289d9cc79c24d42412af35..0b46d6b5834ee1d58456edf4f110205043bb7d70 100644 (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>
index 043f89ba1ada1d942e493c38df5bf137656d1e88..474622518bae826c7929c2efaa80105e494476fd 100644 (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>
diff --git a/lib/base/debug.h b/lib/base/debug.h
new file mode 100644 (file)
index 0000000..88d1d87
--- /dev/null
@@ -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 */
index 1c8773d2d011732036b2085d46f0b17bb197d6da..1c31693a91b429fa85b1cba50ca4c335f2cd0abd 100644 (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>
index 485cb2fe77f83256a02c65db931da2855fd78198..87aa476045f68c657de4c9d9faef32737dc6a5f9 100644 (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"
index 4f25a1961ad46876746fc046428b48579188e82a..8a607ef42aaa71c3c7ef58328f31a4fe7e28b26e 100644 (file)
@@ -18,7 +18,7 @@
  ******************************************************************************/
 
 #include "base/dynamictype.h"
-#include "base/utility.h"
+#include "base/debug.h"
 #include "base/objectlock.h"
 
 using namespace icinga;
index 9e574d444575b67fd022610349fa54476afe4fa4..ddc038d72eb6a781ad94f3a97709e049d265d7a5 100644 (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>
index ba6eab5f9b1c40961b39263f6a1ad1d9cfb35995..0be349e7b2c8296e450a04589120086eef7a947b 100644 (file)
@@ -18,7 +18,7 @@
  ******************************************************************************/
 
 #include "base/netstring.h"
-#include "base/utility.h"
+#include "base/debug.h"
 #include <sstream>
 
 using namespace icinga;
index 727585644699f8baddefa1b94e4843e3d06213a3..ea4c6a785cba855299ec8c95dc48d10c9e40fb5e 100644 (file)
@@ -18,7 +18,7 @@
  ******************************************************************************/
 
 #include "base/objectlock.h"
-#include "base/utility.h"
+#include "base/debug.h"
 
 using namespace icinga;
 
index 1cf5d0fba00191ceb6da809e574d8b519716afa6..9f82c555e951e9de45b0c323c417dda3ad4809a7 100644 (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");
 
-}
\ No newline at end of file
+}
index 4ef83f9ea375a469d7da893179c289ec7d9f4a69..6adfc8242e12ac3032d4e206484ac0e1825db8e4 100644 (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>
index 4f644a030d53038f412e2a9712ff42c4f9c226ad..e72b03d9c535e3cc3b116c75edce66ebaacb1fdc 100644 (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>
index ea20871dfac62c6dd04f386124855d11db38de40..3db044d7e0893cc6fc9ea71971e4638185af2ab1 100644 (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>
index b3f7d8e0b050c42ac29cc80754308e6678cb7fe6..128f8ea2e859b1f1317c697f2b9e4e43fb77c09f 100644 (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 */
index 4f5381a4f6b1345c01512da2305039870d0c5d79..052e7b855dec3925b113671a9b6e62f03b9b53ba 100644 (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>
index e2939747401f1884c43f06d0870e140c3639dc77..1e42fbcd2ac5478b4c28f656948f2a663522dd6f 100644 (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>
index e158f606793739ebf929054f0ea618683dbbe5af..728a52009d576fac0d11aefe4bb6e733430dd038 100644 (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>
index f59e4e1b45b22815748673f7b530e4b96d7e6900..e5bd63295ca984890fde875b94e007a83493e39b 100644 (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>
index 6166d574a314473c842bfdbed993324dfe93f968..fe0df2178f6f51a49c138f3e7c2d5648b1451358 100644 (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>
 
index 6237023d22fc0fb0837b623a78c95deb92962b48..b24f961ef3cc8a5acce07d4853bd9a34cba4682b 100644 (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>
index 835b048dd16f92d373ad423ffc850d516b954b87..3fec66868177836b01b4a8d332d3cda03b45b533 100644 (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>