Mercurial > molko
comparison libcore/core/panic.c @ 229:e71039d820a7
doc: improve documentation
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 19 Nov 2020 16:46:26 +0100 |
parents | aab824406d3d |
children | 76afe639fd72 |
comparison
equal
deleted
inserted
replaced
228:2734223d3daf | 229:e71039d820a7 |
---|---|
21 #include <stdlib.h> | 21 #include <stdlib.h> |
22 | 22 |
23 #include "error.h" | 23 #include "error.h" |
24 #include "panic.h" | 24 #include "panic.h" |
25 | 25 |
26 static noreturn void | 26 static void |
27 terminate(void) | 27 terminate(void) |
28 { | 28 { |
29 fprintf(stderr, "abort: %s\n", error()); | 29 fprintf(stderr, "abort: %s\n", error()); |
30 abort(); | 30 abort(); |
31 exit(1); | 31 exit(1); |
32 } | 32 } |
33 | 33 |
34 void (*panic_handler)(void) = terminate; | 34 void (*panic_handler)(void) = terminate; |
35 | 35 |
36 noreturn void | 36 void |
37 panicf(const char *fmt, ...) | 37 panicf(const char *fmt, ...) |
38 { | 38 { |
39 assert(fmt); | 39 assert(fmt); |
40 | 40 |
41 va_list ap; | 41 va_list ap; |
49 va_end(ap); | 49 va_end(ap); |
50 | 50 |
51 panic(); | 51 panic(); |
52 } | 52 } |
53 | 53 |
54 noreturn void | 54 void |
55 vpanicf(const char *fmt, va_list ap) | 55 vpanicf(const char *fmt, va_list ap) |
56 { | 56 { |
57 assert(fmt); | 57 assert(fmt); |
58 assert(panic_handler); | 58 assert(panic_handler); |
59 | 59 |
60 verrorf(fmt, ap); | 60 verrorf(fmt, ap); |
61 panic(); | 61 panic(); |
62 } | 62 } |
63 | 63 |
64 noreturn void | 64 void |
65 panic(void) | 65 panic(void) |
66 { | 66 { |
67 assert(panic_handler); | 67 assert(panic_handler); |
68 | 68 |
69 panic_handler(); | 69 panic_handler(); |