2015-07-27 10:46:43 +08:00
|
|
|
#ifndef __ARTIQ_PERSONALITY_H
|
|
|
|
#define __ARTIQ_PERSONALITY_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2015-08-02 11:34:11 +08:00
|
|
|
#include <stddef.h>
|
2015-07-27 10:46:43 +08:00
|
|
|
|
|
|
|
struct artiq_exception {
|
|
|
|
union {
|
2015-07-27 14:10:20 +08:00
|
|
|
uintptr_t typeinfo;
|
2015-07-27 10:46:43 +08:00
|
|
|
const char *name;
|
|
|
|
};
|
|
|
|
const char *file;
|
|
|
|
int32_t line;
|
|
|
|
int32_t column;
|
2015-08-08 21:01:08 +08:00
|
|
|
const char *function;
|
2015-07-27 10:46:43 +08:00
|
|
|
const char *message;
|
|
|
|
int64_t param[3];
|
|
|
|
};
|
|
|
|
|
2015-07-27 18:48:42 +08:00
|
|
|
struct artiq_backtrace_item {
|
|
|
|
intptr_t function;
|
|
|
|
intptr_t offset;
|
|
|
|
};
|
|
|
|
|
2015-07-27 10:46:43 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-07-27 17:36:21 +08:00
|
|
|
/* Provided by the runtime */
|
|
|
|
void __artiq_raise(struct artiq_exception *artiq_exn)
|
|
|
|
__attribute__((noreturn));
|
2015-08-02 11:34:11 +08:00
|
|
|
void __artiq_reraise(void)
|
2015-07-27 10:46:43 +08:00
|
|
|
__attribute__((noreturn));
|
|
|
|
|
2015-07-27 18:56:18 +08:00
|
|
|
#define artiq_raise_from_c(exnname, exnmsg, exnparam0, exnparam1, exnparam2) \
|
|
|
|
do { \
|
|
|
|
struct artiq_exception exn = { \
|
|
|
|
.name = exnname, \
|
|
|
|
.message = exnmsg, \
|
|
|
|
.param = { exnparam0, exnparam1, exnparam2 }, \
|
|
|
|
.file = __FILE__, \
|
|
|
|
.line = __LINE__, \
|
2015-08-11 00:26:00 +08:00
|
|
|
.column = -1, \
|
|
|
|
.function = __func__, \
|
2015-07-27 18:56:18 +08:00
|
|
|
}; \
|
|
|
|
__artiq_raise(&exn); \
|
|
|
|
} while(0)
|
|
|
|
|
2015-07-27 17:36:21 +08:00
|
|
|
/* Called by the runtime */
|
2015-07-27 18:48:42 +08:00
|
|
|
void __artiq_terminate(struct artiq_exception *artiq_exn,
|
|
|
|
struct artiq_backtrace_item *backtrace,
|
|
|
|
size_t backtrace_size)
|
2015-07-27 17:36:21 +08:00
|
|
|
__attribute__((noreturn));
|
2015-07-27 10:46:43 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __ARTIQ_PERSONALITY_H */
|