From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=35806 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ONBId-0001TK-CF for qemu-devel@nongnu.org; Fri, 11 Jun 2010 16:58:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ONBIc-0005jp-1r for qemu-devel@nongnu.org; Fri, 11 Jun 2010 16:57:59 -0400 Received: from moutng.kundenserver.de ([212.227.126.187]:60006) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ONBIb-0005j2-MG for qemu-devel@nongnu.org; Fri, 11 Jun 2010 16:57:58 -0400 From: Stefan Weil Date: Fri, 11 Jun 2010 22:57:47 +0200 Message-Id: <1276289867-8014-1-git-send-email-weil@mail.berlios.de> Subject: [Qemu-devel] [PATCH] win32: Add missing function ffs List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: QEMU Developers mingw32 does not include function ffs. Commit c6d29ad6e24533cc3762e1d654275607e1d03058 added a declaration for ffs, but an implementation was missing. For compilations with optimization, the compiler creates inline code, so the implementation is not always needed. Without optimization, linking fails without this patch. Signed-off-by: Stefan Weil --- osdep.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/osdep.c b/osdep.c index abbc8a2..50b38e3 100644 --- a/osdep.c +++ b/osdep.c @@ -167,6 +167,21 @@ int qemu_create_pidfile(const char *filename) #ifdef _WIN32 +/* mingw32 needs ffs for compilations without optimization. */ +int ffs(int i) +{ + int position = 0; + if (i != 0) { + for (position = 1; i != 0; position++) { + if (i & 1) { + break; + } + i >>= 1; + } + } + return position; +} + /* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */ #define _W32_FT_OFFSET (116444736000000000ULL) -- 1.5.6.5