28.04.2014 14:19, Peter Maydell wrote: > On 27 April 2014 17:26, Michael Tokarev <m...@tls.msk.ru> wrote:
>> -static QemuMutex vevent_queue_lock; >> -static QemuCond vevent_queue_condition; >> +static GMutex vevent_queue_lock; >> +static GCond vevent_queue_condition; >> >> void vevent_queue_init(void) >> { >> - qemu_mutex_init(&vevent_queue_lock); >> - qemu_cond_init(&vevent_queue_condition); >> + g_mutex_init(&vevent_queue_lock); >> + g_cond_init(&vevent_queue_condition); >> vevent_queue_head = vevent_queue_tail = NULL; >> } > > Just to record a conversation from IRC: this won't > compile on older versions of glib, because those don't > support g_cond_init(). Conversely, if you use g_cond_new() > then newer glib will complain that it's deprecated. > trace/simple.c has an example of how you have to work > around this API churn... I've added a tiny (but hackish and fun) wrapper header for all this, and pushed whole thing into a branch on my site -- see http://git.corpit.ru/?p=qemu.git;a=shortlog;h=refs/heads/libcacard-standalone The wrapper is here: http://git.corpit.ru/?p=qemu.git;a=blob;f=libcacard/glib-compat.h;h=47fd06a43572fc5cc639fb7d705e85f3965d6b91;hb=1aeefee2a4bb2694b2314cddd04e08675360e255 It allows to use the new primitives/interface with either new (unchanged) or old (wrapped) glib cond and mutex API. I think this is better than a way used in trace/simple.c, and can be used there too, making stuff much more readable. Please note: the wrapper redifines some core symbols which are used in glib so it must come somewhere near the end of #include set. Most interesting is that it redefines GCOnd into GCond* (only for old glib). Thanks, /mjt