* [Qemu-devel] [PATCH 1/1] vl.c: don't try to insert malloc tracepoints on newer glib
@ 2015-09-04 17:58 Serge Hallyn
2015-09-04 18:11 ` Peter Maydell
0 siblings, 1 reply; 2+ messages in thread
From: Serge Hallyn @ 2015-09-04 17:58 UTC (permalink / raw)
To: QEMU Developers
Because it has deprecated it with commit
3be6ed60aa58095691bd697344765e715a327fc1. This prevents the warning
(process:3535): GLib-WARNING **: /build/glib2.0-3tdlHy/glib2.0-2.45.6/./glib/gmem.c:482: custom memory allocation vtable not supported
as reported at https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/1491972
(thanks danpb for the suggestion)
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
---
vl.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/vl.c b/vl.c
index 584ca88..cab9425 100644
--- a/vl.c
+++ b/vl.c
@@ -2719,6 +2719,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
return popt;
}
+#if ! GLIB_CHECK_VERSION(2, 44, 0)
static gpointer malloc_and_trace(gsize n_bytes)
{
void *ptr = malloc(n_bytes);
@@ -2738,6 +2739,7 @@ static void free_and_trace(gpointer mem)
trace_g_free(mem);
free(mem);
}
+#endif
static int machine_set_property(void *opaque,
const char *name, const char *value,
@@ -2966,11 +2968,13 @@ int main(int argc, char **argv, char **envp)
bool userconfig = true;
const char *log_mask = NULL;
const char *log_file = NULL;
+#if ! GLIB_CHECK_VERSION(2, 44, 0)
GMemVTable mem_trace = {
.malloc = malloc_and_trace,
.realloc = realloc_and_trace,
.free = free_and_trace,
};
+#endif
const char *trace_events = NULL;
const char *trace_file = NULL;
ram_addr_t maxram_size;
@@ -2986,7 +2990,9 @@ int main(int argc, char **argv, char **envp)
error_set_progname(argv[0]);
qemu_init_exec_dir(argv[0]);
+#if ! GLIB_CHECK_VERSION(2, 44, 0)
g_mem_set_vtable(&mem_trace);
+#endif
module_call_init(MODULE_INIT_QOM);
--
2.5.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH 1/1] vl.c: don't try to insert malloc tracepoints on newer glib
2015-09-04 17:58 [Qemu-devel] [PATCH 1/1] vl.c: don't try to insert malloc tracepoints on newer glib Serge Hallyn
@ 2015-09-04 18:11 ` Peter Maydell
0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2015-09-04 18:11 UTC (permalink / raw)
To: Serge Hallyn; +Cc: QEMU Developers
On 4 September 2015 at 18:58, Serge Hallyn <serge.hallyn@ubuntu.com> wrote:
> Because it has deprecated it with commit
> 3be6ed60aa58095691bd697344765e715a327fc1. This prevents the warning
>
> (process:3535): GLib-WARNING **: /build/glib2.0-3tdlHy/glib2.0-2.45.6/./glib/gmem.c:482: custom memory allocation vtable not supported
>
> as reported at https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/1491972
>
> (thanks danpb for the suggestion)
>
> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
> ---
> vl.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/vl.c b/vl.c
> index 584ca88..cab9425 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2719,6 +2719,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
> return popt;
> }
>
> +#if ! GLIB_CHECK_VERSION(2, 44, 0)
Existing style for these checks doesn't have a space
between the "!" and the "GLIB_CHECK_VERSION".
> static gpointer malloc_and_trace(gsize n_bytes)
> {
> void *ptr = malloc(n_bytes);
> @@ -2738,6 +2739,7 @@ static void free_and_trace(gpointer mem)
> trace_g_free(mem);
> free(mem);
> }
> +#endif
We could reduce the number of ifdefs we have to have here by
having inside this #if...
void register_glib_mem_trace_functions(void)
(with the GMemVTable and the call to g_mem_set_vtable in it),
and then having an
#else
void register_glib_mem_trace_functions(void)
{
/* Newer versions of glib don't support intercepting the
* memory allocation functions.
*/
}
#endif
Then you can make the callsite un-ifdefed.
thanks
-- PMM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-04 18:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-04 17:58 [Qemu-devel] [PATCH 1/1] vl.c: don't try to insert malloc tracepoints on newer glib Serge Hallyn
2015-09-04 18:11 ` Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).