qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/9] Re-factor osdep code + macro and brace fixes
@ 2010-10-15 14:05 Jes.Sorensen
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 1/9] Move QEMU OS dependant library functions to OS specific files Jes.Sorensen
                   ` (9 more replies)
  0 siblings, 10 replies; 19+ messages in thread
From: Jes.Sorensen @ 2010-10-15 14:05 UTC (permalink / raw)
  To: qemu-devel

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Hi,

Here is another set of patches which tries to split up osdep.c further
into posix and win32 versions. It introduces os-{posix,win32}-lib.c
files which are used for functions that are OS specific core library
functionality, like gettimeofday(), and which is used by both QEMU and
support applications like qemu-img. Other functions are moved to
os-{posix,win32}.c. In addtion there are a couple of minor fixes for
bad macro names.

In some cases braces were added to code when it was moved, to make it
compliant with the QEMU bracing rules.

Cheers,
Jes


Jes Sorensen (9):
  Move QEMU OS dependant library functions to OS specific files
  Move osdep socket code to os-{posix,win32}-lib.c
  qemu_pipe() is used only by POSIX code, so move to os-posix-lib.c
  We only support eventfd under POSIX, move qemu_eventfd() to
    os-posix.c
  Move qemu_gettimeofday() to OS specific files
  Do not redefine reserved key-words TRUE/FALSE
  Separate qemu_pidfile() into OS specific versions
  Consolidate oom_check() functions
  Remove unncessary includes

 Makefile           |    6 +-
 Makefile.objs      |    9 ++-
 hw/bt-sdp.c        |   21 +++--
 os-posix-lib.c     |  111 +++++++++++++++++++++++
 os-posix.c         |   53 +++++++++++
 os-win32-lib.c     |  128 ++++++++++++++++++++++++++
 os-win32.c         |   24 +++++
 osdep.c            |  256 ----------------------------------------------------
 osdep.h            |   15 ---
 posix-aio-compat.c |    1 +
 qemu-common.h      |    1 +
 qemu-img.c         |    1 +
 qemu-malloc.c      |   14 +---
 qemu-os-posix.h    |    3 +
 qemu-os-win32.h    |    9 ++
 qemu-tool.c        |    1 +
 16 files changed, 357 insertions(+), 296 deletions(-)
 create mode 100644 os-posix-lib.c
 create mode 100644 os-win32-lib.c

-- 
1.7.2.3

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 1/9] Move QEMU OS dependant library functions to OS specific files
  2010-10-15 14:05 [Qemu-devel] [PATCH 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
@ 2010-10-15 14:05 ` Jes.Sorensen
  2010-10-15 20:07   ` Blue Swirl
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 2/9] Move osdep socket code to os-{posix, win32}-lib.c Jes.Sorensen
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 19+ messages in thread
From: Jes.Sorensen @ 2010-10-15 14:05 UTC (permalink / raw)
  To: qemu-devel

From: Jes Sorensen <Jes.Sorensen@redhat.com>

This moves library functions used by both QEMU and the QEMU tools,
such as qemu-img, qemu-nbd etc. from osdep.c to os-{posix,win32}-lib.c

In addition it introduces oslib-obj.y to the Makefile set to be
included by the various targets, instead of relying on these library
functions magically getting included via block-obj-y.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 Makefile       |    6 ++--
 Makefile.objs  |    9 ++++++-
 os-posix-lib.c |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++
 os-win32-lib.c |   71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 osdep.c        |   70 -------------------------------------------------------
 5 files changed, 147 insertions(+), 74 deletions(-)
 create mode 100644 os-posix-lib.c
 create mode 100644 os-win32-lib.c

diff --git a/Makefile b/Makefile
index 252c817..0b3751d 100644
--- a/Makefile
+++ b/Makefile
@@ -129,11 +129,11 @@ version-obj-$(CONFIG_WIN32) += version.o
 qemu-img.o: qemu-img-cmds.h
 qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o: $(GENERATED_HEADERS)
 
-qemu-img$(EXESUF): qemu-img.o qemu-tool.o qemu-error.o $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y)
+qemu-img$(EXESUF): qemu-img.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y)
 
-qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o qemu-error.o $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y)
+qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y)
 
-qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y)
+qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y)
 
 qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
 	$(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@,"  GEN   $@")
diff --git a/Makefile.objs b/Makefile.objs
index 816194a..4281ae8 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -5,10 +5,16 @@ qobject-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o
 qobject-obj-y += qerror.o
 
 #######################################################################
+# os-obj-y is code depending on the OS (win32 vs posix)
+oslib-obj-y = osdep.o
+oslib-obj-$(CONFIG_WIN32) += os-win32-lib.o
+oslib-obj-$(CONFIG_POSIX) += os-posix-lib.o
+
+#######################################################################
 # block-obj-y is code used by both qemu system emulation and qemu-img
 
 block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o
-block-obj-y += nbd.o block.o aio.o aes.o osdep.o qemu-config.o
+block-obj-y += nbd.o block.o aio.o aes.o qemu-config.o
 block-obj-$(CONFIG_POSIX) += posix-aio-compat.o
 block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 
@@ -50,6 +56,7 @@ common-obj-y += $(net-obj-y)
 common-obj-y += $(qobject-obj-y)
 common-obj-$(CONFIG_LINUX) += $(fsdev-obj-$(CONFIG_LINUX))
 common-obj-y += readline.o console.o cursor.o async.o qemu-error.o
+common-obj-y += $(oslib-obj-y)
 common-obj-$(CONFIG_WIN32) += os-win32.o
 common-obj-$(CONFIG_POSIX) += os-posix.o
 
diff --git a/os-posix-lib.c b/os-posix-lib.c
new file mode 100644
index 0000000..83e5101
--- /dev/null
+++ b/os-posix-lib.c
@@ -0,0 +1,65 @@
+/*
+ * os-posix-lib.c
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * QEMU library functions on POSIX which are shared between QEMU and
+ * the QEMU tools.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "config-host.h"
+#include "sysemu.h"
+#include "trace.h"
+#include "net/slirp.h"
+#include "qemu-options.h"
+
+void *qemu_memalign(size_t alignment, size_t size)
+{
+    void *ptr;
+#if defined(_POSIX_C_SOURCE) && !defined(__sun__)
+    int ret;
+    ret = posix_memalign(&ptr, alignment, size);
+    if (ret != 0) {
+        fprintf(stderr, "Failed to allocate %zu B: %s\n",
+                size, strerror(ret));
+        abort();
+    }
+#elif defined(CONFIG_BSD)
+    ptr = oom_check(valloc(size));
+#else
+    ptr = oom_check(memalign(alignment, size));
+#endif
+    trace_qemu_memalign(alignment, size, ptr);
+    return ptr;
+}
+
+/* alloc shared memory pages */
+void *qemu_vmalloc(size_t size)
+{
+    return qemu_memalign(getpagesize(), size);
+}
+
+void qemu_vfree(void *ptr)
+{
+    trace_qemu_vfree(ptr);
+    free(ptr);
+}
diff --git a/os-win32-lib.c b/os-win32-lib.c
new file mode 100644
index 0000000..80e713a
--- /dev/null
+++ b/os-win32-lib.c
@@ -0,0 +1,71 @@
+/*
+ * os-win32.c
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * QEMU library functions for win32 which are shared between QEMU and
+ * the QEMU tools.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include <windows.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <time.h>
+#include <errno.h>
+#include <sys/time.h>
+#include "config-host.h"
+#include "sysemu.h"
+#include "trace.h"
+#include "qemu-options.h"
+
+void *qemu_memalign(size_t alignment, size_t size)
+{
+    void *ptr;
+
+    if (!size) {
+        abort();
+    }
+    ptr = oom_check(VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE));
+    trace_qemu_memalign(alignment, size, ptr);
+    return ptr;
+}
+
+void *qemu_vmalloc(size_t size)
+{
+    void *ptr;
+
+    /* FIXME: this is not exactly optimal solution since VirtualAlloc
+       has 64Kb granularity, but at least it guarantees us that the
+       memory is page aligned. */
+    if (!size) {
+        abort();
+    }
+    ptr = oom_check(VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE));
+    trace_qemu_vmalloc(size, ptr);
+    return ptr;
+}
+
+void qemu_vfree(void *ptr)
+{
+    trace_qemu_vfree(ptr);
+    VirtualFree(ptr, 0, MEM_RELEASE);
+}
diff --git a/osdep.c b/osdep.c
index 2e05b21..785fa4d 100644
--- a/osdep.c
+++ b/osdep.c
@@ -76,76 +76,6 @@ static void *oom_check(void *ptr)
 }
 #endif
 
-#if defined(_WIN32)
-void *qemu_memalign(size_t alignment, size_t size)
-{
-    void *ptr;
-
-    if (!size) {
-        abort();
-    }
-    ptr = oom_check(VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE));
-    trace_qemu_memalign(alignment, size, ptr);
-    return ptr;
-}
-
-void *qemu_vmalloc(size_t size)
-{
-    void *ptr;
-
-    /* FIXME: this is not exactly optimal solution since VirtualAlloc
-       has 64Kb granularity, but at least it guarantees us that the
-       memory is page aligned. */
-    if (!size) {
-        abort();
-    }
-    ptr = oom_check(VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE));
-    trace_qemu_vmalloc(size, ptr);
-    return ptr;
-}
-
-void qemu_vfree(void *ptr)
-{
-    trace_qemu_vfree(ptr);
-    VirtualFree(ptr, 0, MEM_RELEASE);
-}
-
-#else
-
-void *qemu_memalign(size_t alignment, size_t size)
-{
-    void *ptr;
-#if defined(_POSIX_C_SOURCE) && !defined(__sun__)
-    int ret;
-    ret = posix_memalign(&ptr, alignment, size);
-    if (ret != 0) {
-        fprintf(stderr, "Failed to allocate %zu B: %s\n",
-                size, strerror(ret));
-        abort();
-    }
-#elif defined(CONFIG_BSD)
-    ptr = oom_check(valloc(size));
-#else
-    ptr = oom_check(memalign(alignment, size));
-#endif
-    trace_qemu_memalign(alignment, size, ptr);
-    return ptr;
-}
-
-/* alloc shared memory pages */
-void *qemu_vmalloc(size_t size)
-{
-    return qemu_memalign(getpagesize(), size);
-}
-
-void qemu_vfree(void *ptr)
-{
-    trace_qemu_vfree(ptr);
-    free(ptr);
-}
-
-#endif
-
 int qemu_madvise(void *addr, size_t len, int advice)
 {
     if (advice == QEMU_MADV_INVALID) {
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 2/9] Move osdep socket code to os-{posix, win32}-lib.c
  2010-10-15 14:05 [Qemu-devel] [PATCH 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 1/9] Move QEMU OS dependant library functions to OS specific files Jes.Sorensen
@ 2010-10-15 14:05 ` Jes.Sorensen
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 3/9] qemu_pipe() is used only by POSIX code, so move to os-posix-lib.c Jes.Sorensen
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Jes.Sorensen @ 2010-10-15 14:05 UTC (permalink / raw)
  To: qemu-devel

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 os-posix-lib.c |   15 +++++++++++++++
 os-win32-lib.c |   21 +++++++++++++++++++++
 osdep.c        |   38 --------------------------------------
 3 files changed, 36 insertions(+), 38 deletions(-)

