]> www.ginac.de Git - ginac.git/blobdiff - ginac/polynomial/debug.h
Renamed files *.tcc and *.hpp to *.h.
[ginac.git] / ginac / polynomial / debug.h
diff --git a/ginac/polynomial/debug.h b/ginac/polynomial/debug.h
new file mode 100644 (file)
index 0000000..48659fd
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef GINAC_MOD_GCD_DEBUG_HPP
+#define GINAC_MOD_GCD_DEBUG_HPP
+#include <iostream>
+#include <string>
+#include <stdexcept>
+#include <sstream>
+#include "compiler.h"
+
+#define DEBUG_PREFIX __func__ << ':' << __LINE__ << ": "
+#define EXCEPTION_PREFIX std::string(__func__) + std::string(": ") +
+
+#define Dout2(stream, msg) \
+do {                                                                   \
+       stream << DEBUG_PREFIX << msg << std::endl << std::flush;       \
+} while (0)
+#define Dout(msg) Dout2(std::cout, msg)
+
+#define bug3_on(condition, the_exception, msg)                         \
+do {                                                                   \
+       if (unlikely(condition)) {                                      \
+               std::ostringstream err_stream;                          \
+               Dout2(err_stream, "BUG: " << msg);                      \
+               throw the_exception(err_stream.str());                  \
+       }                                                               \
+} while (0)
+
+#define bug_on(condition, msg) bug3_on(condition, std::logic_error, msg)
+
+#endif // GINAC_MOD_GCD_DEBUG_HPP
+