Skip to contentSkip to conversation

[7237] qemu: mutex/thread/cond wrappers and configure tweaks ( Marcelo Tosatti)

Qemu-devel Anthony Liguori 2 participants 3 messages Apr 24, 2009 – Apr 28, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

Revision: 7237

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=7237
Author:   aliguori
Date:     2009-04-24 18:03:15 +0000 (Fri, 24 Apr 2009)

Log Message:
-----------
qemu: mutex/thread/cond wrappers and configure tweaks (Marcelo Tosatti)

Modified Paths:
--------------
trunk/Makefile
trunk/Makefile.target
trunk/configure

Added Paths:
-----------
trunk/qemu-thread.c
trunk/qemu-thread.h

Modified: trunk/Makefile
===================================================================

Makefile +6 -1
@@ -30,7 +30,8 @@
 DOCS=
 endif
 
-LIBS+=$(AIOLIBS)
+LIBS+=$(PTHREADLIBS)
+LIBS+=$(CLOCKLIBS)
 
 ifdef CONFIG_SOLARIS
 LIBS+=-lsocket -lnsl -lresolv
@@ -170,6 +171,10 @@
 OBJS+=cocoa.o
 endif
 
+ifdef CONFIG_IOTHREAD
+OBJS+=qemu-thread.o
+endif
+
 ifdef CONFIG_SLIRP
 CPPFLAGS+=-I$(SRC_PATH)/slirp
 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \

Modified: trunk/Makefile.target
===================================================================

Makefile.target +4 -2
@@ -318,7 +318,8 @@
 
 OBJS= main.o syscall.o strace.o mmap.o signal.o path.o thunk.o \
       elfload.o linuxload.o uaccess.o envlist.o
-LIBS+= $(AIOLIBS)
+LIBS+= $(PTHREADLIBS)
+LIBS+= $(CLOCKLIBS)
 ifdef TARGET_HAS_BFLT
 OBJS+= flatload.o
 endif
@@ -694,7 +695,8 @@
 CPPFLAGS+=-I$(SRC_PATH)/slirp
 endif
 
-LIBS+=$(AIOLIBS)
+LIBS+=$(PTHREADLIBS)
+LIBS+=$(CLOCKLIBS)
 # specific flags are needed for non soft mmu emulator
 ifdef CONFIG_STATIC
 LDFLAGS+=-static

Modified: trunk/configure
===================================================================

configure +30 -11

106 lines not on this page · raw message

Added: trunk/qemu-thread.c
===================================================================

qemu-thread.c +163 -0

163 lines not on this page · raw message

Added: trunk/qemu-thread.h
===================================================================

qemu-thread.h +40 -0
@@ -0,0 +1,40 @@
+#ifndef __QEMU_THREAD_H
+#define __QEMU_THREAD_H 1
+#include "semaphore.h"
+#include "pthread.h"
+
+struct QemuMutex {
+    pthread_mutex_t lock;
+};
+
+struct QemuCond {
+    pthread_cond_t cond;
+};
+
+struct QemuThread {
+    pthread_t thread;
+};
+
+typedef struct QemuMutex QemuMutex;
+typedef struct QemuCond QemuCond;
+typedef struct QemuThread QemuThread;
+
+void qemu_mutex_init(QemuMutex *mutex);
+void qemu_mutex_lock(QemuMutex *mutex);
+int qemu_mutex_trylock(QemuMutex *mutex);
+int qemu_mutex_timedlock(QemuMutex *mutex, uint64_t msecs);
+void qemu_mutex_unlock(QemuMutex *mutex);
+
+void qemu_cond_init(QemuCond *cond);
+void qemu_cond_signal(QemuCond *cond);
+void qemu_cond_broadcast(QemuCond *cond);
+void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex);
+int qemu_cond_timedwait(QemuCond *cond, QemuMutex *mutex, uint64_t msecs);
+
+void qemu_thread_create(QemuThread *thread,
+                       void *(*start_routine)(void*),
+                       void *arg);
+void qemu_thread_signal(QemuThread *thread, int sig);
+void qemu_thread_self(QemuThread *thread);
+int qemu_thread_equal(QemuThread *thread1, QemuThread *thread2);
+#endif
#1 lore raw
Quoted 4 lines · Anthony Liguori

Added Paths:
-----------
    trunk/qemu-thread.c
    trunk/qemu-thread.h

Having both these and qemu-lock.h seems wrong.

Paul

#2 lore raw
Quoted 10 lines · Paul Brook
Quoted 5 lines · Anthony Liguori

Added Paths:
-----------
trunk/qemu-thread.c
trunk/qemu-thread.h

Having both these and qemu-lock.h seems wrong.

And since they're pthread specific, they are poorly named. It'll be refactored soon.

Regards,

Anthony Liguori

Quoted 2 lines

Paul