diff --git a/os-posix-lib.c b/os-posix-lib.c
index 83e5101..79f9bac 100644
--- a/os-posix-lib.c
+++ b/os-posix-lib.c
@@ -31,6 +31,7 @@
 #include "trace.h"
 #include "net/slirp.h"
 #include "qemu-options.h"
+#include "qemu_socket.h"
 
 void *qemu_memalign(size_t alignment, size_t size)
 {
@@ -63,3 +64,17 @@ void qemu_vfree(void *ptr)
     trace_qemu_vfree(ptr);
     free(ptr);
 }
+
+void socket_set_nonblock(int fd)
+{
+    int f;
+    f = fcntl(fd, F_GETFL);
+    fcntl(fd, F_SETFL, f | O_NONBLOCK);
+}
+
+void qemu_set_cloexec(int fd)
+{
+    int f;
+    f = fcntl(fd, F_GETFD);
+    fcntl(fd, F_SETFD, f | FD_CLOEXEC);
+}
diff --git a/os-win32-lib.c b/os-win32-lib.c
index 80e713a..e7419e5 100644
--- a/os-win32-lib.c
+++ b/os-win32-lib.c
@@ -36,6 +36,7 @@
 #include "sysemu.h"
 #include "trace.h"
 #include "qemu-options.h"
+#include "qemu_socket.h"
 
 void *qemu_memalign(size_t alignment, size_t size)
 {
@@ -69,3 +70,23 @@ void qemu_vfree(void *ptr)
     trace_qemu_vfree(ptr);
     VirtualFree(ptr, 0, MEM_RELEASE);
 }
+
+void socket_set_nonblock(int fd)
+{
+    unsigned long opt = 1;
+    ioctlsocket(fd, FIONBIO, &opt);
+}
+
+int inet_aton(const char *cp, struct in_addr *ia)
+{
+    uint32_t addr = inet_addr(cp);
+    if (addr == 0xffffffff) {
+	return 0;
+    }
+    ia->s_addr = addr;
+    return 1;
+}
+
+void qemu_set_cloexec(int fd)
+{
+}
diff --git a/osdep.c b/osdep.c
index 785fa4d..bc95bdd 100644
--- a/osdep.c
+++ b/osdep.c
@@ -162,44 +162,6 @@ int qemu_gettimeofday(qemu_timeval *tp)
 #endif /* _WIN32 */
 
 
