-
Notifications
You must be signed in to change notification settings - Fork 3
/
message.h
79 lines (61 loc) · 1.48 KB
/
message.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
#ifndef _messages_h_INCLUDED
#define _messages_h_INCLUDED
#include <stdint.h>
#include <unistd.h>
void die (const char *, ...) __attribute__ ((format (printf, 1, 2)));
void fatal_error (const char *, ...)
__attribute__ ((format (printf, 1, 2)));
#ifdef QUIET
static const int verbosity = -1;
#define acquire_message_lock() \
do { \
} while (0)
#define release_message_lock() \
do { \
} while (0)
#define message(...) \
do { \
} while (0)
#define verbose(...) \
do { \
} while (0)
#define very_verbose(...) \
do { \
} while (0)
#define extremely_verbose(...) \
do { \
} while (0)
#else
extern int verbosity;
extern const char *prefix_format;
#ifdef LOGGING
#include <stdatomic.h>
// clang-format off
extern _Atomic (uint64_t) clause_ids;
// clang-format on
#endif
void acquire_message_lock (void);
void release_message_lock (void);
struct ring;
ssize_t print_line_without_acquiring_lock (struct ring *, const char *, ...)
__attribute__ ((format (printf, 2, 3)));
void message (struct ring *ring, const char *, ...)
__attribute__ ((format (printf, 2, 3)));
#define PRINTLN(...) print_line_without_acquiring_lock (ring, __VA_ARGS__)
#define verbose(...) \
do { \
if (verbosity > 1) \
message (__VA_ARGS__); \
} while (0)
#define very_verbose(...) \
do { \
if (verbosity > 2) \
message (__VA_ARGS__); \
} while (0)
#define extremely_verbose(...) \
do { \
if (verbosity > 3) \
message (__VA_ARGS__); \
} while (0)
#endif
#endif