24 #define SCAMAC_ESHIFT 6 25 #define SCAMAC_EMASK ((1U << SCAMAC_ESHIFT) - 1) 69 SCAMAC_EINTERNAL = (1U << (2*SCAMAC_ESHIFT))
75 typedef void (*scamac_error_handler_ft)(void);
76 extern scamac_error_handler_ft scamac_error_handler;
81 #define SCAMAC_ASSERT(err) \ 85 #define SCAMAC_APPROVE(exp) \ 92 #define SCAMAC_ASSERT(expr) \ 95 fprintf(stderr, "\n*************\n*** ABORT ***\n*************\n%s\n\nassertion in function >%s< at line %d failed.\n\n", \ 96 __FILE__, __func__, __LINE__); \ 97 fprintf(stderr,"%s\n",#expr); \ 98 fprintf(stderr,"* * * * * * *\n\naborted\n"); \ 99 if (scamac_error_handler) { \ 100 scamac_error_handler(); \ 102 exit(EXIT_FAILURE); \ 107 #define SCAMAC_APPROVE(cmd) \ 109 ScamacErrorCode unique_142b176e_err; \ 110 unique_142b176e_err = cmd; \ 112 fprintf(stderr, "\n*************\n*** ABORT ***\n*************\n%s\n\nin function >%s< at line %d\n\n>%s< failed with\n\n", \ 113 __FILE__, __func__, __LINE__, #cmd); \ 114 fprintf(stderr,"%s%s\n",scamac_error_desc(unique_142b176e_err),scamac_error_dpar(unique_142b176e_err)); \ 115 fprintf(stderr,"* * * * * * *\n\naborted\n"); \ 116 if (scamac_error_handler) { \ 117 scamac_error_handler(); \ 119 exit(EXIT_FAILURE); \ 127 #define SCAMAC_CHKERR(err) \ 130 fprintf(stderr, "\n*************\n*** ABORT ***\n*************\n%s\n\nfunction >%s< at line %d failed with\n\n", \ 131 __FILE__, __func__, __LINE__); \ 132 fprintf(stderr,"%s%s\n",scamac_error_desc(err),scamac_error_dpar(err)); \ 133 fprintf(stderr,"* * * * * * *\n\naborted\n"); \ 134 if (scamac_error_handler) { \ 135 scamac_error_handler(); \ 137 exit(EXIT_FAILURE); \ 142 #define SCAMAC_TRY(exp) \ 144 ScamacErrorCode unique_142b176e_err; \ 145 unique_142b176e_err = exp; \ 146 if (unique_142b176e_err) { \ 147 fprintf(stderr, "\n*************\n*** ABORT ***\n*************\n%s\n\nin function >%s< at line %d\n\n>%s< failed with\n\n", \ 148 __FILE__, __func__, __LINE__, #exp); \ 149 fprintf(stderr,"%s%s\n",scamac_error_desc(unique_142b176e_err),scamac_error_dpar(unique_142b176e_err)); \ 150 fprintf(stderr,"* * * * * * *\n\naborted\n"); \ 151 if (scamac_error_handler) { \ 152 scamac_error_handler(); \ 154 exit(EXIT_FAILURE); \ 161 #define SCAMAC_RETERR(err) \ 164 return scamac_error_set_internal(err); \ 168 #define SCAMAC_GOTOERR(err, label) \ 171 err=scamac_error_set_internal(err); \ 179 #define SCAMAC_RETERR(err) \ 182 fprintf(stderr, "\n*************\n*** ERROR ***\n*************\n%s\n\nfunction >%s< at line %d encountered an error\n\n", \ 183 __FILE__, __func__, __LINE__); \ 184 fprintf(stderr,"%s%s\n* * * * * * *\n\n",scamac_error_desc(err),scamac_error_dpar(err)); \ 185 return scamac_error_set_internal(err); \ 189 #define SCAMAC_GOTOERR(err, label) \ 192 fprintf(stderr, "\n*************\n*** ERROR ***\n*************\n%s\n\nfunction >%s< at line %d encountered an error\n\n", \ 193 __FILE__, __func__, __LINE__); \ 194 fprintf(stderr,"%s%s\n* * * * * * *\n\n",scamac_error_desc(err),scamac_error_dpar(err)); \ 195 err=scamac_error_set_internal(err); \ 204 #define SCAMAC_REPORT(str) \ 210 #define SCAMAC_REPORT(str) \ 212 fprintf(stderr, "-- report >%s< line %d: %s\n",__func__, __LINE__,str); \ 218 #define SCAMAC_LOG(...) \ 222 #define SCAMAC_LOG(...) \ 224 fprintf(stderr, ">%s : %d<\n ", __func__, __LINE__); \ 225 fprintf(stderr, __VA_ARGS__); \ 226 fprintf(stderr, "\n"); \ 234 int scamac_error_par (ScamacErrorCode err);
235 const char * scamac_error_dpar(ScamacErrorCode err);
237 ScamacErrorCode scamac_error_discard_warning(ScamacErrorCode err);
239 ScamacErrorCode scamac_error_set_internal(ScamacErrorCode err);
240 ScamacErrorCode scamac_error_set_par(ScamacErrorCode err,
int par);
241 bool scamac_error_is(ScamacErrorCode err1, ScamacErrorCode err2);
const char * scamac_error_desc(ScamacErrorCode err)
Return error name.