-#ifdef _WIN32
-void socket_set_nonblock(int fd)
-{
-    unsigned long opt = 1;
-    ioctlsocket(fd, FIONBIO, &opt);
-}
-
-int inet_aton(const char *cp, struct in_addr *ia)
-{
-    uint32_t addr = inet_addr(cp);
-    if (addr == 0xffffffff)
-	return 0;
-    ia->s_addr = addr;
-    return 1;
-}
-
-void qemu_set_cloexec(int fd)
-{
-}
-
-#else
-
-void socket_set_nonblock(int fd)
-{
-    int f;
-    f = fcntl(fd, F_GETFL);
-    fcntl(fd, F_SETFL, f | O_NONBLOCK);
-}
-
-void qemu_set_cloexec(int fd)
-{
-    int f;
-    f = fcntl(fd, F_GETFD);
-    fcntl(fd, F_SETFD, f | FD_CLOEXEC);
-}
-
-#endif
-
 /*
  * Opens a file with FD_CLOEXEC set
  */
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 3/9] qemu_pipe() is used only by POSIX code, so move to os-posix-lib.c
  2010-10-15 14:05 [Qemu-devel] [PATCH 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 1/9] Move QEMU OS dependant library functions to OS specific files Jes.Sorensen
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 2/9] Move osdep socket code to os-{posix, win32}-lib.c Jes.Sorensen
@ 2010-10-15 14:05 ` Jes.Sorensen
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 4/9] We only support eventfd under POSIX, move qemu_eventfd() to os-posix.c Jes.Sorensen
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Jes.Sorensen @ 2010-10-15 14:05 UTC (permalink / raw)
  To: qemu-devel

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 os-posix-lib.c |   22 ++++++++++++++++++++++
 osdep.c        |   22 ----------------------
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/os-posix-lib.c b/os-posix-lib.c
index 79f9bac..773e998 100644
--- a/os-posix-lib.c
+++ b/os-posix-lib.c
@@ -78,3 +78,25 @@ void qemu_set_cloexec(int fd)
     f = fcntl(fd, F_GETFD);
     fcntl(fd, F_SETFD, f | FD_CLOEXEC);
 }
+
+/*
+ * Creates a pipe with FD_CLOEXEC set on both file descriptors
+ */
+int qemu_pipe(int pipefd[2])
+{
+    int ret;
+
+#ifdef CONFIG_PIPE2
+    ret = pipe2(pipefd, O_CLOEXEC);
+    if (ret != -1 || errno != ENOSYS) {
+        return ret;
+    }
+#endif
+    ret = pipe(pipefd);
+    if (ret == 0) {
+        qemu_set_cloexec(pipefd[0]);
+        qemu_set_cloexec(pipefd[1]);
+    }
+
+    return ret;
+}
diff --git a/osdep.c b/osdep.c
index bc95bdd..0019238 100644
--- a/osdep.c
+++ b/osdep.c
@@ -250,28 +250,6 @@ int qemu_eventfd(int fds[2])
 
     return qemu_pipe(fds);
 }
-
-/*
- * Creates a pipe with FD_CLOEXEC set on both file descriptors
- */
-int qemu_pipe(int pipefd[2])
-{
-    int ret;
-
-#ifdef CONFIG_PIPE2
-    ret = pipe2(pipefd, O_CLOEXEC);
-    if (ret != -1 || errno != ENOSYS) {
-        return ret;
-    }
-#endif
-    ret = pipe(pipefd);
-    if (ret == 0) {
-        qemu_set_cloexec(pipefd[0]);
-        qemu_set_cloexec(pipefd[1]);
-    }
-
-    return ret;
-}
 #endif
 
 /*
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 4/9] We only support eventfd under POSIX, move qemu_eventfd() to os-posix.c
  2010-10-15 14:05 [Qemu-devel] [PATCH 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
                   ` (2 preceding siblings ...)
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 3/9] qemu_pipe() is used only by POSIX code, so move to os-posix-lib.c Jes.Sorensen
@ 2010-10-15 14:05 ` Jes.Sorensen
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files Jes.Sorensen
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Jes.Sorensen @ 2010-10-15 14:05 UTC (permalink / raw)
  To: qemu-devel

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 os-posix.c |   32 ++++++++++++++++++++++++++++++++
 osdep.c    |   34 ----------------------------------
 2 files changed, 32 insertions(+), 34 deletions(-)

diff --git a/os-posix.c b/os-posix.c
index 6321e99..612b641 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -43,6 +43,10 @@
 #include <sys/prctl.h>
 #endif
 
+#ifdef CONFIG_EVENTFD
+#include <sys/eventfd.h>
+#endif
+
 static struct passwd *user_pwd;
 static const char *chroot_dir;
 static int daemonize;
@@ -329,3 +333,31 @@ void os_set_line_buffering(void)
 {
     setvbuf(stdout, NULL, _IOLBF, 0);
 }
+
+/*
+ * Creates an eventfd that looks like a pipe and has EFD_CLOEXEC set.
+ */
+int qemu_eventfd(int fds[2])
+{
+#ifdef CONFIG_EVENTFD
+    int ret;
+
+    ret = eventfd(0, 0);
+    if (ret >= 0) {
+        fds[0] = ret;
+        qemu_set_cloexec(ret);
+        if ((fds[1] = dup(ret)) == -1) {
+            close(ret);
+            return -1;
+        }
+        qemu_set_cloexec(fds[1]);
+        return 0;
+    }
+
+    if (errno != ENOSYS) {
+        return -1;
+    }
+#endif
+
+    return qemu_pipe(fds);
+}
diff --git a/osdep.c b/osdep.c
index 0019238..695c460 100644
--- a/osdep.c
+++ b/osdep.c
@@ -44,10 +44,6 @@
 extern int madvise(caddr_t, size_t, int);
 #endif
 
-#ifdef CONFIG_EVENTFD
-#include <sys/eventfd.h>
-#endif
-
 #ifdef _WIN32
 #include <windows.h>
 #elif defined(CONFIG_BSD)
@@ -222,36 +218,6 @@ ssize_t qemu_write_full(int fd, const void *buf, size_t count)
     return total;
 }
 
-#ifndef _WIN32
-/*
- * Creates an eventfd that looks like a pipe and has EFD_CLOEXEC set.
- */
-int qemu_eventfd(int fds[2])
-{
-#ifdef CONFIG_EVENTFD
-    int ret;
-
-    ret = eventfd(0, 0);
-    if (ret >= 0) {
-        fds[0] = ret;
-        qemu_set_cloexec(ret);
-        if ((fds[1] = dup(ret)) == -1) {
-            close(ret);
-            return -1;
-        }
-        qemu_set_cloexec(fds[1]);
-        return 0;
-    }
-
-    if (errno != ENOSYS) {
-        return -1;
-    }
-#endif
-
-    return qemu_pipe(fds);
-}
-#endif
-
 /*
  * Opens a socket with FD_CLOEXEC set
  */
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files
  2010-10-15 14:05 [Qemu-devel] [PATCH 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
                   ` (3 preceding siblings ...)
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 4/9] We only support eventfd under POSIX, move qemu_eventfd() to os-posix.c Jes.Sorensen
@ 2010-10-15 14:05 ` Jes.Sorensen
  2010-10-15 16:39   ` [Qemu-devel] " Paolo Bonzini
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 6/9] Do not redefine reserved key-words TRUE/FALSE Jes.Sorensen
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 19+ messages in thread
From: Jes.Sorensen @ 2010-10-15 14:05 UTC (permalink / raw)
  To: qemu-devel

From: Jes Sorensen <Jes.Sorensen@redhat.com>

In addition add sysemu.h includes to file requiring a prototype for
ffs()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 hw/bt-sdp.c        |    1 +
 os-win32-lib.c     |   27 +++++++++++++++++++++++++++
 osdep.c            |   31 -------------------------------
 osdep.h            |   15 ---------------
 posix-aio-compat.c |    1 +
 qemu-img.c         |    1 +
 qemu-os-posix.h    |    3 +++
 qemu-os-win32.h    |    9 +++++++++
 qemu-tool.c        |    1 +
 9 files changed, 43 insertions(+), 46 deletions(-)

diff --git a/hw/bt-sdp.c b/hw/bt-sdp.c
index cc0bf2f..6344da2 100644
--- a/hw/bt-sdp.c
+++ b/hw/bt-sdp.c
@@ -19,6 +19,7 @@
 
 #include "qemu-common.h"
 #include "bt.h"
+#include "sysemu.h"
 
 struct bt_l2cap_sdp_state_s {
     struct bt_l2cap_conn_params_s *channel;
diff --git a/os-win32-lib.c b/os-win32-lib.c
index e7419e5..b5b6def 100644
--- a/os-win32-lib.c
+++ b/os-win32-lib.c
@@ -90,3 +90,30 @@ int inet_aton(const char *cp, struct in_addr *ia)
 void qemu_set_cloexec(int fd)
 {
 }
+
+/* mingw32 needs ffs for compilations without optimization. */
+int ffs(int i)
+{
+    /* Use gcc's builtin ffs. */
+    return __builtin_ffs(i);
+}
+
+/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
+#define _W32_FT_OFFSET (116444736000000000ULL)
+
+int qemu_gettimeofday(qemu_timeval *tp)
+{
+  union {
+    unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */
+    FILETIME ft;
+  }  _now;
+
+  if(tp) {
+      GetSystemTimeAsFileTime (&_now.ft);
+      tp->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL );
+      tp->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL);
+  }
+  /* Always return 0 as per Open Group Base Specifications Issue 6.
+     Do not set errno on error.  */
+  return 0;
+}
diff --git a/osdep.c b/osdep.c
index 695c460..4b6b246 100644
--- a/osdep.c
+++ b/osdep.c
@@ -126,37 +126,6 @@ int qemu_create_pidfile(const char *filename)
     return 0;
 }
 
