-
Notifications
You must be signed in to change notification settings - Fork 3
/
file.c
36 lines (32 loc) · 903 Bytes
/
file.c
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
#include "file.h"
#include "message.h"
#include "stack.h"
#include <assert.h>
#include <inttypes.h>
#include <stdatomic.h>
#include <stdio.h>
void write_buffer (struct buffer *buffer, struct file *file) {
assert (file);
if (file->lock)
acquire_message_lock ();
size_t size = SIZE (*buffer);
fwrite (buffer->begin, size, 1, file->file);
if (file->lock)
release_message_lock ();
CLEAR (*buffer);
atomic_fetch_add (&file->lines, 1);
}
void close_proof (struct file *proof) {
if (!proof->file)
return;
if (proof->close) {
fclose (proof->file);
if (verbosity >= 0)
printf ("c\nc closed '%s' after writing %" PRIu64 " proof lines\n",
proof->path, proof->lines);
} else if (verbosity >= 0)
printf ("c\nc finished writing %" PRIu64 " proof lines to '%s'\n",
proof->lines, proof->path);
if (verbosity >= 0)
fflush (stdout);
}