ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
print.c
Go to the documentation of this file.
1#include "global.h"
2
3#ifndef KISSAT_QUIET
4
5#include "print.h"
6#include "colors.h"
7#include "handle.h"
8#include "internal.h"
9
10#include <inttypes.h>
11#include <stdarg.h>
12#include <string.h>
13
14static inline int verbosity (kissat *solver) {
15 if (!solver)
16 return -1;
17#ifdef LOGGING
18 if (GET_OPTION (log))
19 return 3;
20#endif
21#ifndef KISSAT_QUIET
22 if (GET_OPTION (quiet))
23 return -1;
24 return GET_OPTION (verbose);
25#else
26 return 0;
27#endif
28}
29
30void kissat_warning (kissat *solver, const char *fmt, ...) {
31 if (verbosity (solver) < 0)
32 return;
33 TERMINAL (stdout, 1);
34 fputs (solver->prefix, stdout);
36 fputs ("warning:", stdout);
37 COLOR (NORMAL);
38 fputc (' ', stdout);
39 va_list ap;
40 va_start (ap, fmt);
41 vprintf (fmt, ap);
42 va_end (ap);
43 fputc ('\n', stdout);
44#ifdef KISSAT_NOPTIONS
45 (void) solver;
46#endif
47}
48
49void kissat_signal (kissat *solver, const char *type, int sig) {
50 if (verbosity (solver) < 0)
51 return;
52 TERMINAL (stdout, 1);
53 fputs (solver->prefix, stdout);
54 COLOR (BOLD RED);
55 printf ("%s signal %d (%s)", type, sig, kissat_signal_name (sig));
56 COLOR (NORMAL);
57 fputc ('\n', stdout);
58 fflush (stdout);
59}
60
61static void print_message (kissat *solver, const char *color,
62 const char *fmt, va_list *ap) {
63 TERMINAL (stdout, 1);
64 fputs (solver->prefix, stdout);
65 COLOR (color);
66 vprintf (fmt, *ap);
67 fputc ('\n', stdout);
68 COLOR (NORMAL);
69 fflush (stdout);
70}
71
72static void print_line (kissat *solver) {
73 char ch;
74 for (const char *p = solver->prefix; (ch = *p); p++)
75 if (ch && (ch != ' ' || p[1]))
76 fputc (ch, stdout);
77 fputc ('\n', stdout);
78 fflush (stdout);
79}
80
81int kissat_verbosity (kissat *solver) { return verbosity (solver); }
82
83void kissat_message (kissat *solver, const char *fmt, ...) {
84 if (verbosity (solver) < 0)
85 return;
86 va_list ap;
87 va_start (ap, fmt);
88 print_message (solver, "", fmt, &ap);
89 va_end (ap);
90}
91
93 if (verbosity (solver) >= 0)
94 print_line (solver);
95}
96
97void kissat_prefix (kissat *solver) { fputs (solver->prefix, stdout); }
98
99void kissat_verbose (kissat *solver, const char *fmt, ...) {
100 if (verbosity (solver) < 1)
101 return;
102 va_list ap;
103 va_start (ap, fmt);
104 print_message (solver, LIGHT_GRAY, fmt, &ap);
105 va_end (ap);
106}
107
108void kissat_very_verbose (kissat *solver, const char *fmt, ...) {
109 if (verbosity (solver) < 2)
110 return;
111 va_list ap;
112 va_start (ap, fmt);
113 print_message (solver, DARK_GRAY, fmt, &ap);
114 va_end (ap);
115}
116
117void kissat_extremely_verbose (kissat *solver, const char *fmt, ...) {
118 if (verbosity (solver) < 3)
119 return;
120 va_list ap;
121 va_start (ap, fmt);
122 print_message (solver, DARK_GRAY, fmt, &ap);
123 va_end (ap);
124}
125
126void kissat_section (kissat *solver, const char *name) {
127 if (verbosity (solver) < 0)
128 return;
129 TERMINAL (stdout, 1);
130 if (solver->sectioned)
132 else
133 solver->sectioned = true;
134 fputs (solver->prefix, stdout);
135 COLOR (BLUE);
136 fputs ("---- [ ", stdout);
137 COLOR (BOLD BLUE);
138 fputs (name, stdout);
139 COLOR (NORMAL BLUE);
140 fputs (" ] ", stdout);
141 for (size_t i = strlen (name); i < 66; i++)
142 fputc ('-', stdout);
143 COLOR (NORMAL);
144 fputc ('\n', stdout);
145 print_line (solver);
146 fflush (stdout);
147}
148
149void kissat_phase (kissat *solver, const char *name, uint64_t count,
150 const char *fmt, ...) {
151 if (verbosity (solver) < 1)
152 return;
153 TERMINAL (stdout, 1);
154 fputs (solver->prefix, stdout);
155 if (solver->stable)
156 COLOR (CYAN);
157 else
158 COLOR (BOLD CYAN);
159 printf ("[%s", name);
160 if (count != UINT64_MAX)
161 printf ("-%" PRIu64, count);
162 fputs ("] ", stdout);
163 va_list ap;
164 va_start (ap, fmt);
165 vprintf (fmt, ap);
166 va_end (ap);
167 COLOR (NORMAL);
168 fputc ('\n', stdout);
169 fflush (stdout);
170}
171
172#else
174#endif
#define NORMAL
Definition colors.h:18
#define BOLD
Definition colors.h:14
#define COLOR(CODE)
Definition colors.h:41
#define BLUE
Definition colors.h:13
#define TERMINAL(F, I)
Definition colors.h:34
#define RED
Definition colors.h:19
#define LIGHT_GRAY
Definition colors.h:23
#define YELLOW
Definition colors.h:21
#define DARK_GRAY
Definition colors.h:24
#define CYAN
Definition colors.h:15
Cube * p
Definition exorList.c:222
type
CUBE COVER and CUBE typedefs ///.
Definition exor.h:90
#define vprintf
Definition fretime.h:138
#define solver
Definition kitten.c:211
char * name
Definition main.h:24
#define GET_OPTION(N)
Definition options.h:295
int kissat_print_dummy_to_avoid_warning
Definition print.c:173
#define kissat_message(...)
Definition print.h:47
#define kissat_verbose(...)
Definition print.h:51
#define kissat_line(...)
Definition print.h:46
#define kissat_extremely_verbose(...)
Definition print.h:53
#define kissat_section(...)
Definition print.h:49
#define kissat_signal(...)
Definition print.h:50
#define kissat_very_verbose(...)
Definition print.h:52
#define kissat_phase(...)
Definition print.h:48
#define kissat_warning(...)
Definition print.h:54
int strlen()