qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 2/7] Enable I/O thread and VNC threads by defaul


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 2/7] Enable I/O thread and VNC threads by default
Date: Thu, 10 Feb 2011 10:54:06 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

On 02/09/2011 11:16 PM, Stefan Weil wrote:
The patch is available here:
http://repo.or.cz/w/qemu/ar7.git/commitdiff/aabf11dc0a938b84d76d7c147cbf0445d7bee297

diff --git a/hosts/w32/include/signal.h b/hosts/w32/include/signal.h
new file mode 100644
index 0000000..e45f03c
--- /dev/null
+++ b/hosts/w32/include/signal.h
@@ -0,0 +1,20 @@
+/*
+ * QEMU w32 support
+ *
+ * Copyright (C) 2011 Stefan Weil
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef WIN32_SIGNAL_H
+#define WIN32_SIGNAL_H
+
+#include_next <signal.h>
+#include <sys/types.h>    /* sigset_t */
+
+int pthread_sigmask(int how, const sigset_t *set, sigset_t *oldset);
+int sigfillset(sigset_t *set);
+
+#endif /* WIN32_SIGNAL_H */
diff --git a/hosts/w32/include/time.h b/hosts/w32/include/time.h
new file mode 100644
index 0000000..0b997d3
--- /dev/null
+++ b/hosts/w32/include/time.h
@@ -0,0 +1,31 @@
+/*
+ * QEMU w32 support
+ *
+ * Copyright (C) 2011 Stefan Weil
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#if !defined(W32_TIME_H)
+#define W32_TIME_H
+
+#include_next <time.h>
+
+#ifndef HAVE_STRUCT_TIMESPEC
+#define HAVE_STRUCT_TIMESPEC 1
+struct timespec {
+        long tv_sec;
+        long tv_nsec;
+};
+#endif /* HAVE_STRUCT_TIMESPEC */
+
+typedef enum {
+  CLOCK_REALTIME = 0
+} clockid_t;
+
+int clock_getres (clockid_t clock_id, struct timespec *res);
+int clock_gettime(clockid_t clock_id, struct timespec *pTimespec);
+
+#endif /* W32_TIME_H */
diff --git a/os-win32.c b/os-win32.c
index b214e6a..7778366 100644
--- a/os-win32.c
+++ b/os-win32.c
@@ -36,6 +36,45 @@
 /***********************************************************/
 /* Functions missing in mingw */

+#if defined(CONFIG_THREAD)
+
+int clock_gettime(clockid_t clock_id, struct timespec *pTimespec)
+{
+  int result = 0;
+  if (clock_id == CLOCK_REALTIME && pTimespec != 0) {
+    DWORD t = GetTickCount();
+    const unsigned cps = 1000;
+    struct timespec ts;
+    ts.tv_sec  = t / cps;
+    ts.tv_nsec = (t % cps) * (1000000000UL / cps);
+    *pTimespec = ts;
+  } else {
+    errno = EINVAL;
+    result = -1;
+  }
+  return result;
+}

Why is this needed? The only user of clock_gettime in the POSIX case is using CLOCK_MONOTONIC, and actually has a Win32 version already.

+int pthread_sigmask(int how, const sigset_t *set, sigset_t *oldset)
+{
+    /* Dummy, do nothing. */
+    return EINVAL;
+}
+
+int sigfillset(sigset_t *set)
+{
+    int result = 0;
+    if (set) {
+        *(set) = (sigset_t)(-1);
+    } else {
+        errno = EINVAL;
+        result = -1;
+    }
+    return result;
+}

Instead of these, it's better to provide a Win32 implementation of mutexes and condvars. I'll submit it next week hopefully.

Paolo



reply via email to

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