* [Qemu-devel] [PATCH 1/9] Move QEMU OS dependant library functions to OS specific files
2010-10-26 8:39 [Qemu-devel] [PATCH v4 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
@ 2010-10-26 8:39 ` Jes.Sorensen
2010-10-26 8:39 ` [Qemu-devel] [PATCH 2/9] Move osdep socket code to oslib-{posix, win32}.c Jes.Sorensen
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jes.Sorensen @ 2010-10-26 8:39 UTC (permalink / raw)
To: qemu-devel; +Cc: blauwirbel
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 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 +++++-
osdep.c | 85 ---------------------------------------------------------
oslib-posix.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++
oslib-win32.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 158 insertions(+), 89 deletions(-)
create mode 100644 oslib-posix.c
create mode 100644 oslib-win32.c
diff --git a/Makefile b/Makefile
index a1434b1..4121338 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-timer-common.o
+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-timer-common.o
-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-timer-common.o
+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-timer-common.o
-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-timer-common.o
+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-timer-common.o
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 f07fb01..c88e82d 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
#######################################################################
+# oslib-obj-y is code depending on the OS (win32 vs posix)
+oslib-obj-y = osdep.o
+oslib-obj-$(CONFIG_WIN32) += oslib-win32.o
+oslib-obj-$(CONFIG_POSIX) += oslib-posix.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/osdep.c b/osdep.c
index 2e05b21..581768a 100644
--- a/osdep.c
+++ b/osdep.c
@@ -61,91 +61,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
-
-#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) {
diff --git a/oslib-posix.c b/oslib-posix.c
new file mode 100644
index 0000000..df97304
--- /dev/null
+++ b/oslib-posix.c
@@ -0,0 +1,74 @@
+/*
+ * 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"
+
+#if !defined(_POSIX_C_SOURCE) || defined(__sun__)
+static void *oom_check(void *ptr)
+{
+ if (ptr == NULL) {
+ fprintf(stderr, "Failed to allocate memory: %s\n", strerror(errno));
+ abort();
+ }
+ return ptr;
+}
+#endif
+
+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/oslib-win32.c b/oslib-win32.c
new file mode 100644
index 0000000..3b5245d
--- /dev/null
+++ b/oslib-win32.c
@@ -0,0 +1,73 @@
+/*
+ * 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 "config-host.h"
+#include "sysemu.h"
+#include "trace.h"
+
+static void *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;
+
+ 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);
+}
--
1.7.2.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 2/9] Move osdep socket code to oslib-{posix, win32}.c
2010-10-26 8:39 [Qemu-devel] [PATCH v4 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
2010-10-26 8:39 ` [Qemu-devel] [PATCH 1/9] Move QEMU OS dependant library functions to OS specific files Jes.Sorensen
@ 2010-10-26 8:39 ` Jes.Sorensen
2010-10-26 8:39 ` [Qemu-devel] [PATCH 3/9] qemu_pipe() is used only by POSIX code, so move to oslib-posix.c Jes.Sorensen
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jes.Sorensen @ 2010-10-26 8:39 UTC (permalink / raw)
To: qemu-devel; +Cc: blauwirbel
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
osdep.c | 38 --------------------------------------
oslib-posix.c | 15 +++++++++++++++
oslib-win32.c | 21 +++++++++++++++++++++
3 files changed, 36 insertions(+), 38 deletions(-)
diff --git a/osdep.c b/osdep.c
index 581768a..902fce9 100644
--- a/osdep.c
+++ b/osdep.c
@@ -147,44 +147,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
*/
diff --git a/oslib-posix.c b/oslib-posix.c
index df97304..aebe3ac 100644
--- a/oslib-posix.c
+++ b/oslib-posix.c
@@ -29,6 +29,7 @@
#include "config-host.h"
#include "sysemu.h"
#include "trace.h"
+#include "qemu_socket.h"
#if !defined(_POSIX_C_SOURCE) || defined(__sun__)
static void *oom_check(void *ptr)
@@ -72,3 +73,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/oslib-win32.c b/oslib-win32.c
index 3b5245d..1ddd857 100644
--- a/oslib-win32.c
+++ b/oslib-win32.c
@@ -29,6 +29,7 @@
#include "config-host.h"
#include "sysemu.h"
#include "trace.h"
+#include "qemu_socket.h"
static void *oom_check(void *ptr)
{
@@ -71,3 +72,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)
+{
+}
--
1.7.2.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 3/9] qemu_pipe() is used only by POSIX code, so move to oslib-posix.c
2010-10-26 8:39 [Qemu-devel] [PATCH v4 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
2010-10-26 8:39 ` [Qemu-devel] [PATCH 1/9] Move QEMU OS dependant library functions to OS specific files Jes.Sorensen
2010-10-26 8:39 ` [Qemu-devel] [PATCH 2/9] Move osdep socket code to oslib-{posix, win32}.c Jes.Sorensen
@ 2010-10-26 8:39 ` Jes.Sorensen
2010-10-26 8:39 ` [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; 11+ messages in thread
From: Jes.Sorensen @ 2010-10-26 8:39 UTC (permalink / raw)
To: qemu-devel; +Cc: blauwirbel
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
osdep.c | 22 ----------------------
oslib-posix.c | 22 ++++++++++++++++++++++
2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/osdep.c b/osdep.c
index 902fce9..926c8ad 100644
--- a/osdep.c
+++ b/osdep.c
@@ -235,28 +235,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
/*
diff --git a/oslib-posix.c b/oslib-posix.c
index aebe3ac..ad44b17 100644
--- a/oslib-posix.c
+++ b/oslib-posix.c
@@ -87,3 +87,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;
+}
--
1.7.2.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 4/9] We only support eventfd under POSIX, move qemu_eventfd() to os-posix.c
2010-10-26 8:39 [Qemu-devel] [PATCH v4 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
` (2 preceding siblings ...)
2010-10-26 8:39 ` [Qemu-devel] [PATCH 3/9] qemu_pipe() is used only by POSIX code, so move to oslib-posix.c Jes.Sorensen
@ 2010-10-26 8:39 ` Jes.Sorensen
2010-10-26 8:39 ` [Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files Jes.Sorensen
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jes.Sorensen @ 2010-10-26 8:39 UTC (permalink / raw)
To: qemu-devel; +Cc: blauwirbel
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 926c8ad..cb12e5f 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)
@@ -207,36 +203,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] 11+ messages in thread
* [Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files
2010-10-26 8:39 [Qemu-devel] [PATCH v4 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
` (3 preceding siblings ...)
2010-10-26 8:39 ` [Qemu-devel] [PATCH 4/9] We only support eventfd under POSIX, move qemu_eventfd() to os-posix.c Jes.Sorensen
@ 2010-10-26 8:39 ` Jes.Sorensen
2010-10-26 8:39 ` [Qemu-devel] [PATCH 6/9] Do not redefine reserved key-words TRUE/FALSE Jes.Sorensen
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jes.Sorensen @ 2010-10-26 8:39 UTC (permalink / raw)
To: qemu-devel; +Cc: blauwirbel
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
m68k-semi.c | 2 +-
osdep.c | 31 -------------------------------
osdep.h | 15 ---------------
oslib-win32.c | 27 +++++++++++++++++++++++++++
posix-aio-compat.c | 1 +
qemu-common.h | 5 +++++
qemu-img.c | 1 +
qemu-os-posix.h | 3 +++
qemu-os-win32.h | 8 ++++++++
qemu-tool.c | 1 +
10 files changed, 47 insertions(+), 47 deletions(-)
diff --git a/m68k-semi.c b/m68k-semi.c
index d16bc67..0371089 100644
--- a/m68k-semi.c
+++ b/m68k-semi.c
@@ -33,10 +33,10 @@
#define SEMIHOSTING_HEAP_SIZE (128 * 1024 * 1024)
#else
#include "qemu-common.h"
-#include "sysemu.h"
#include "gdbstub.h"
#include "softmmu-semi.h"
#endif
+#include "sysemu.h"
#define HOSTED_EXIT 0
#define HOSTED_INIT_SIM 1
diff --git a/osdep.c b/osdep.c
index cb12e5f..b1664ac 100644
--- a/osdep.c
+++ b/osdep.c
@@ -111,37 +111,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/oslib-win32.c b/oslib-win32.c
index 1ddd857..e03c472 100644
--- a/oslib-win32.c
+++ b/oslib-win32.c
@@ -92,3 +92,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/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-common.h b/qemu-common.h
index 2fbc27f..898da62 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -167,6 +167,11 @@ const char *path(const char *pathname);
#define qemu_isascii(c) isascii((unsigned char)(c))
#define qemu_toascii(c) toascii((unsigned char)(c))
+#ifdef _WIN32
+/* ffs() in oslib-win32.c for WIN32, strings.h for the rest of the world */
+int ffs(int i);
+#endif
+
void *qemu_malloc(size_t size);
void *qemu_realloc(void *ptr, size_t size);
void *qemu_mallocz(size_t size);
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..353f878 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..1a07e5e 100644
--- a/qemu-os-win32.h
+++ b/qemu-os-win32.h
@@ -52,4 +52,12 @@ static inline void os_set_proc_name(const char *dummy) {}
# define EPROTONOSUPPORT EINVAL
#endif
+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 9ccca65..392e1c9 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] 11+ messages in thread
* [Qemu-devel] [PATCH 6/9] Do not redefine reserved key-words TRUE/FALSE
2010-10-26 8:39 [Qemu-devel] [PATCH v4 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
` (4 preceding siblings ...)
2010-10-26 8:39 ` [Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files Jes.Sorensen
@ 2010-10-26 8:39 ` Jes.Sorensen
2010-10-26 8:39 ` [Qemu-devel] [PATCH 7/9] Separate qemu_pidfile() into OS specific versions Jes.Sorensen
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jes.Sorensen @ 2010-10-26 8:39 UTC (permalink / raw)
To: qemu-devel; +Cc: blauwirbel
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 cc0bf2f..cdf2d95 100644
--- a/hw/bt-sdp.c
+++ b/hw/bt-sdp.c
@@ -786,11 +786,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, \
},
@@ -842,8 +842,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(
@@ -883,12 +883,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))
)
@@ -936,7 +936,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] 11+ messages in thread
* [Qemu-devel] [PATCH 7/9] Separate qemu_pidfile() into OS specific versions
2010-10-26 8:39 [Qemu-devel] [PATCH v4 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
` (5 preceding siblings ...)
2010-10-26 8:39 ` [Qemu-devel] [PATCH 6/9] Do not redefine reserved key-words TRUE/FALSE Jes.Sorensen
@ 2010-10-26 8:39 ` Jes.Sorensen
2010-10-26 8:39 ` [Qemu-devel] [PATCH 8/9] Consolidate oom_check() functions Jes.Sorensen
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jes.Sorensen @ 2010-10-26 8:39 UTC (permalink / raw)
To: qemu-devel; +Cc: blauwirbel
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 b1664ac..0d48561 100644
--- a/osdep.c
+++ b/osdep.c
@@ -73,44 +73,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] 11+ messages in thread
* [Qemu-devel] [PATCH 8/9] Consolidate oom_check() functions
2010-10-26 8:39 [Qemu-devel] [PATCH v4 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
` (6 preceding siblings ...)
2010-10-26 8:39 ` [Qemu-devel] [PATCH 7/9] Separate qemu_pidfile() into OS specific versions Jes.Sorensen
@ 2010-10-26 8:39 ` Jes.Sorensen
2010-10-26 8:39 ` [Qemu-devel] [PATCH 9/9] Remove unncessary includes Jes.Sorensen
2010-10-30 9:23 ` [Qemu-devel] Re: [PATCH v4 0/9] Re-factor osdep code + macro and brace fixes Blue Swirl
9 siblings, 0 replies; 11+ messages in thread
From: Jes.Sorensen @ 2010-10-26 8:39 UTC (permalink / raw)
To: qemu-devel; +Cc: blauwirbel
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>
---
Makefile.target | 2 +-
oslib-posix.c | 8 +++-----
oslib-win32.c | 6 +++---
qemu-common.h | 1 +
qemu-malloc.c | 14 +++-----------
5 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/Makefile.target b/Makefile.target
index c48cbcc..91e6e74 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -88,7 +88,7 @@ $(call set-vpath, $(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR
QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
obj-y = main.o syscall.o strace.o mmap.o signal.o thunk.o \
elfload.o linuxload.o uaccess.o gdbstub.o cpu-uname.o \
- qemu-malloc.o
+ qemu-malloc.o $(oslib-obj-y)
obj-$(TARGET_HAS_BFLT) += flatload.o
diff --git a/oslib-posix.c b/oslib-posix.c
index ad44b17..6e9b0c3 100644
--- a/oslib-posix.c
+++ b/oslib-posix.c
@@ -31,8 +31,7 @@
#include "trace.h"
#include "qemu_socket.h"
-#if !defined(_POSIX_C_SOURCE) || defined(__sun__)
-static void *oom_check(void *ptr)
+void *qemu_oom_check(void *ptr)
{
if (ptr == NULL) {
fprintf(stderr, "Failed to allocate memory: %s\n", strerror(errno));
@@ -40,7 +39,6 @@ static void *oom_check(void *ptr)
}
return ptr;
}
-#endif
void *qemu_memalign(size_t alignment, size_t size)
{
@@ -54,9 +52,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/oslib-win32.c b/oslib-win32.c
index e03c472..ab29eae 100644
--- a/oslib-win32.c
+++ b/oslib-win32.c
@@ -31,7 +31,7 @@
#include "trace.h"
#include "qemu_socket.h"
-static void *oom_check(void *ptr)
+void *qemu_oom_check(void *ptr)
{
if (ptr == NULL) {
fprintf(stderr, "Failed to allocate memory: %lu\n", GetLastError());
@@ -47,7 +47,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;
}
@@ -62,7 +62,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/qemu-common.h b/qemu-common.h
index 898da62..12fb42d 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -172,6 +172,7 @@ const char *path(const char *pathname);
int ffs(int i);
#endif
+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] 11+ messages in thread
* [Qemu-devel] [PATCH 9/9] Remove unncessary includes
2010-10-26 8:39 [Qemu-devel] [PATCH v4 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
` (7 preceding siblings ...)
2010-10-26 8:39 ` [Qemu-devel] [PATCH 8/9] Consolidate oom_check() functions Jes.Sorensen
@ 2010-10-26 8:39 ` Jes.Sorensen
2010-10-30 9:23 ` [Qemu-devel] Re: [PATCH v4 0/9] Re-factor osdep code + macro and brace fixes Blue Swirl
9 siblings, 0 replies; 11+ messages in thread
From: Jes.Sorensen @ 2010-10-26 8:39 UTC (permalink / raw)
To: qemu-devel; +Cc: blauwirbel
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] 11+ messages in thread
* [Qemu-devel] Re: [PATCH v4 0/9] Re-factor osdep code + macro and brace fixes
2010-10-26 8:39 [Qemu-devel] [PATCH v4 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
` (8 preceding siblings ...)
2010-10-26 8:39 ` [Qemu-devel] [PATCH 9/9] Remove unncessary includes Jes.Sorensen
@ 2010-10-30 9:23 ` Blue Swirl
9 siblings, 0 replies; 11+ messages in thread
From: Blue Swirl @ 2010-10-30 9:23 UTC (permalink / raw)
To: Jes.Sorensen; +Cc: qemu-devel
Thanks, applied all.
On Tue, Oct 26, 2010 at 8:39 AM, <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 oslib-{posix,win32}.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.
>
> v4 fixes the build problem for m68k-linux-user reported by Blue Swirl.
>
> Cheers,
> Jes
>
>
> Jes Sorensen (9):
> Move QEMU OS dependant library functions to OS specific files
> Move osdep socket code to oslib-{posix,win32}.c
> qemu_pipe() is used only by POSIX code, so move to oslib-posix.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 ++-
> Makefile.target | 2 +-
> hw/bt-sdp.c | 20 ++--
> m68k-semi.c | 2 +-
> os-posix.c | 53 +++++++++++
> os-win32.c | 24 +++++
> osdep.c | 256 ----------------------------------------------------
> osdep.h | 15 ---
> oslib-posix.c | 109 ++++++++++++++++++++++
> oslib-win32.c | 121 +++++++++++++++++++++++++
> posix-aio-compat.c | 1 +
> qemu-common.h | 6 ++
> qemu-img.c | 1 +
> qemu-malloc.c | 14 +---
> qemu-os-posix.h | 3 +
> qemu-os-win32.h | 8 ++
> qemu-tool.c | 1 +
> 18 files changed, 353 insertions(+), 298 deletions(-)
> create mode 100644 oslib-posix.c
> create mode 100644 oslib-win32.c
>
> --
> 1.7.2.3
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread