Skip to contentSkip to conversation

trace: inline control-internal.h into control.h

PATCH In review Stefan Hajnoczi 2 participants 3 messages May 2, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace: inline control-internal.h into control.h

trace/control.h is the API for manipulating trace events in QEMU. Some of the implementation of this API lives in trace/control-internal.h.

Older versions of gcc complain because a static prototype is used but the function is defined static inline later on:

CC vl.o
In file included from trace/control.h:191,

                   from vl.c:165:
                   trace/control.h:77:
  warning: ‘trace_event_count’ declared inline after being called
                   trace/control.h:77:

warning: previous declaration of ‘trace_event_count’ was here

The gcc version is:

gcc (SUSE Linux) 4.3.4 [gcc-4_3-branch revision 152973]

The whole split into a public header and implementation header with static inlines seems a bit much anyway. If we want these functions to be static inline let's pay the price and put them into the header file.

Note that a few functions must be re-ordered so that they are declared before use.

---
 trace/control-internal.h | 67 ----------------------------------------
 trace/control.h          | 80 +++++++++++++++++++++++++++++++++---------------
 2 files changed, 55 insertions(+), 92 deletions(-)
 delete mode 100644 trace/control-internal.h
trace/control-internal.h deleted +0 -67
deleted file mode 100644
index cce2da4..0000000
@@ -1,67 +0,0 @@
-/*
- * Interface for configuring and controlling the state of tracing events.
- *
- * Copyright (C) 2011-2012 Lluís Vilanova <[email protected]>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#ifndef TRACE__CONTROL_INTERNAL_H
-#define TRACE__CONTROL_INTERNAL_H
-
-#include <string.h>
-
-
-extern TraceEvent trace_events[];
-
-
-static inline TraceEvent *trace_event_id(TraceEventID id)
-{
-    assert(id < trace_event_count());
-    return &trace_events[id];
-}
-
-static inline TraceEventID trace_event_count(void)
-{
-    return TRACE_EVENT_COUNT;
-}
-
-static inline bool trace_event_is_pattern(const char *str)
-{
-    assert(str != NULL);
-    return strchr(str, '*') != NULL;
-}
-
-static inline TraceEventID trace_event_get_id(TraceEvent *ev)
-{
-    assert(ev != NULL);
-    return ev->id;
-}
-
-static inline const char * trace_event_get_name(TraceEvent *ev)
-{
-    assert(ev != NULL);
-    return ev->name;
-}
-
-static inline bool trace_event_get_state_static(TraceEvent *ev)
-{
-    assert(ev != NULL);
-    return ev->sstate;
-}
-
-static inline bool trace_event_get_state_dynamic(TraceEvent *ev)
-{
-    assert(ev != NULL);
-    return ev->dstate;
-}
-
-static inline void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
-{
-    assert(ev != NULL);
-    assert(trace_event_get_state_static(ev));
-    return trace_event_set_state_dynamic_backend(ev, state);
-}
-
-#endif  /* TRACE__CONTROL_INTERNAL_H */
trace/control.h +55 -25

144 lines not on this page · raw message

Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 16 lines · Stefan Hajnoczi

trace/control.h is the API for manipulating trace events in QEMU. Some of the implementation of this API lives in trace/control-internal.h.

Older versions of gcc complain because a static prototype is used but the function is defined static inline later on:

CC vl.o
In file included from trace/control.h:191,

                   from vl.c:165:
                   trace/control.h:77:
  warning: ‘trace_event_count’ declared inline after being called
                   trace/control.h:77:

warning: previous declaration of ‘trace_event_count’ was here

The gcc version is:

Quoted 8 lines

gcc (SUSE Linux) 4.3.4 [gcc-4_3-branch revision 152973]

The whole split into a public header and implementation header with static inlines seems a bit much anyway. If we want these functions to be static inline let's pay the price and put them into the header file.

Note that a few functions must be re-ordered so that they are declared before use.

Wouldn't declaring them as "static inline" solve the compiler warning? Sorry, but I don't have such gcc version to try it.

My personal taste is that having headers only with (grouped) declarations and documentation helps improving readability and in getting to know the codebase, but feel free to merge the files.

Lluis

Signature · 4 lines
 "And it's much the same thing with knowledge, for whenever you learn
 something new, the whole world becomes that much richer."
 -- The Princess of Pure Reason, as told by Norton Juster in The Phantom
 Tollbooth
#2 lore raw
Quoted 24 lines · Lluís Vilanova
Quoted 21 lines · Stefan Hajnoczi

trace/control.h is the API for manipulating trace events in QEMU. Some of the implementation of this API lives in trace/control-internal.h.

Older versions of gcc complain because a static prototype is used but the function is defined static inline later on:

CC vl.o
In file included from trace/control.h:191,

                   from vl.c:165:
                   trace/control.h:77:
  warning: ‘trace_event_count’ declared inline after being called
                   trace/control.h:77:

warning: previous declaration of ‘trace_event_count’ was here

The gcc version is:

gcc (SUSE Linux) 4.3.4 [gcc-4_3-branch revision 152973]

The whole split into a public header and implementation header with static inlines seems a bit much anyway. If we want these functions to be static inline let's pay the price and put them into the header file.

Quoted 5 lines
Quoted 2 lines

Note that a few functions must be re-ordered so that they are declared before use.

Wouldn't declaring them as "static inline" solve the compiler warning? Sorry, but I don't have such gcc version to try it.

I don't either but maybe Andreas can check. I'm all for a smaller fix.

Stefan