diff mbox

[v7,2/7] trace: Make trace_get_vcpu_event_count() inlinable

Message ID 148434050231.31446.10929552655201551997.stgit@frigg.lan
State New
Headers show

Commit Message

Lluís Vilanova Jan. 13, 2017, 8:48 p.m. UTC
Later patches will make use of it.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
 trace/control-internal.h |    7 ++++++-
 trace/control.c          |   11 +++--------
 trace/control.h          |    4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)

Comments

Richard Henderson Jan. 14, 2017, 3:30 a.m. UTC | #1
On 01/13/2017 12:48 PM, Lluís Vilanova wrote:
> uring and controlling the state of tracing events.
>   *
> - * Copyright (C) 2011-2016 Lluís Vilanova <vilanova@ac.upc.edu>
> + * Copyright (C) 2011-2017 Lluís Vilanova <vilanova@ac.upc.edu>
>   *
>   * This work is licensed under the terms of the GNU GPL, version 2 or later.
>   * See the COPYING file in the top-level directory.
> @@ -237,7 +237,7 @@ char *trace_opt_parse(const char *optarg);
>   *
>   * Return the number of known vcpu-specific events
>   */
> -uint32_t trace_get_vcpu_event_count(void);
> +static uint32_t trace_get_vcpu_event_count(void);
>

Why is this declaration still here?  It's redundant with the inline.


r~
Lluís Vilanova Jan. 15, 2017, 2 a.m. UTC | #2
Richard Henderson writes:

> On 01/13/2017 12:48 PM, Lluís Vilanova wrote:
>> uring and controlling the state of tracing events.
>> *
>> - * Copyright (C) 2011-2016 Lluís Vilanova <vilanova@ac.upc.edu>
>> + * Copyright (C) 2011-2017 Lluís Vilanova <vilanova@ac.upc.edu>
>> *
>> * This work is licensed under the terms of the GNU GPL, version 2 or later.
>> * See the COPYING file in the top-level directory.
>> @@ -237,7 +237,7 @@ char *trace_opt_parse(const char *optarg);
>> *
>> * Return the number of known vcpu-specific events
>> */
>> -uint32_t trace_get_vcpu_event_count(void);
>> +static uint32_t trace_get_vcpu_event_count(void);
>> 

> Why is this declaration still here?  It's redundant with the inline.

I can remove it if you feel strongly against it, but I kept it to maintain
consistency with the rest of the file. As I said in the previous series, this is
the style used in the header. All "public" functions (inlined or not) are
declared there with their documentation.

Being inlined is an implementation detail (inlines are defined on a separate
header), but given C's design it leaks through the static declaration.


Cheers,
  Lluis
Lluís Vilanova Jan. 29, 2017, 2:51 p.m. UTC | #3
Lluís Vilanova writes:

> Richard Henderson writes:
>> On 01/13/2017 12:48 PM, Lluís Vilanova wrote:
>>> @@ -237,7 +237,7 @@ char *trace_opt_parse(const char *optarg);
>>> *
>>> * Return the number of known vcpu-specific events
>>> */
>>> -uint32_t trace_get_vcpu_event_count(void);
>>> +static uint32_t trace_get_vcpu_event_count(void);
>>> 

>> Why is this declaration still here?  It's redundant with the inline.

> I can remove it if you feel strongly against it, but I kept it to maintain
> consistency with the rest of the file. As I said in the previous series, this is
> the style used in the header. All "public" functions (inlined or not) are
> declared there with their documentation.

> Being inlined is an implementation detail (inlines are defined on a separate
> header), but given C's design it leaks through the static declaration.

Ping.


Cheers,
  Lluis
diff mbox

Patch

diff --git a/trace/control-internal.h b/trace/control-internal.h
index a9d395a587..a8beb44847 100644
--- a/trace/control-internal.h
+++ b/trace/control-internal.h
@@ -1,7 +1,7 @@ 
 /*
  * Interface for configuring and controlling the state of tracing events.
  *
- * Copyright (C) 2011-2016 Lluís Vilanova <vilanova@ac.upc.edu>
+ * Copyright (C) 2011-2017 Lluís Vilanova <vilanova@ac.upc.edu>
  *
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
@@ -16,6 +16,7 @@ 
 
 
 extern int trace_events_enabled_count;
+extern uint32_t trace_next_vcpu_id;
 
 
 static inline bool trace_event_is_pattern(const char *str)
@@ -82,6 +83,10 @@  static inline bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu,
     return trace_event_get_vcpu_state_dynamic_by_vcpu_id(vcpu, vcpu_id);
 }
 
+static inline uint32_t trace_get_vcpu_event_count(void)
+{
+    return trace_next_vcpu_id;
+}
 
 void trace_event_register_group(TraceEvent **events);
 
diff --git a/trace/control.c b/trace/control.c
index 1a7bee6ddc..8a52c7fc39 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -1,7 +1,7 @@ 
 /*
  * Interface for configuring and controlling the state of tracing events.
  *
- * Copyright (C) 2011-2016 Lluís Vilanova <vilanova@ac.upc.edu>
+ * Copyright (C) 2011-2017 Lluís Vilanova <vilanova@ac.upc.edu>
  *
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
@@ -36,7 +36,7 @@  typedef struct TraceEventGroup {
 static TraceEventGroup *event_groups;
 static size_t nevent_groups;
 static uint32_t next_id;
-static uint32_t next_vcpu_id;
+uint32_t trace_next_vcpu_id;
 
 QemuOptsList qemu_trace_opts = {
     .name = "trace",
@@ -65,7 +65,7 @@  void trace_event_register_group(TraceEvent **events)
     for (i = 0; events[i] != NULL; i++) {
         events[i]->id = next_id++;
         if (events[i]->vcpu_id != TRACE_VCPU_EVENT_NONE) {
-            events[i]->vcpu_id = next_vcpu_id++;
+            events[i]->vcpu_id = trace_next_vcpu_id++;
         }
     }
     event_groups = g_renew(TraceEventGroup, event_groups, nevent_groups + 1);
@@ -299,8 +299,3 @@  char *trace_opt_parse(const char *optarg)
 
     return trace_file;
 }
-
-uint32_t trace_get_vcpu_event_count(void)
-{
-    return next_vcpu_id;
-}
diff --git a/trace/control.h b/trace/control.h
index ccaeac8552..6dfbc53c8d 100644
--- a/trace/control.h
+++ b/trace/control.h
@@ -1,7 +1,7 @@ 
 /*
  * Interface for configuring and controlling the state of tracing events.
  *
- * Copyright (C) 2011-2016 Lluís Vilanova <vilanova@ac.upc.edu>
+ * Copyright (C) 2011-2017 Lluís Vilanova <vilanova@ac.upc.edu>
  *
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
@@ -237,7 +237,7 @@  char *trace_opt_parse(const char *optarg);
  *
  * Return the number of known vcpu-specific events
  */
-uint32_t trace_get_vcpu_event_count(void);
+static uint32_t trace_get_vcpu_event_count(void);
 
 
 #include "trace/control-internal.h"