qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/3] glib: add g_thread_new() compat function


From: Michael Tokarev
Subject: [Qemu-devel] [PATCH 2/3] glib: add g_thread_new() compat function
Date: Fri, 02 May 2014 14:52:23 +0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.4.0

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]