17#ifndef ETISS_INCLUDE_RETURNCODE_H_
18#define ETISS_INCLUDE_RETURNCODE_H_
20#include "etiss/jit/types.h"
36extern std::map<etiss::int32, const char *> &getErrorMessages();
41extern std::map<etiss::int32, const char *> &getErrorNames();
43extern int32_t setTemporary(
const std::string &msg);
56#define etiss__toString_(X) #X
57#define etiss_toString(X) etiss__toString_(X)
60#define etiss__merge2_(X, Y) X##Y
61#define etiss_merge2(X, Y) etiss__merge2_(X, Y)
68#ifdef ETISS_RETURNCODE_REGISTRATION_BODY
70#define defineReturnCodeClass_(UNIQUENUMBER, NAME, VALUE, MSG) \
71 static class ReturnCodeRegistration_##UNIQUENUMBER \
74 ReturnCodeRegistration_##UNIQUENUMBER() \
76 auto entry = etiss::RETURNCODE::getErrorNames().find(VALUE); \
77 if (entry != etiss::RETURNCODE::getErrorNames().end()) \
79 if (std::string(entry->second) != etiss_toString(NAME)) \
81 std::stringstream ss; \
82 ss << "Duplicated RETURNCODE " << VALUE << ": "; \
83 ss << etiss::RETURNCODE::getErrorNames().find(VALUE)->second << "," << etiss_toString(NAME); \
84 etiss::log(etiss::ERROR, ss.str()); \
87 etiss::RETURNCODE::getErrorMessages()[VALUE] = MSG; \
88 etiss::RETURNCODE::getErrorNames()[VALUE] = etiss_toString(NAME); \
90 } returnCodeRegistration_##UNIQUENUMBER
92#define defineReturnCodeClass(UNIQUENUMBER, NAME, VALUE, MSG) defineReturnCodeClass_(UNIQUENUMBER, NAME, VALUE, MSG)
94#define defineReturnCode(NAME, VALUE, MSG) \
97 namespace RETURNCODE \
99 static const etiss::int32 NAME = VALUE; \
102 static const etiss_int32 etiss_merge2(ETISS_RETURNCODE_, NAME) = VALUE; \
103 defineReturnCodeClass(__COUNTER__, NAME, VALUE, MSG)
105#define defineReturnCode(NAME, VALUE, MSG) \
108 namespace RETURNCODE \
110 static const etiss::int32 NAME = VALUE; \
113 static const etiss_int32 ETISS_RETURNCODE_##NAME = VALUE
116#define defineReturnCode(NAME, VALUE, MSG) static const etiss_int32 ETISS_RETURNCODE_##NAME = VALUE
129defineReturnCode(RELOADCURRENTBLOCK, -3,
"Clear the cached block that returned this code.");
143 "Has the same effect as NOERROR but allows exiting a block where NOERROR "
144 "would have continued block execution.");
149 "Finished cpu execution. This is the proper way to exit from "
150 "etiss::CPUCore::execute.");
152 "Terminates cpu execution. this is the proper way to force an "
153 "exit from etiss::CPUCore::execute (e.g. by a debugger).");
159 "An ETISS_System structure doesn't contain "
160 "the neccessary function pointers.");
169#define ETISS_RETURNCODE_TEMPORARY_COUNT 8
general configuration and logging
static __inline__ int32_t
int32_t etiss_returncode_setTemporary(const char *msg)
sets the message of a temporary return code and returns the returncode.
#define defineReturnCode(NAME, VALUE, MSG)
define RETURNCODE definition template for easy use with c and c++