-#ifdef _WIN32
-
-/* mingw32 needs ffs for compilations without optimization. */
-int ffs(int i)
-{
-    /* Use gcc's builtin ffs. */
-    return __builtin_ffs(i);
-}
-
-/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
-#define _W32_FT_OFFSET (116444736000000000ULL)
-
-int qemu_gettimeofday(qemu_timeval *tp)
-{
-  union {
-    unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */
-    FILETIME ft;
-  }  _now;
-
-  if(tp)
-    {
-      GetSystemTimeAsFileTime (&_now.ft);
-      tp->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL );
-      tp->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL);
-    }
-  /* Always return 0 as per Open Group Base Specifications Issue 6.
-     Do not set errno on error.  */
-  return 0;
-}
-#endif /* _WIN32 */
-
 
 /*
  * Opens a file with FD_CLOEXEC set
diff --git a/osdep.h b/osdep.h
index 6716281..8bd30d7 100644
--- a/osdep.h
+++ b/osdep.h
@@ -127,19 +127,4 @@ int qemu_madvise(void *addr, size_t len, int advice);
 
 int qemu_create_pidfile(const char *filename);
 
-#ifdef _WIN32
-int ffs(int i);
-
-int setenv(const char *name, const char *value, int overwrite);
-
-typedef struct {
-    long tv_sec;
-    long tv_usec;
-} qemu_timeval;
-int qemu_gettimeofday(qemu_timeval *tp);
-#else
-typedef struct timeval qemu_timeval;
-#define qemu_gettimeofday(tp) gettimeofday(tp, NULL);
-#endif /* !_WIN32 */
-
 #endif
diff --git a/posix-aio-compat.c b/posix-aio-compat.c
index 7b862b5..fa5494d 100644
--- a/posix-aio-compat.c
+++ b/posix-aio-compat.c
@@ -24,6 +24,7 @@
 
 #include "qemu-queue.h"
 #include "osdep.h"
+#include "sysemu.h"
 #include "qemu-common.h"
 #include "trace.h"
 #include "block_int.h"
diff --git a/qemu-img.c b/qemu-img.c
index 578b8eb..5b2bed3 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -24,6 +24,7 @@
 #include "qemu-common.h"
 #include "qemu-option.h"
 #include "osdep.h"
+#include "sysemu.h"
 #include "block_int.h"
 #include <stdio.h>
 
diff --git a/qemu-os-posix.h b/qemu-os-posix.h
index ed5c058..609494e 100644
--- a/qemu-os-posix.h
+++ b/qemu-os-posix.h
@@ -36,4 +36,7 @@ void os_setup_signal_handling(void);
 void os_daemonize(void);
 void os_setup_post(void);
 
+typedef struct timeval qemu_timeval;
+#define qemu_gettimeofday(tp) gettimeofday(tp, NULL);
+
 #endif
diff --git a/qemu-os-win32.h b/qemu-os-win32.h
index c63778d..c2c2c20 100644
--- a/qemu-os-win32.h
+++ b/qemu-os-win32.h
@@ -52,4 +52,13 @@ static inline void os_set_proc_name(const char *dummy) {}
 # define EPROTONOSUPPORT EINVAL
 #endif
 
+int ffs(int i);
+int setenv(const char *name, const char *value, int overwrite);
+
+typedef struct {
+    long tv_sec;
+    long tv_usec;
+} qemu_timeval;
+int qemu_gettimeofday(qemu_timeval *tp);
+
 #endif
diff --git a/qemu-tool.c b/qemu-tool.c
index b39af86..2f3db30 100644
--- a/qemu-tool.c
+++ b/qemu-tool.c
@@ -15,6 +15,7 @@
 #include "monitor.h"
 #include "qemu-timer.h"
 #include "qemu-log.h"
+#include "sysemu.h"
 
 #include <sys/time.h>
 
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 6/9] Do not redefine reserved key-words TRUE/FALSE
  2010-10-15 14:05 [Qemu-devel] [PATCH 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
                   ` (4 preceding siblings ...)
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files Jes.Sorensen
@ 2010-10-15 14:05 ` Jes.Sorensen
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 7/9] Separate qemu_pidfile() into OS specific versions Jes.Sorensen
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Jes.Sorensen @ 2010-10-15 14:05 UTC (permalink / raw)
  To: qemu-devel

From: Jes Sorensen <Jes.Sorensen@redhat.com>

TRUE/FALSE are generally reserved keywords and shouldn't be defined in
a driver like this. Rename the macros to SDP_TRUE and SDP_FALSE
respectively.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 hw/bt-sdp.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/hw/bt-sdp.c b/hw/bt-sdp.c
index 6344da2..8d7074d 100644
--- a/hw/bt-sdp.c
+++ b/hw/bt-sdp.c
@@ -787,11 +787,11 @@ static void sdp_service_db_build(struct bt_l2cap_sdp_state_s *sdp,
         .type       = SDP_DTYPE_UUID | SDP_DSIZE_16,	\
         .value.uint = val,				\
     },
-#define TRUE	{				\
+#define SDP_TRUE	{				\
         .type       = SDP_DTYPE_BOOL | SDP_DSIZE_1,	\
         .value.uint = 1,				\
     },
-#define FALSE	{				\
+#define SDP_FALSE	{				\
         .type       = SDP_DTYPE_BOOL | SDP_DSIZE_1,	\
         .value.uint = 0,				\
     },
