forked from dschoerk/GPU_Arch_SS19
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.cpp
More file actions
72 lines (61 loc) · 989 Bytes
/
utils.cpp
File metadata and controls
72 lines (61 loc) · 989 Bytes
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
#include "utils.h"
#include <cstdio>
#include <cstring>
#ifdef DEBUG
void trace(
const char *fmt,
...
)
{
if (verbose)
{
va_list ap;
va_start(ap, fmt);
if (vfprintf(stdout, fmt, ap) < 0)
{
ERROR("Cannot write to trace stream");
}
va_end(ap);
if (fflush(stdout) == EOF)
{
ERROR("Cannot flush trace stream");
}
}
}
#endif // DEBUG
#ifndef __linux__
void error_at_line(
int status,
int errnum,
const char *filename,
unsigned int linenum,
const char *fmt,
...
)
{
va_list ap;
va_start(ap, fmt);
(void) fprintf(
stderr,
"%s:%s:%d: ",
program_invocation_name,
filename,
linenum
);
(void) vfprintf(stderr, fmt, ap);
va_end(ap);
if (errnum != 0)
{
(void) fprintf(
stderr,
": %s",
strerror(errnum)
);
}
(void) fputs("\n", stderr);
if (status != EXIT_SUCCESS)
{
exit(status);
}
}
#endif