All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] win32: Add missing function ffs
@ 2010-06-11 20:57 Stefan Weil
  2010-06-11 21:35 ` Richard Henderson
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Weil @ 2010-06-11 20:57 UTC (permalink / raw)
  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 <weil@mail.berlios.de>
---
 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

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

end of thread, other threads:[~2010-06-27 20:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-11 20:57 [Qemu-devel] [PATCH] win32: Add missing function ffs Stefan Weil
2010-06-11 21:35 ` Richard Henderson
2010-06-12 14:07   ` Stefan Weil
2010-06-12 15:52     ` [Qemu-devel] " Richard Henderson
2010-06-24 20:50     ` Stefan Weil
2010-06-27 20:25       ` Blue Swirl

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.