]> git.proxmox.com Git - mirror_qemu.git/blame - trace/control-internal.h
Clean up decorations and whitespace around header guards
[mirror_qemu.git] / trace / control-internal.h
CommitLineData
b1bae816
LV
1/*
2 * Interface for configuring and controlling the state of tracing events.
3 *
5b808275 4 * Copyright (C) 2011-2014 Lluís Vilanova <vilanova@ac.upc.edu>
b1bae816
LV
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */
9
10#ifndef TRACE__CONTROL_INTERNAL_H
11#define TRACE__CONTROL_INTERNAL_H
12
b1bae816 13extern TraceEvent trace_events[];
585ec727 14extern bool trace_events_dstate[];
43b48cfc 15extern int trace_events_enabled_count;
b1bae816
LV
16
17
84f3fe1b 18static inline TraceEventID trace_event_count(void)
b1bae816 19{
84f3fe1b 20 return TRACE_EVENT_COUNT;
b1bae816
LV
21}
22
84f3fe1b 23static inline TraceEvent *trace_event_id(TraceEventID id)
b1bae816 24{
84f3fe1b
PM
25 assert(id < trace_event_count());
26 return &trace_events[id];
b1bae816
LV
27}
28
29static inline bool trace_event_is_pattern(const char *str)
30{
31 assert(str != NULL);
32 return strchr(str, '*') != NULL;
33}
34
35static inline TraceEventID trace_event_get_id(TraceEvent *ev)
36{
37 assert(ev != NULL);
38 return ev->id;
39}
40
41static inline const char * trace_event_get_name(TraceEvent *ev)
42{
43 assert(ev != NULL);
44 return ev->name;
45}
46
47static inline bool trace_event_get_state_static(TraceEvent *ev)
48{
49 assert(ev != NULL);
50 return ev->sstate;
51}
52
585ec727
PB
53static inline bool trace_event_get_state_dynamic_by_id(int id)
54{
55 return unlikely(trace_events_enabled_count) && trace_events_dstate[id];
56}
57
b1bae816
LV
58static inline bool trace_event_get_state_dynamic(TraceEvent *ev)
59{
585ec727
PB
60 int id = trace_event_get_id(ev);
61 return trace_event_get_state_dynamic_by_id(id);
b1bae816
LV
62}
63
64static inline void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
65{
585ec727 66 int id = trace_event_get_id(ev);
b1bae816
LV
67 assert(ev != NULL);
68 assert(trace_event_get_state_static(ev));
585ec727
PB
69 trace_events_enabled_count += state - trace_events_dstate[id];
70 trace_events_dstate[id] = state;
b1bae816
LV
71}
72
175de524 73#endif /* TRACE__CONTROL_INTERNAL_H */