From patchwork Mon Oct 18 08:15:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 68142 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 63D25B7103 for ; Mon, 18 Oct 2010 19:35:49 +1100 (EST) Received: from localhost ([127.0.0.1]:49042 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P7lC6-0006DG-Dp for incoming@patchwork.ozlabs.org; Mon, 18 Oct 2010 04:35:46 -0400 Received: from [140.186.70.92] (port=55279 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P7kt6-0003wc-2g for qemu-devel@nongnu.org; Mon, 18 Oct 2010 04:16:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P7kt4-0000wX-TR for qemu-devel@nongnu.org; Mon, 18 Oct 2010 04:16:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62608) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P7kt4-0000wO-Mg for qemu-devel@nongnu.org; Mon, 18 Oct 2010 04:16:06 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9I8G537022906 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 18 Oct 2010 04:16:05 -0400 Received: from localhost6.localdomain6 (ovpn-113-37.phx2.redhat.com [10.3.113.37]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9I8FuO5012414; Mon, 18 Oct 2010 04:16:04 -0400 From: Jes.Sorensen@redhat.com To: qemu-devel@nongnu.org Date: Mon, 18 Oct 2010 10:15:50 +0200 Message-Id: <1287389754-985-6-git-send-email-Jes.Sorensen@redhat.com> In-Reply-To: <1287389754-985-1-git-send-email-Jes.Sorensen@redhat.com> References: <1287389754-985-1-git-send-email-Jes.Sorensen@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: blauwirbel@gmail.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jes Sorensen Signed-off-by: Jes Sorensen --- 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 + 9 files changed, 46 insertions(+), 46 deletions(-) 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 81aafa0..1f01a44 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -174,6 +174,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 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 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