qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] glib: move compat functions into glib-compat.h
@ 2014-02-03 13:31 Stefan Hajnoczi
  2014-02-03 13:31 ` [Qemu-devel] [PATCH 1/3] glib: move g_poll() replacement " Stefan Hajnoczi
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Stefan Hajnoczi @ 2014-02-03 13:31 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Anthony Liguori

glib has deprecated APIs like GStaticMutex, g_thread_create(), and others.  In
QEMU support both old and new APIs since using deprecated APIs would flood us
with warnings but legacy distros must continue to build the QEMU source code.

This patch series reduces ifdefs by moving glib compat functions into
glib-compat.h, where they can be reused.

There are two strategies for compat functions:

1. Implement the new API using the deprecated API.  This compat function is
   used when building on a legacy host.  Sometimes the API semantics are so
   different that this option is not feasible.

2. Add a new wrapper API that maps to the deprecated API.  The wrapper is not
   marked deprecated so it works as a drop-in replacement but is implemented
   using the new API where possible.

Stefan Hajnoczi (3):
  glib: move g_poll() replacement into glib-compat.h
  glib: add g_thread_new() compat function
  glib: add compat wrapper for GStaticMutex

 coroutine-gthread.c   | 26 ++++++++++----------------
 include/glib-compat.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
 include/qemu-common.h | 12 ------------
 trace/simple.c        | 31 ++++++++++---------------------
 4 files changed, 64 insertions(+), 49 deletions(-)

-- 
1.8.5.3

^ permalink raw reply	[flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 2/3] glib: add g_thread_new() compat function
@ 2014-05-02 10:52 Michael Tokarev
  2014-05-02 11:01 ` Daniel P. Berrange
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Tokarev @ 2014-05-02 10:52 UTC (permalink / raw)
  To: stefanha; +Cc: qemu-devel

Stefan Hajnoczi:
> Implement g_thread_new() in terms of the deprecated g_thread_create().
> The API was changed in glib 2.31.0.
>
> The compat function allows us to write modern code and avoid ifdefs.

ACK.  With one small nit:

[]
> +#if !GLIB_CHECK_VERSION(2, 31, 0)
> +static inline GThread *g_thread_new(const gchar *unused,
> +                                    GThreadFunc func,
> +                                    gpointer data)
> +{
> +    GThread *thread = g_thread_create(func, data, TRUE, NULL);
> +    if (!thread) {
> +        g_error("g_thread_create failed");
> +    }
> +    return thread;
> +}
> +#endif

About g_error():

"This function will result in a core dump; don't use it for errors you expect.
 Using this function indicates a bug in your program, i.e. an assertion failure."

I'm not sure if this is like an assertion failure, probably yes.  But we should
not, I think, dump core in this situation.  Is there a glib function that does
(fatal) error reporting but does NOT dump core?

In my attempt to do this, I completely ignored errors:

 https://lists.gnu.org/archive/html/qemu-devel/2014-04/msg04551.html

(search for g_thread_new() in glib-compat.h).  This is, obviously, not right,
but that's really because I was too lazy to actually find the right function
to do so.  Maybe just using some fprintf(stderr) + abort() - from classic
C library instead of glib - will do.

Thanks,

/mjt

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-05-02 12:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-03 13:31 [Qemu-devel] [PATCH 0/3] glib: move compat functions into glib-compat.h Stefan Hajnoczi
2014-02-03 13:31 ` [Qemu-devel] [PATCH 1/3] glib: move g_poll() replacement " Stefan Hajnoczi
2014-02-03 13:31 ` [Qemu-devel] [PATCH 2/3] glib: add g_thread_new() compat function Stefan Hajnoczi
2014-02-03 13:31 ` [Qemu-devel] [PATCH 3/3] glib: add compat wrapper for GStaticMutex Stefan Hajnoczi
2014-02-14 12:31 ` [Qemu-devel] [PATCH 0/3] glib: move compat functions into glib-compat.h Stefan Hajnoczi
2014-05-02  9:35 ` Stefan Hajnoczi
  -- strict thread matches above, loose matches on Subject: below --
2014-05-02 10:52 [Qemu-devel] [PATCH 2/3] glib: add g_thread_new() compat function Michael Tokarev
2014-05-02 11:01 ` Daniel P. Berrange
2014-05-02 11:08   ` Peter Maydell
2014-05-02 11:16     ` Michael Tokarev
2014-05-02 12:30     ` Michael Tokarev

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).