forked from arminbiere/gimsatul
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogging.h
184 lines (158 loc) · 4.36 KB
/
logging.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#ifndef _logging_h_INCLUDED
#define _logging_h_INCLUDED
#ifdef LOGGING
#include "message.h"
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
struct ring;
struct ruler;
extern bool ignore_values_and_levels_during_logging;
const char *loglit (struct ring *, unsigned lit);
const char *logvar (struct ring *, unsigned idx);
const char *roglit (struct ruler *, unsigned lit);
const char *rogvar (struct ruler *, unsigned idx);
#define LOGLIT(...) loglit (ring, __VA_ARGS__)
#define LOGVAR(...) logvar (ring, __VA_ARGS__)
#define ROGLIT(...) roglit (ruler, __VA_ARGS__)
#define ROGVAR(...) rogvar (ruler, __VA_ARGS__)
#define LOGPREFIX(...) \
if (verbosity < INT_MAX) \
break; \
acquire_message_lock (); \
printf (prefix_format, ring->id); \
printf ("LOG %u ", ring->level); \
printf (__VA_ARGS__)
#define LOGSUFFIX() \
fputc ('\n', stdout); \
fflush (stdout); \
release_message_lock ()
#define LOG(...) \
do { \
LOGPREFIX (__VA_ARGS__); \
LOGSUFFIX (); \
} while (0)
#define LOGTMP(...) \
do { \
LOGPREFIX (__VA_ARGS__); \
printf (" size %zu temporary clause", SIZE (ring->clause)); \
for (all_elements_on_stack (unsigned, LIT, ring->clause)) \
printf (" %s", LOGLIT (LIT)); \
LOGSUFFIX (); \
} while (0)
#define LOGBINARY(REDUNDANT, LIT, OTHER, ...) \
do { \
LOGPREFIX (__VA_ARGS__); \
if ((REDUNDANT)) \
printf (" redundant"); \
else \
printf (" irredundant"); \
printf (" binary clause %s %s", LOGLIT (LIT), LOGLIT (OTHER)); \
LOGSUFFIX (); \
} while (0)
#define LOGCLAUSE(CLAUSE, ...) \
do { \
if (is_binary_pointer (CLAUSE)) { \
bool REDUNDANT = redundant_pointer (CLAUSE); \
unsigned LIT = lit_pointer (CLAUSE); \
unsigned OTHER = other_pointer (CLAUSE); \
LOGBINARY (REDUNDANT, LIT, OTHER, __VA_ARGS__); \
} else { \
LOGPREFIX (__VA_ARGS__); \
if ((CLAUSE)->garbage) \
printf (" garbage"); \
if ((CLAUSE)->redundant) \
printf (" redundant glue %u", (CLAUSE)->glue); \
else \
printf (" irredundant"); \
printf (" size %u clause[%" PRIu64 "]", (CLAUSE)->size, \
(uint64_t) (CLAUSE)->id); \
for (all_literals_in_clause (LIT, (CLAUSE))) \
printf (" %s", LOGLIT (LIT)); \
LOGSUFFIX (); \
} \
} while (0)
#define LOGWATCH(WATCH, ...) \
do { \
if (is_binary_pointer (WATCH)) { \
unsigned LIT = lit_pointer (WATCH); \
unsigned OTHER = other_pointer (WATCH); \
bool REDUNDANT = redundant_pointer (WATCH); \
LOGBINARY (REDUNDANT, LIT, OTHER, __VA_ARGS__); \
} else \
LOGCLAUSE (get_clause (ring, WATCH), __VA_ARGS__); \
} while (0)
#define ROGPREFIX(...) \
if (verbosity < INT_MAX) \
break; \
acquire_message_lock (); \
printf ("c LOG - "); \
printf (__VA_ARGS__)
#define ROGSUFFIX LOGSUFFIX
#define ROG(...) \
do { \
ROGPREFIX (__VA_ARGS__); \
ROGSUFFIX (); \
} while (0)
#define LOG(...) \
do { \
LOGPREFIX (__VA_ARGS__); \
LOGSUFFIX (); \
} while (0)
#define ROGBINARY(LIT, OTHER, ...) \
do { \
ROGPREFIX (__VA_ARGS__); \
printf (" irredundant"); \
printf (" binary clause %s %s", ROGLIT (LIT), ROGLIT (OTHER)); \
ROGSUFFIX (); \
} while (0)
#define ROGCLAUSE(CLAUSE, ...) \
do { \
if (is_binary_pointer (CLAUSE)) { \
assert (!redundant_pointer (CLAUSE)); \
unsigned LIT = lit_pointer (CLAUSE); \
unsigned OTHER = other_pointer (CLAUSE); \
ROGBINARY (LIT, OTHER, __VA_ARGS__); \
} else { \
ROGPREFIX (__VA_ARGS__); \
if ((CLAUSE)->garbage) \
printf (" garbage"); \
if ((CLAUSE)->redundant) \
printf (" redundant glue %u", (CLAUSE)->glue); \
else \
printf (" irredundant"); \
printf (" size %u clause[%" PRIu64 "]", (CLAUSE)->size, \
(uint64_t) (CLAUSE)->id); \
for (all_literals_in_clause (LIT, (CLAUSE))) \
printf (" %s", ROGLIT (LIT)); \
ROGSUFFIX (); \
} \
} while (0)
#else
#define LOG(...) \
do { \
} while (0)
#define LOGTMP(...) \
do { \
} while (0)
#define LOGBINARY(...) \
do { \
} while (0)
#define LOGCLAUSE(...) \
do { \
} while (0)
#define LOGWATCH(...) \
do { \
} while (0)
#define ROG(...) \
do { \
} while (0)
#define ROGBINARY(...) \
do { \
} while (0)
#define ROGCLAUSE(...) \
do { \
} while (0)
#endif
#endif