00001
00028 #ifndef GALOIS_RUNTIME_LL_GIO_H
00029 #define GALOIS_RUNTIME_LL_GIO_H
00030
00031 #include <sstream>
00032 #include <cerrno>
00033
00034
00035
00036 namespace Galois {
00037 namespace Runtime {
00038 namespace LL {
00039
00041 void gPrintStr(const std::string&);
00043 void gInfoStr(const std::string&);
00045 void gWarnStr(const std::string&);
00047 void gDebugStr(const std::string&);
00049 void gErrorStr(const std::string&);
00050
00052 template<typename T>
00053 bool toString(std::ostringstream& os, const T& val) { os << val; return true; }
00054
00056 template<typename... Args>
00057 void gPrint(Args... args) {
00058 std::ostringstream os;
00059 __attribute__((unused)) bool tmp[] = {toString(os, args)...};
00060 gPrintStr(os.str());
00061 }
00062
00064 template<typename... Args>
00065 void gInfo(Args... args) {
00066 std::ostringstream os;
00067 __attribute__((unused)) bool tmp[] = {toString(os, args)...};
00068 gInfoStr(os.str());
00069 }
00070
00072 template<typename... Args>
00073 void gWarn(Args... args) {
00074 std::ostringstream os;
00075 __attribute__((unused)) bool tmp[] = {toString(os, args)...};
00076 gWarnStr(os.str());
00077 }
00078
00081 template<typename... Args>
00082 void gDebug(Args... args) {
00083 #ifndef NDEBUG
00084 std::ostringstream os;
00085 __attribute__((unused)) bool tmp[] = {toString(os, args)...};
00086 gDebugStr(os.str());
00087 #endif
00088 }
00089
00091 template<typename... Args>
00092 void gError(Args... args) {
00093 std::ostringstream os;
00094 __attribute__((unused)) bool tmp[] = {toString(os, args)...};
00095 gErrorStr(os.str());
00096 }
00097
00098 void gFlush();
00099
00100 #define GALOIS_SYS_ERROR(...) do { Galois::Runtime::LL::gError(__FILE__, ":", __LINE__, ": ", strerror(errno), ": ", ##__VA_ARGS__); } while (0)
00101 #define GALOIS_ERROR(...) do { Galois::Runtime::LL::gError(__FILE__, ":", __LINE__, ": ", ##__VA_ARGS__); } while (0)
00102 #define GALOIS_SYS_DIE(...) do { Galois::Runtime::LL::gError(__FILE__, ":", __LINE__, ": ", strerror(errno), ": ", ##__VA_ARGS__); abort(); } while (0)
00103 #define GALOIS_DIE(...) do { Galois::Runtime::LL::gError(__FILE__, ":", __LINE__, ": ", ##__VA_ARGS__); abort(); } while (0)
00104
00105 }
00106 }
00107 }
00108
00109 #endif //_GIO_H