standalone: reformat demo.c
This commit is contained in:
parent
6f483aed6c
commit
99da1974ef
|
@ -6,33 +6,19 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
double dbl_nan(void) {
|
double dbl_nan(void) { return NAN; }
|
||||||
return NAN;
|
|
||||||
}
|
|
||||||
|
|
||||||
double dbl_inf(void) {
|
double dbl_inf(void) { return INFINITY; }
|
||||||
return INFINITY;
|
|
||||||
}
|
|
||||||
|
|
||||||
void output_bool(bool x) {
|
void output_bool(bool x) { puts(x ? "True" : "False"); }
|
||||||
puts(x ? "True" : "False");
|
|
||||||
}
|
|
||||||
|
|
||||||
void output_int32(int32_t x) {
|
void output_int32(int32_t x) { printf("%" PRId32 "\n", x); }
|
||||||
printf("%"PRId32"\n", x);
|
|
||||||
}
|
|
||||||
|
|
||||||
void output_int64(int64_t x) {
|
void output_int64(int64_t x) { printf("%" PRId64 "\n", x); }
|
||||||
printf("%"PRId64"\n", x);
|
|
||||||
}
|
|
||||||
|
|
||||||
void output_uint32(uint32_t x) {
|
void output_uint32(uint32_t x) { printf("%" PRIu32 "\n", x); }
|
||||||
printf("%"PRIu32"\n", x);
|
|
||||||
}
|
|
||||||
|
|
||||||
void output_uint64(uint64_t x) {
|
void output_uint64(uint64_t x) { printf("%" PRIu64 "\n", x); }
|
||||||
printf("%"PRIu64"\n", x);
|
|
||||||
}
|
|
||||||
|
|
||||||
void output_float64(double x) {
|
void output_float64(double x) {
|
||||||
if (isnan(x)) {
|
if (isnan(x)) {
|
||||||
|
@ -99,8 +85,10 @@ uint64_t dbg_stack_address(__attribute__((unused)) struct cslice *slice) {
|
||||||
return (uintptr_t)ptr;
|
return (uintptr_t)ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t __nac3_personality(uint32_t state, uint32_t exception_object, uint32_t context) {
|
uint32_t __nac3_personality(uint32_t state, uint32_t exception_object,
|
||||||
printf("__nac3_personality(state: %u, exception_object: %u, context: %u)\n", state, exception_object, context);
|
uint32_t context) {
|
||||||
|
printf("__nac3_personality(state: %u, exception_object: %u, context: %u)\n",
|
||||||
|
state, exception_object, context);
|
||||||
exit(101);
|
exit(101);
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
@ -120,10 +108,14 @@ struct Exception {
|
||||||
uint32_t __nac3_raise(struct Exception *e) {
|
uint32_t __nac3_raise(struct Exception *e) {
|
||||||
printf("__nac3_raise called. Exception details:\n");
|
printf("__nac3_raise called. Exception details:\n");
|
||||||
printf(" ID: %" PRIu32 "\n", e->id);
|
printf(" ID: %" PRIu32 "\n", e->id);
|
||||||
printf(" Location: %*s:%"PRIu32":%"PRIu32"\n" , (int) e->file.len, (const char*) e->file.data, e->line, e->column);
|
printf(" Location: %*s:%" PRIu32 ":%" PRIu32 "\n", (int)e->file.len,
|
||||||
printf(" Function: %*s\n" , (int) e->function.len, (const char*) e->function.data);
|
(const char *)e->file.data, e->line, e->column);
|
||||||
printf(" Message: \"%*s\"\n" , (int) e->message.len, (const char*) e->message.data);
|
printf(" Function: %*s\n", (int)e->function.len,
|
||||||
printf(" Params: {0}=%"PRId64", {1}=%"PRId64", {2}=%"PRId64"\n", e->param[0], e->param[1], e->param[2]);
|
(const char *)e->function.data);
|
||||||
|
printf(" Message: \"%*s\"\n", (int)e->message.len,
|
||||||
|
(const char *)e->message.data);
|
||||||
|
printf(" Params: {0}=%" PRId64 ", {1}=%" PRId64 ", {2}=%" PRId64 "\n",
|
||||||
|
e->param[0], e->param[1], e->param[2]);
|
||||||
exit(101);
|
exit(101);
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
@ -132,6 +124,4 @@ void __nac3_end_catch(void) {}
|
||||||
|
|
||||||
extern int32_t run(void);
|
extern int32_t run(void);
|
||||||
|
|
||||||
int main(void) {
|
int main(void) { run(); }
|
||||||
run();
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue