libcacard: replace qemu thread primitives with glib ones

Replace QemuMutex with GMutex and QemuCond with GCond
(with corresponding function changes), to make libcacard
independent of qemu internal functions.

After this step, none of libcacard internals use any
qemu-provided symbols.  Maybe it's a good idea to
stop including qemu-common.h internally too.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Alon Levy <alevy@redhat.com>
Tested-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Michael Tokarev 2014-05-08 12:30:48 +04:00 committed by Paolo Bonzini
parent 2a0c46da96
commit fd25c0e6dd
3 changed files with 19 additions and 30 deletions

View file

@ -6,7 +6,6 @@
*/
#include "qemu-common.h"
#include "qemu/thread.h"
#include "vcard.h"
#include "vreader.h"
@ -43,13 +42,11 @@ vevent_delete(VEvent *vevent)
static VEvent *vevent_queue_head;
static VEvent *vevent_queue_tail;
static QemuMutex vevent_queue_lock;
static QemuCond vevent_queue_condition;
static CompatGMutex vevent_queue_lock;
static CompatGCond vevent_queue_condition;
void vevent_queue_init(void)
{
qemu_mutex_init(&vevent_queue_lock);
qemu_cond_init(&vevent_queue_condition);
vevent_queue_head = vevent_queue_tail = NULL;
}
@ -57,7 +54,7 @@ void
vevent_queue_vevent(VEvent *vevent)
{
vevent->next = NULL;
qemu_mutex_lock(&vevent_queue_lock);
g_mutex_lock(&vevent_queue_lock);
if (vevent_queue_head) {
assert(vevent_queue_tail);
vevent_queue_tail->next = vevent;
@ -65,8 +62,8 @@ vevent_queue_vevent(VEvent *vevent)
vevent_queue_head = vevent;
}
vevent_queue_tail = vevent;
qemu_cond_signal(&vevent_queue_condition);
qemu_mutex_unlock(&vevent_queue_lock);
g_cond_signal(&vevent_queue_condition);
g_mutex_unlock(&vevent_queue_lock);
}
/* must have lock */
@ -86,11 +83,11 @@ VEvent *vevent_wait_next_vevent(void)
{
VEvent *vevent;
qemu_mutex_lock(&vevent_queue_lock);
g_mutex_lock(&vevent_queue_lock);
while ((vevent = vevent_dequeue_vevent()) == NULL) {
qemu_cond_wait(&vevent_queue_condition, &vevent_queue_lock);
g_cond_wait(&vevent_queue_condition, &vevent_queue_lock);
}
qemu_mutex_unlock(&vevent_queue_lock);
g_mutex_unlock(&vevent_queue_lock);
return vevent;
}
@ -98,9 +95,9 @@ VEvent *vevent_get_next_vevent(void)
{
VEvent *vevent;
qemu_mutex_lock(&vevent_queue_lock);
g_mutex_lock(&vevent_queue_lock);
vevent = vevent_dequeue_vevent();
qemu_mutex_unlock(&vevent_queue_lock);
g_mutex_unlock(&vevent_queue_lock);
return vevent;
}