-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.h
More file actions
42 lines (32 loc) · 917 Bytes
/
debug.h
File metadata and controls
42 lines (32 loc) · 917 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
/** Utils of debugging: messages and helper functions */
#ifndef LOCK_DEBUG
# define LOCK_DEBUG
# define __debug_mm_headers(...)
# ifdef DEBUG
# include "mem/mgr.h"
# include <stdio.h>
# include <unistd.h>
# define __debug(...) \
__VA_ARGS__
# define __debug_msg(msg) \
fputs(msg "\n", stderr)
# define __debug_byt(byt) \
write(STDERR_FILENO, byt, sizeof(byt)/sizeof(*byt) - 1)
# define __debug_bytsz(byt, n) \
write(STDERR_FILENO, byt, n)
# define __debug_fmt(msg, ...) \
fprintf(stderr, msg "\n", __VA_ARGS__)
struct mm_header* mm_header_of(void* mem);
# ifdef DEBUG_MM
# undef __debug_mm_headers
void
__debug_mm_headers(char* msg, struct mm_header* header);
# endif
# else
# define __debug(...)
# define __debug_msg(x)
# define __debug_byt(x)
# define __debug_bytsz(x, y)
# define __debug_fmt(x, ...)
# endif
#endif