ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
error.c
Go to the documentation of this file.
1#include "error.h"
2#include "colors.h"
3#include "cover.h"
4
5#include <stdarg.h>
6#include <stdlib.h>
7
9
10static void (*kissat_abort_function) (void);
11
13 kissat_abort_function = f;
14}
15
16// clang-format off
17
18void
20{
21 if (kissat_abort_function)
22 { FLUSH_COVERAGE (); kissat_abort_function (); } // Keep all in this line.
23 else
24 { FLUSH_COVERAGE (); abort (); } // Keep all in this line.
25}
26
27// clang-format on
28
29static void typed_error_message_start (const char *type) {
30 fflush (stdout);
31 TERMINAL (stderr, 2);
32 COLOR (BOLD);
33 fputs ("kissat: ", stderr);
34 COLOR (RED);
35 fputs (type, stderr);
36 fputs (": ", stderr);
37 COLOR (NORMAL);
38}
39
41 typed_error_message_start ("fatal error");
42}
43
44static void vprint_error (const char *type, const char *fmt, va_list *ap) {
45 typed_error_message_start (type);
46 vfprintf (stderr, fmt, *ap);
47 fputc ('\n', stderr);
48 fflush (stderr);
49}
50
51void kissat_error (const char *fmt, ...) {
52 va_list ap;
53 va_start (ap, fmt);
54 vprint_error ("error", fmt, &ap);
55 va_end (ap);
56}
57
58void kissat_fatal (const char *fmt, ...) {
59 va_list ap;
60 va_start (ap, fmt);
61 vprint_error ("fatal error", fmt, &ap);
62 va_end (ap);
63 kissat_abort ();
64}
65
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define NORMAL
Definition colors.h:18
#define BOLD
Definition colors.h:14
#define COLOR(CODE)
Definition colors.h:41
#define TERMINAL(F, I)
Definition colors.h:34
#define RED
Definition colors.h:19
#define FLUSH_COVERAGE()
Definition cover.h:26
void kissat_call_function_instead_of_abort(void(*f)(void))
Definition error.c:12
void kissat_fatal_message_start(void)
Definition error.c:40
void kissat_abort(void)
Definition error.c:19
void kissat_fatal(const char *fmt,...)
Definition error.c:58
void kissat_error(const char *fmt,...)
Definition error.c:51
type
CUBE COVER and CUBE typedefs ///.
Definition exor.h:90
VOID_HACK abort()