@@ -843,8 +843,8 @@ SERVICE(hid,
     /* TODO: extract from l2cap_device->device.class[0] */
     ATTRIBUTE(DEVICE_SUBCLASS,		UINT8(0x40))
     ATTRIBUTE(COUNTRY_CODE,		UINT8(0x15))
-    ATTRIBUTE(VIRTUAL_CABLE,		TRUE)
-    ATTRIBUTE(RECONNECT_INITIATE,	FALSE)
+    ATTRIBUTE(VIRTUAL_CABLE,		SDP_TRUE)
+    ATTRIBUTE(RECONNECT_INITIATE,	SDP_FALSE)
     /* TODO: extract from hid->usbdev->report_desc */
     ATTRIBUTE(DESCRIPTOR_LIST,		LIST(
         LIST(UINT8(0x22) ARRAY(
@@ -884,12 +884,12 @@ SERVICE(hid,
     ATTRIBUTE(LANG_ID_BASE_LIST,	LIST(
         LIST(UINT16(0x0409) UINT16(0x0100))
     ))
-    ATTRIBUTE(SDP_DISABLE,		FALSE)
-    ATTRIBUTE(BATTERY_POWER,		TRUE)
-    ATTRIBUTE(REMOTE_WAKEUP,		TRUE)
-    ATTRIBUTE(BOOT_DEVICE,		TRUE)	/* XXX: untested */
+    ATTRIBUTE(SDP_DISABLE,		SDP_FALSE)
+    ATTRIBUTE(BATTERY_POWER,		SDP_TRUE)
+    ATTRIBUTE(REMOTE_WAKEUP,		SDP_TRUE)
+    ATTRIBUTE(BOOT_DEVICE,		SDP_TRUE)	/* XXX: untested */
     ATTRIBUTE(SUPERVISION_TIMEOUT,	UINT16(0x0c80))
-    ATTRIBUTE(NORMALLY_CONNECTABLE,	TRUE)
+    ATTRIBUTE(NORMALLY_CONNECTABLE,	SDP_TRUE)
     ATTRIBUTE(PROFILE_VERSION,		UINT16(0x0100))
 )
 
@@ -937,7 +937,7 @@ SERVICE(pnp,
     /* Profile specific */
     ATTRIBUTE(SPECIFICATION_ID, UINT16(0x0100))
     ATTRIBUTE(VERSION,         UINT16(0x0100))
-    ATTRIBUTE(PRIMARY_RECORD,  TRUE)
+    ATTRIBUTE(PRIMARY_RECORD,  SDP_TRUE)
 )
 
 static int bt_l2cap_sdp_new_ch(struct bt_l2cap_device_s *dev,
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 7/9] Separate qemu_pidfile() into OS specific versions
  2010-10-15 14:05 [Qemu-devel] [PATCH 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
                   ` (5 preceding siblings ...)
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 6/9] Do not redefine reserved key-words TRUE/FALSE Jes.Sorensen
@ 2010-10-15 14:05 ` Jes.Sorensen
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 8/9] Consolidate oom_check() functions Jes.Sorensen
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Jes.Sorensen @ 2010-10-15 14:05 UTC (permalink / raw)
  To: qemu-devel

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 os-posix.c |   21 +++++++++++++++++++++
 os-win32.c |   24 ++++++++++++++++++++++++
 osdep.c    |   38 --------------------------------------
 3 files changed, 45 insertions(+), 38 deletions(-)

diff --git a/os-posix.c b/os-posix.c
index 612b641..38c29d1 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -361,3 +361,24 @@ int qemu_eventfd(int fds[2])
 
     return qemu_pipe(fds);
 }
+
+int qemu_create_pidfile(const char *filename)
+{
+    char buffer[128];
+    int len;
+    int fd;
+
+    fd = qemu_open(filename, O_RDWR | O_CREAT, 0600);
+    if (fd == -1) {
+        return -1;
+    }
+    if (lockf(fd, F_TLOCK, 0) == -1) {
+        return -1;
+    }
+    len = snprintf(buffer, sizeof(buffer), "%ld\n", (long)getpid());
+    if (write(fd, buffer, len) != len) {
+        return -1;
+    }
+
+    return 0;
+}
diff --git a/os-win32.c b/os-win32.c
index 3c6f50f..566d5e9 100644
--- a/os-win32.c
+++ b/os-win32.c
@@ -240,3 +240,27 @@ void os_pidfile_error(void)
 {
     fprintf(stderr, "Could not acquire pid file: %s\n", strerror(errno));
 }
+
+int qemu_create_pidfile(const char *filename)
+{
+    char buffer[128];
+    int len;
+    HANDLE file;
+    OVERLAPPED overlap;
+    BOOL ret;
+    memset(&overlap, 0, sizeof(overlap));
+
+    file = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL,
+		      OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+
+    if (file == INVALID_HANDLE_VALUE) {
+        return -1;
+    }
+    len = snprintf(buffer, sizeof(buffer), "%ld\n", (long)getpid());
+    ret = WriteFileEx(file, (LPCVOID)buffer, (DWORD)len,
+		      &overlap, NULL);
+    if (ret == 0) {
+        return -1;
+    }
+    return 0;
+}
diff --git a/osdep.c b/osdep.c
index 4b6b246..702c9d9 100644
--- a/osdep.c
+++ b/osdep.c
@@ -88,44 +88,6 @@ int qemu_madvise(void *addr, size_t len, int advice)
 #endif
 }
 
-int qemu_create_pidfile(const char *filename)
-{
-    char buffer[128];
-    int len;
-#ifndef _WIN32
-    int fd;
-
-    fd = qemu_open(filename, O_RDWR | O_CREAT, 0600);
-    if (fd == -1)
-        return -1;
-
-    if (lockf(fd, F_TLOCK, 0) == -1)
-        return -1;
-
-    len = snprintf(buffer, sizeof(buffer), "%ld\n", (long)getpid());
-    if (write(fd, buffer, len) != len)
-        return -1;
-#else
-    HANDLE file;
-    OVERLAPPED overlap;
-    BOOL ret;
-    memset(&overlap, 0, sizeof(overlap));
-
-    file = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL,
-		      OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
-
-    if (file == INVALID_HANDLE_VALUE)
-      return -1;
-
-    len = snprintf(buffer, sizeof(buffer), "%ld\n", (long)getpid());
-    ret = WriteFileEx(file, (LPCVOID)buffer, (DWORD)len,
-		      &overlap, NULL);
-    if (ret == 0)
-      return -1;
-#endif
-    return 0;
-}
-
 
 /*
  * Opens a file with FD_CLOEXEC set
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 8/9] Consolidate oom_check() functions
  2010-10-15 14:05 [Qemu-devel] [PATCH 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
                   ` (6 preceding siblings ...)
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 7/9] Separate qemu_pidfile() into OS specific versions Jes.Sorensen
@ 2010-10-15 14:05 ` Jes.Sorensen
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 9/9] Remove unncessary includes Jes.Sorensen
  2010-10-15 16:41 ` [Qemu-devel] Re: [PATCH 0/9] Re-factor osdep code + macro and brace fixes Paolo Bonzini
  9 siblings, 0 replies; 19+ messages in thread
From: Jes.Sorensen @ 2010-10-15 14:05 UTC (permalink / raw)
  To: qemu-devel

From: Jes Sorensen <Jes.Sorensen@redhat.com>

This consolidates the duplicated oom_check() functions, as well as
splitting them into OS dependant versions to avoid the #ifdef
grossness that was present in the old osdep.c version.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 os-posix-lib.c |   13 +++++++++++--
 os-win32-lib.c |   13 +++++++++++--
 osdep.c        |   15 ---------------
 qemu-common.h  |    1 +
 qemu-malloc.c  |   14 +++-----------
 5 files changed, 26 insertions(+), 30 deletions(-)

diff --git a/os-posix-lib.c b/os-posix-lib.c
index 773e998..cb146dd 100644
--- a/os-posix-lib.c
+++ b/os-posix-lib.c
@@ -33,6 +33,15 @@
 #include "qemu-options.h"
 #include "qemu_socket.h"
 
+void *qemu_oom_check(void *ptr)
+{
+    if (ptr == NULL) {
+        fprintf(stderr, "Failed to allocate memory: %s\n", strerror(errno));
+        abort();
+    }
+    return ptr;
+}
+
 void *qemu_memalign(size_t alignment, size_t size)
 {
     void *ptr;
@@ -45,9 +54,9 @@ void *qemu_memalign(size_t alignment, size_t size)
         abort();
     }
 #elif defined(CONFIG_BSD)
-    ptr = oom_check(valloc(size));
+    ptr = qemu_oom_check(valloc(size));
 #else
-    ptr = oom_check(memalign(alignment, size));
+    ptr = qemu_oom_check(memalign(alignment, size));
 #endif
     trace_qemu_memalign(alignment, size, ptr);
     return ptr;
diff --git a/os-win32-lib.c b/os-win32-lib.c
index b5b6def..a1c7ca8 100644
--- a/os-win32-lib.c
+++ b/os-win32-lib.c
@@ -38,6 +38,15 @@
 #include "qemu-options.h"
 #include "qemu_socket.h"
 
+void *qemu_oom_check(void *ptr)
+{
+    if (ptr == NULL) {
+        fprintf(stderr, "Failed to allocate memory: %lu\n", GetLastError());
+        abort();
+    }
+    return ptr;
+}
+
 void *qemu_memalign(size_t alignment, size_t size)
 {
     void *ptr;
@@ -45,7 +54,7 @@ void *qemu_memalign(size_t alignment, size_t size)
     if (!size) {
         abort();
     }
-    ptr = oom_check(VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE));
+    ptr = qemu_oom_check(VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE));
     trace_qemu_memalign(alignment, size, ptr);
     return ptr;
 }
@@ -60,7 +69,7 @@ void *qemu_vmalloc(size_t size)
     if (!size) {
         abort();
     }
-    ptr = oom_check(VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE));
+    ptr = qemu_oom_check(VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE));
     trace_qemu_vmalloc(size, ptr);
     return ptr;
 }
diff --git a/osdep.c b/osdep.c
index 702c9d9..0d48561 100644
--- a/osdep.c
+++ b/osdep.c
@@ -57,21 +57,6 @@ extern int madvise(caddr_t, size_t, int);
 #include "sysemu.h"
 #include "qemu_socket.h"
 
-#if !defined(_POSIX_C_SOURCE) || defined(_WIN32) || defined(__sun__)
-static void *oom_check(void *ptr)
-{
-    if (ptr == NULL) {
-#if defined(_WIN32)
-        fprintf(stderr, "Failed to allocate memory: %lu\n", GetLastError());
-#else
-        fprintf(stderr, "Failed to allocate memory: %s\n", strerror(errno));
-#endif
-        abort();
-    }
-    return ptr;
-}
-#endif
-
 int qemu_madvise(void *addr, size_t len, int advice)
 {
     if (advice == QEMU_MADV_INVALID) {
diff --git a/qemu-common.h b/qemu-common.h
index 81aafa0..ead1d83 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -174,6 +174,7 @@ const char *path(const char *pathname);
 #define qemu_isascii(c)		isascii((unsigned char)(c))
 #define qemu_toascii(c)		toascii((unsigned char)(c))
 
+void *qemu_oom_check(void *ptr);
 void *qemu_malloc(size_t size);
 void *qemu_realloc(void *ptr, size_t size);
 void *qemu_mallocz(size_t size);
diff --git a/qemu-malloc.c b/qemu-malloc.c
index ecffb67..28fb05a 100644
--- a/qemu-malloc.c
+++ b/qemu-malloc.c
@@ -25,14 +25,6 @@
 #include "trace.h"
 #include <stdlib.h>
 
-static void *oom_check(void *ptr)
-{
-    if (ptr == NULL) {
-        abort();
-    }
-    return ptr;
-}
-
 void qemu_free(void *ptr)
 {
     trace_qemu_free(ptr);
@@ -54,7 +46,7 @@ void *qemu_malloc(size_t size)
     if (!size && !allow_zero_malloc()) {
         abort();
     }
-    ptr = oom_check(malloc(size ? size : 1));
+    ptr = qemu_oom_check(malloc(size ? size : 1));
     trace_qemu_malloc(size, ptr);
     return ptr;
 }
@@ -65,7 +57,7 @@ void *qemu_realloc(void *ptr, size_t size)
     if (!size && !allow_zero_malloc()) {
         abort();
     }
-    newptr = oom_check(realloc(ptr, size ? size : 1));
+    newptr = qemu_oom_check(realloc(ptr, size ? size : 1));
     trace_qemu_realloc(ptr, size, newptr);
     return newptr;
 }
@@ -75,7 +67,7 @@ void *qemu_mallocz(size_t size)
     if (!size && !allow_zero_malloc()) {
         abort();
     }
-    return oom_check(calloc(1, size ? size : 1));
+    return qemu_oom_check(calloc(1, size ? size : 1));
 }
 
 char *qemu_strdup(const char *str)
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 9/9] Remove unncessary includes
  2010-10-15 14:05 [Qemu-devel] [PATCH 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
                   ` (7 preceding siblings ...)
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 8/9] Consolidate oom_check() functions Jes.Sorensen
@ 2010-10-15 14:05 ` Jes.Sorensen
  2010-10-15 16:41 ` [Qemu-devel] Re: [PATCH 0/9] Re-factor osdep code + macro and brace fixes Paolo Bonzini
  9 siblings, 0 replies; 19+ messages in thread
From: Jes.Sorensen @ 2010-10-15 14:05 UTC (permalink / raw)
  To: qemu-devel

From: Jes Sorensen <Jes.Sorensen@redhat.com>

No need to include stdlib.h for BSD as it is included by
qemu-common.h, windows.h is handled by sysemu.h and osdep.c no longer
needs malloc.h

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 osdep.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/osdep.c b/osdep.c
index 0d48561..327583b 100644
--- a/osdep.c
+++ b/osdep.c
@@ -44,14 +44,6 @@
 extern int madvise(caddr_t, size_t, int);
 #endif
 
-#ifdef _WIN32
-#include <windows.h>
-#elif defined(CONFIG_BSD)
-#include <stdlib.h>
-#else
-#include <malloc.h>
-#endif
-
 #include "qemu-common.h"
 #include "trace.h"
 #include "sysemu.h"
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] Re: [PATCH 5/9] Move qemu_gettimeofday() to OS specific files
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files Jes.Sorensen
@ 2010-10-15 16:39   ` Paolo Bonzini
  2010-10-16 14:27     ` Jes Sorensen
  0 siblings, 1 reply; 19+ messages in thread
From: Paolo Bonzini @ 2010-10-15 16:39 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: qemu-devel

On 10/15/2010 04:05 PM, Jes.Sorensen@redhat.com wrote:
> +typedef struct timeval qemu_timeval;
> +#define qemu_gettimeofday(tp) gettimeofday(tp, NULL);

Argh, trailing semicolon.  Please remove it or use an inline function.

Paolo

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Qemu-devel] Re: [PATCH 0/9] Re-factor osdep code + macro and brace fixes
  2010-10-15 14:05 [Qemu-devel] [PATCH 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
                   ` (8 preceding siblings ...)
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 9/9] Remove unncessary includes Jes.Sorensen
@ 2010-10-15 16:41 ` Paolo Bonzini
  9 siblings, 0 replies; 19+ messages in thread
From: Paolo Bonzini @ 2010-10-15 16:41 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: qemu-devel

On 10/15/2010 04:05 PM, Jes.Sorensen@redhat.com wrote:
> From: Jes Sorensen<Jes.Sorensen@redhat.com>
>
> Hi,
>
> Here is another set of patches which tries to split up osdep.c further
> into posix and win32 versions. It introduces os-{posix,win32}-lib.c
> files which are used for functions that are OS specific core library
> functionality, like gettimeofday(), and which is used by both QEMU and
> support applications like qemu-img. Other functions are moved to
> os-{posix,win32}.c. In addtion there are a couple of minor fixes for
> bad macro names.
>
> In some cases braces were added to code when it was moved, to make it
> compliant with the QEMU bracing rules.
>
> Cheers,
> Jes
>
>
> Jes Sorensen (9):
>    Move QEMU OS dependant library functions to OS specific files
>    Move osdep socket code to os-{posix,win32}-lib.c
>    qemu_pipe() is used only by POSIX code, so move to os-posix-lib.c
>    We only support eventfd under POSIX, move qemu_eventfd() to
>      os-posix.c
>    Move qemu_gettimeofday() to OS specific files
>    Do not redefine reserved key-words TRUE/FALSE
>    Separate qemu_pidfile() into OS specific versions
>    Consolidate oom_check() functions
>    Remove unncessary includes
>
>   Makefile           |    6 +-
>   Makefile.objs      |    9 ++-
>   hw/bt-sdp.c        |   21 +++--
>   os-posix-lib.c     |  111 +++++++++++++++++++++++
>   os-posix.c         |   53 +++++++++++
>   os-win32-lib.c     |  128 ++++++++++++++++++++++++++
>   os-win32.c         |   24 +++++
>   osdep.c            |  256 ----------------------------------------------------
>   osdep.h            |   15 ---
>   posix-aio-compat.c |    1 +
>   qemu-common.h      |    1 +
>   qemu-img.c         |    1 +
>   qemu-malloc.c      |   14 +---
>   qemu-os-posix.h    |    3 +
>   qemu-os-win32.h    |    9 ++
>   qemu-tool.c        |    1 +
>   16 files changed, 357 insertions(+), 296 deletions(-)
>   create mode 100644 os-posix-lib.c
>   create mode 100644 os-win32-lib.c
>

ACK except for the nit in patch 5/9.

Paolo

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH 1/9] Move QEMU OS dependant library functions to OS specific files
  2010-10-15 14:05 ` [Qemu-devel] [PATCH 1/9] Move QEMU OS dependant library functions to OS specific files Jes.Sorensen
@ 2010-10-15 20:07   ` Blue Swirl
  0 siblings, 0 replies; 19+ messages in thread
From: Blue Swirl @ 2010-10-15 20:07 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: qemu-devel

On Fri, Oct 15, 2010 at 2:05 PM,  <Jes.Sorensen@redhat.com> wrote:
> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>
> This moves library functions used by both QEMU and the QEMU tools,
> such as qemu-img, qemu-nbd etc. from osdep.c to os-{posix,win32}-lib.c

$ find . \( -name '*posix*.c' -o -name '*win32*.c' \) -print
./os-win32.c
./block/raw-posix.c
./block/raw-win32.c
./posix-aio-compat.c
./os-posix.c
./net/tap-win32.c

Please use something like osdep-{posix,win32}.c or oslib-{posix,win32}.c.

>
> In addition it introduces oslib-obj.y to the Makefile set to be
> included by the various targets, instead of relying on these library
> functions magically getting included via block-obj-y.
>
> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
> ---
>  Makefile       |    6 ++--
>  Makefile.objs  |    9 ++++++-
>  os-posix-lib.c |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  os-win32-lib.c |   71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  osdep.c        |   70 -------------------------------------------------------
>  5 files changed, 147 insertions(+), 74 deletions(-)
>  create mode 100644 os-posix-lib.c
>  create mode 100644 os-win32-lib.c
>
> diff --git a/Makefile b/Makefile
> index 252c817..0b3751d 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -129,11 +129,11 @@ version-obj-$(CONFIG_WIN32) += version.o
>  qemu-img.o: qemu-img-cmds.h
>  qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o: $(GENERATED_HEADERS)
>
> -qemu-img$(EXESUF): qemu-img.o qemu-tool.o qemu-error.o $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y)
> +qemu-img$(EXESUF): qemu-img.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y)
>
> -qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o qemu-error.o $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y)
> +qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y)
>
> -qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y)
> +qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y)
>
>  qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
>        $(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@,"  GEN   $@")
> diff --git a/Makefile.objs b/Makefile.objs
> index 816194a..4281ae8 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -5,10 +5,16 @@ qobject-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o
>  qobject-obj-y += qerror.o
>
>  #######################################################################
> +# os-obj-y is code depending on the OS (win32 vs posix)

The comment, variable name and file names are also all different.

> +oslib-obj-y = osdep.o
> +oslib-obj-$(CONFIG_WIN32) += os-win32-lib.o
> +oslib-obj-$(CONFIG_POSIX) += os-posix-lib.o
> +
> +#######################################################################
>  # block-obj-y is code used by both qemu system emulation and qemu-img
>
>  block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o
> -block-obj-y += nbd.o block.o aio.o aes.o osdep.o qemu-config.o
> +block-obj-y += nbd.o block.o aio.o aes.o qemu-config.o
>  block-obj-$(CONFIG_POSIX) += posix-aio-compat.o
>  block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
>
> @@ -50,6 +56,7 @@ common-obj-y += $(net-obj-y)
>  common-obj-y += $(qobject-obj-y)
>  common-obj-$(CONFIG_LINUX) += $(fsdev-obj-$(CONFIG_LINUX))
>  common-obj-y += readline.o console.o cursor.o async.o qemu-error.o
> +common-obj-y += $(oslib-obj-y)
>  common-obj-$(CONFIG_WIN32) += os-win32.o
>  common-obj-$(CONFIG_POSIX) += os-posix.o
>
> diff --git a/os-posix-lib.c b/os-posix-lib.c
> new file mode 100644
> index 0000000..83e5101
> --- /dev/null
> +++ b/os-posix-lib.c
> @@ -0,0 +1,65 @@
> +/*
> + * os-posix-lib.c
> + *
> + * Copyright (c) 2003-2008 Fabrice Bellard
> + * Copyright (c) 2010 Red Hat, Inc.
> + *
> + * QEMU library functions on POSIX which are shared between QEMU and
> + * the QEMU tools.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +
> +#include "config-host.h"
> +#include "sysemu.h"
> +#include "trace.h"
> +#include "net/slirp.h"
> +#include "qemu-options.h"

I don't think all of these are really needed, please trim.

> +
> +void *qemu_memalign(size_t alignment, size_t size)
> +{
> +    void *ptr;
> +#if defined(_POSIX_C_SOURCE) && !defined(__sun__)
> +    int ret;
> +    ret = posix_memalign(&ptr, alignment, size);
> +    if (ret != 0) {
> +        fprintf(stderr, "Failed to allocate %zu B: %s\n",
> +                size, strerror(ret));
> +        abort();
> +    }
> +#elif defined(CONFIG_BSD)
> +    ptr = oom_check(valloc(size));
> +#else
> +    ptr = oom_check(memalign(alignment, size));
> +#endif
> +    trace_qemu_memalign(alignment, size, ptr);
> +    return ptr;
> +}
> +
> +/* alloc shared memory pages */
> +void *qemu_vmalloc(size_t size)
> +{
> +    return qemu_memalign(getpagesize(), size);
> +}
> +
> +void qemu_vfree(void *ptr)
> +{
> +    trace_qemu_vfree(ptr);
> +    free(ptr);
> +}
> diff --git a/os-win32-lib.c b/os-win32-lib.c
> new file mode 100644
> index 0000000..80e713a
> --- /dev/null
> +++ b/os-win32-lib.c
> @@ -0,0 +1,71 @@
> +/*
> + * os-win32.c
> + *
> + * Copyright (c) 2003-2008 Fabrice Bellard
> + * Copyright (c) 2010 Red Hat, Inc.
> + *
> + * QEMU library functions for win32 which are shared between QEMU and
> + * the QEMU tools.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +#include <windows.h>
> +#include <unistd.h>
> +#include <fcntl.h>
> +#include <signal.h>
> +#include <time.h>
> +#include <errno.h>
> +#include <sys/time.h>
> +#include "config-host.h"
> +#include "sysemu.h"
> +#include "trace.h"
> +#include "qemu-options.h"

Ditto.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Qemu-devel] Re: [PATCH 5/9] Move qemu_gettimeofday() to OS specific files
  2010-10-15 16:39   ` [Qemu-devel] " Paolo Bonzini
@ 2010-10-16 14:27     ` Jes Sorensen
  0 siblings, 0 replies; 19+ messages in thread
From: Jes Sorensen @ 2010-10-16 14:27 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel

On 10/15/10 18:39, Paolo Bonzini wrote:
> On 10/15/2010 04:05 PM, Jes.Sorensen@redhat.com wrote:
>> +typedef struct timeval qemu_timeval;
>> +#define qemu_gettimeofday(tp) gettimeofday(tp, NULL);
> 
> Argh, trailing semicolon.  Please remove it or use an inline function.

Good point, it is present in the existing code - it was a pure copy
paste. I'll fix it.

Cheers,
Jes

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Qemu-devel] Re: [PATCH 5/9] Move qemu_gettimeofday() to OS specific files
  2010-10-16 16:04 ` [Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files Jes.Sorensen
@ 2010-10-16 19:32   ` Blue Swirl
  2010-10-18  8:08     ` Jes Sorensen
  0 siblings, 1 reply; 19+ messages in thread
From: Blue Swirl @ 2010-10-16 19:32 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: pbonzini, qemu-devel

On Sat, Oct 16, 2010 at 4:04 PM,  <Jes.Sorensen@redhat.com> wrote:
> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>
> In addition add sysemu.h includes to file requiring a prototype for
> ffs()

There are probably a lot more files which would need that:
/src/qemu/hw/sd.c: In function 'sd_normal_command':
/src/qemu/hw/sd.c:738:13: error: implicit declaration of function
'ffs' [-Werror=implicit-function-declaration]
/src/qemu/hw/max7310.c: In function 'max7310_tx':
/src/qemu/hw/max7310.c:94:13: error: implicit declaration of function
'ffs' [-Werror=implicit-function-declaration]
/src/qemu/hw/unin_pci.c: In function 'unin_get_config_reg':
/src/qemu/hw/unin_pci.c:101:9: error: implicit declaration of function
'ffs' [-Werror=implicit-function-declaration]

Perhaps the prototype should be added someplace else.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Qemu-devel] Re: [PATCH 5/9] Move qemu_gettimeofday() to OS specific files
  2010-10-16 19:32   ` [Qemu-devel] " Blue Swirl
@ 2010-10-18  8:08     ` Jes Sorensen
  0 siblings, 0 replies; 19+ messages in thread
From: Jes Sorensen @ 2010-10-18  8:08 UTC (permalink / raw)
  To: Blue Swirl; +Cc: pbonzini, qemu-devel

On 10/16/10 21:32, Blue Swirl wrote:
> On Sat, Oct 16, 2010 at 4:04 PM,  <Jes.Sorensen@redhat.com> wrote:
>> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>>
>> In addition add sysemu.h includes to file requiring a prototype for
>> ffs()
> 
> There are probably a lot more files which would need that:
> /src/qemu/hw/sd.c: In function 'sd_normal_command':
> /src/qemu/hw/sd.c:738:13: error: implicit declaration of function
> 'ffs' [-Werror=implicit-function-declaration]
> /src/qemu/hw/max7310.c: In function 'max7310_tx':
> /src/qemu/hw/max7310.c:94:13: error: implicit declaration of function
> 'ffs' [-Werror=implicit-function-declaration]
> /src/qemu/hw/unin_pci.c: In function 'unin_get_config_reg':
> /src/qemu/hw/unin_pci.c:101:9: error: implicit declaration of function
> 'ffs' [-Werror=implicit-function-declaration]
> 
> Perhaps the prototype should be added someplace else.

I guess we'll have to bite the bullet. I don't really like it, but I
moved it to qemu-common.h to be consistent with the POSIX code. POSIX
relies on ffs() to be provided by strings.h which we include in
qemu-common.h

Should build (I hope) in the next patch. I tried building arm-softmmu
here but it wouldn't build for me at all due to other things so I
couldn't test it.

Cheers,
Jes

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Qemu-devel] Re: [PATCH 5/9] Move qemu_gettimeofday() to OS specific files
  2010-10-18  8:15 ` [Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files Jes.Sorensen
@ 2010-10-23 14:42   ` Blue Swirl
  2010-10-25  7:39     ` Jes Sorensen
  0 siblings, 1 reply; 19+ messages in thread
From: Blue Swirl @ 2010-10-23 14:42 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: pbonzini, qemu-devel

On Mon, Oct 18, 2010 at 8:15 AM,  <Jes.Sorensen@redhat.com> wrote:
> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>
> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>

Almost there:
  CC    m68k-linux-user/m68k-semi.o
/src/qemu/m68k-semi.c: In function 'do_m68k_semihosting':
/src/qemu/m68k-semi.c:328: error: 'qemu_timeval' undeclared (first use
in this function)
/src/qemu/m68k-semi.c:328: error: (Each undeclared identifier is
reported only once
/src/qemu/m68k-semi.c:328: error: for each function it appears in.)
/src/qemu/m68k-semi.c:328: error: expected ';' before 'tv'
cc1: warnings being treated as errors
/src/qemu/m68k-semi.c:330: error: implicit declaration of function
'qemu_gettimeofday'
/src/qemu/m68k-semi.c:330: error: nested extern declaration of
'qemu_gettimeofday'
/src/qemu/m68k-semi.c:330: error: 'tv' undeclared (first use in this function)

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Qemu-devel] Re: [PATCH 5/9] Move qemu_gettimeofday() to OS specific files
  2010-10-23 14:42   ` [Qemu-devel] " Blue Swirl
@ 2010-10-25  7:39     ` Jes Sorensen
  2010-10-25 17:01       ` Blue Swirl
  0 siblings, 1 reply; 19+ messages in thread
From: Jes Sorensen @ 2010-10-25  7:39 UTC (permalink / raw)
  To: Blue Swirl; +Cc: pbonzini, qemu-devel

On 10/23/10 16:42, Blue Swirl wrote:
> On Mon, Oct 18, 2010 at 8:15 AM,  <Jes.Sorensen@redhat.com> wrote:
>> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>>
>> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
> 
> Almost there:
>   CC    m68k-linux-user/m68k-semi.o
> /src/qemu/m68k-semi.c: In function 'do_m68k_semihosting':
> /src/qemu/m68k-semi.c:328: error: 'qemu_timeval' undeclared (first use
> in this function)
> /src/qemu/m68k-semi.c:328: error: (Each undeclared identifier is
> reported only once
> /src/qemu/m68k-semi.c:328: error: for each function it appears in.)
> /src/qemu/m68k-semi.c:328: error: expected ';' before 'tv'
> cc1: warnings being treated as errors
> /src/qemu/m68k-semi.c:330: error: implicit declaration of function
> 'qemu_gettimeofday'
> /src/qemu/m68k-semi.c:330: error: nested extern declaration of
> 'qemu_gettimeofday'
> /src/qemu/m68k-semi.c:330: error: 'tv' undeclared (first use in this function)

How are you configuring your build? m68k-semi.c builds fine for me here
with these patches applied:

  CC    m68k-softmmu/mcf_fec.o
  CC    m68k-softmmu/m68k-semi.o
  CC    m68k-softmmu/dummy_m68k.o
  LINK  m68k-softmmu/qemu-system-m68k

This is for target m68k-softmmu, are you using a different target?

Thanks,
Jes

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Qemu-devel] Re: [PATCH 5/9] Move qemu_gettimeofday() to OS specific files
  2010-10-25  7:39     ` Jes Sorensen
@ 2010-10-25 17:01       ` Blue Swirl
  0 siblings, 0 replies; 19+ messages in thread
From: Blue Swirl @ 2010-10-25 17:01 UTC (permalink / raw)
  To: Jes Sorensen; +Cc: pbonzini, qemu-devel

On Mon, Oct 25, 2010 at 7:39 AM, Jes Sorensen <Jes.Sorensen@redhat.com> wrote:
> On 10/23/10 16:42, Blue Swirl wrote:
>> On Mon, Oct 18, 2010 at 8:15 AM,  <Jes.Sorensen@redhat.com> wrote:
>>> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>>>
>>> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
>>
>> Almost there:
>>   CC    m68k-linux-user/m68k-semi.o
>> /src/qemu/m68k-semi.c: In function 'do_m68k_semihosting':
>> /src/qemu/m68k-semi.c:328: error: 'qemu_timeval' undeclared (first use
>> in this function)
>> /src/qemu/m68k-semi.c:328: error: (Each undeclared identifier is
>> reported only once
>> /src/qemu/m68k-semi.c:328: error: for each function it appears in.)
>> /src/qemu/m68k-semi.c:328: error: expected ';' before 'tv'
>> cc1: warnings being treated as errors
>> /src/qemu/m68k-semi.c:330: error: implicit declaration of function
>> 'qemu_gettimeofday'
>> /src/qemu/m68k-semi.c:330: error: nested extern declaration of
>> 'qemu_gettimeofday'
>> /src/qemu/m68k-semi.c:330: error: 'tv' undeclared (first use in this function)
>
> How are you configuring your build? m68k-semi.c builds fine for me here
> with these patches applied:

With no --target-list.

>  CC    m68k-softmmu/mcf_fec.o
>  CC    m68k-softmmu/m68k-semi.o
>  CC    m68k-softmmu/dummy_m68k.o
>  LINK  m68k-softmmu/qemu-system-m68k
>
> This is for target m68k-softmmu, are you using a different target?

m68k-linux-user

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2010-10-25 17:03 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-15 14:05 [Qemu-devel] [PATCH 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
2010-10-15 14:05 ` [Qemu-devel] [PATCH 1/9] Move QEMU OS dependant library functions to OS specific files Jes.Sorensen
2010-10-15 20:07   ` Blue Swirl
2010-10-15 14:05 ` [Qemu-devel] [PATCH 2/9] Move osdep socket code to os-{posix, win32}-lib.c Jes.Sorensen
2010-10-15 14:05 ` [Qemu-devel] [PATCH 3/9] qemu_pipe() is used only by POSIX code, so move to os-posix-lib.c Jes.Sorensen
2010-10-15 14:05 ` [Qemu-devel] [PATCH 4/9] We only support eventfd under POSIX, move qemu_eventfd() to os-posix.c Jes.Sorensen
2010-10-15 14:05 ` [Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files Jes.Sorensen
2010-10-15 16:39   ` [Qemu-devel] " Paolo Bonzini
2010-10-16 14:27     ` Jes Sorensen
2010-10-15 14:05 ` [Qemu-devel] [PATCH 6/9] Do not redefine reserved key-words TRUE/FALSE Jes.Sorensen
2010-10-15 14:05 ` [Qemu-devel] [PATCH 7/9] Separate qemu_pidfile() into OS specific versions Jes.Sorensen
2010-10-15 14:05 ` [Qemu-devel] [PATCH 8/9] Consolidate oom_check() functions Jes.Sorensen
2010-10-15 14:05 ` [Qemu-devel] [PATCH 9/9] Remove unncessary includes Jes.Sorensen
2010-10-15 16:41 ` [Qemu-devel] Re: [PATCH 0/9] Re-factor osdep code + macro and brace fixes Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2010-10-16 16:04 [Qemu-devel] [PATCH v2 " Jes.Sorensen
2010-10-16 16:04 ` [Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files Jes.Sorensen
2010-10-16 19:32   ` [Qemu-devel] " Blue Swirl
2010-10-18  8:08     ` Jes Sorensen
2010-10-18  8:15 [Qemu-devel] [PATCH v3 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
2010-10-18  8:15 ` [Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files Jes.Sorensen
2010-10-23 14:42   ` [Qemu-devel] " Blue Swirl
2010-10-25  7:39     ` Jes Sorensen
2010-10-25 17:01       ` Blue Swirl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).