[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files
From: |
Jes . Sorensen |
Subject: |
[Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files |
Date: |
Sat, 16 Oct 2010 18:04:39 +0200 |
From: Jes Sorensen <address@hidden>
In addition add sysemu.h includes to file requiring a prototype for
ffs()
Signed-off-by: Jes Sorensen <address@hidden>
---
hw/bt-sdp.c | 1 +
osdep.c | 31 -------------------------------
osdep.h | 15 ---------------
oslib-win32.c | 27 +++++++++++++++++++++++++++
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/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-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..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
- [Qemu-devel] [PATCH v2 0/9] Re-factor osdep code + macro and brace fixes, Jes . Sorensen, 2010/10/16
- [Qemu-devel] [PATCH 2/9] Move osdep socket code to oslib-{posix, win32}.c, Jes . Sorensen, 2010/10/16
- [Qemu-devel] [PATCH 1/9] Move QEMU OS dependant library functions to OS specific files, Jes . Sorensen, 2010/10/16
- [Qemu-devel] [PATCH 4/9] We only support eventfd under POSIX, move qemu_eventfd() to os-posix.c, Jes . Sorensen, 2010/10/16
- [Qemu-devel] [PATCH 3/9] qemu_pipe() is used only by POSIX code, so move to oslib-posix.c, Jes . Sorensen, 2010/10/16
- [Qemu-devel] [PATCH 6/9] Do not redefine reserved key-words TRUE/FALSE, Jes . Sorensen, 2010/10/16
- [Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files,
Jes . Sorensen <=
- [Qemu-devel] [PATCH 7/9] Separate qemu_pidfile() into OS specific versions, Jes . Sorensen, 2010/10/16
- [Qemu-devel] [PATCH 9/9] Remove unncessary includes, Jes . Sorensen, 2010/10/16
- [Qemu-devel] [PATCH 8/9] Consolidate oom_check() functions, Jes . Sorensen, 2010/10/16