aboutsummaryrefslogtreecommitdiffstats
path: root/trace.h
blob: f59b9fa436657e01d8c2bbd7bd75a46beac5fc25 (plain)
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
#ifndef TRACE_H
#define TRACE_H

#include "compiler.h"

extern FILE *tracef;

enum tracing {
    TRACE_NONE = 0x00,
    TRACE_CPU = 0x01,
    TRACE_IO = 0x02,
    TRACE_DISK = 0x04,
    TRACE_CAS = 0x08,
    TRACE_PR = 0x10,
    TRACE_FLASH = 0x20,
    TRACE_ALL = 0x1f
};

extern enum tracing traceflags;

static inline bool tracing(enum tracing flags)
{
    return unlikely(traceflags & flags);
}

extern void
trace_dump_data(const char *prefix, const void *data, unsigned int l);

static inline void
trace_dump(enum tracing flags, const char *prefix, const void *data, size_t l)
{
    if (tracing(flags))
        trace_dump_data(prefix, data, l);
}

#endif /* TRACE_H */