-
Notifications
You must be signed in to change notification settings - Fork 0
/
harness_trace.c
60 lines (46 loc) · 1.37 KB
/
harness_trace.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "harness/trace.h"
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
int harness_debug_level = 4;
void debug_printf(const char* fmt, const char* fn, const char* fmt2, ...) {
va_list ap;
printf(fmt, fn);
va_start(ap, fmt2);
vprintf(fmt2, ap);
va_end(ap);
puts("\033[0m");
}
void debug_print_vector3(const char* fmt, const char* fn, char* msg, br_vector3* v) {
printf(fmt, fn);
printf("%s %f, %f, %f\n", msg, v->v[0], v->v[1], v->v[2]);
puts("\033[0m");
}
void debug_print_matrix34(const char* fmt, const char* fn, char* msg, br_matrix34* m) {
printf(fmt, fn);
printf("matrix34 \"%s\"\n", msg);
for (int i = 0; i < 4; i++) {
printf(" %f, %f, %f\n", m->m[i][0], m->m[i][1], m->m[i][2]);
}
puts("\033[0m");
}
void debug_print_matrix4(const char* fmt, const char* fn, char* msg, br_matrix4* m) {
printf(fmt, fn);
printf("matrix34 \"%s\"\n", msg);
for (int i = 0; i < 4; i++) {
printf(" %f, %f, %f, %f\n", m->m[i][0], m->m[i][1], m->m[i][2], m->m[i][3]);
}
puts("\033[0m");
}
// int count_open_fds() {
// DIR* dp = opendir("/dev/fd/");
// struct dirent* de;
// int count = -3; // '.', '..', dp
// if (dp == NULL)
// return -1;
// while ((de = readdir(dp)) != NULL)
// count++;
// (void)closedir(dp);
// return count;
// }