Patchwork w32: Always compile with __builtin_ffs

login
register
mail settings
Submitter Jacob Kroon
Date Feb. 16, 2013, 6:48 p.m.
Message ID <CAPbeDCkt36dh1H=8hyc3HdEBX_9h54TZwSrFMGgzDA2FJsztxw@mail.gmail.com>
Download mbox | patch
Permalink /patch/221024/
State New
Headers show

Comments

Jacob Kroon - Feb. 16, 2013, 6:48 p.m.
Hi Stefan,

On Sat, Feb 16, 2013 at 7:30 PM, Stefan Weil <sw@weilnetz.de> wrote:
> Not all MinGW build environments include a library which provides ffs(),
> and some versions of gcc create a function call instead of inline code.
>
> When gcc is called with -ansi, it will always create a function call.
> This usually results in an unresolved symbol "ffs" at link time.
>
> The patch enforces inline code for this special case.
>
> Cc: Jacob Kroon <jacob.kroon@gmail.com>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>
> Hi Jacob,
>
> please try the patch below. If it does not fix the linker problem,
> you can define ffs unconditionally.

Thanks for looking into this. The patch as it is still results in
linker errors on my machine,
but yes, defining "ffs" unconditionally like below does fix the problem here.


Regards
Jacob

Patch

diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
index bf9edeb..e2972c8 100644
--- a/include/sysemu/os-win32.h
+++ b/include/sysemu/os-win32.h
@@ -66,6 +66,7 @@ 

 /* Declaration of ffs() is missing in MinGW's strings.h. */
 int ffs(int i);
+#define ffs(i) __builtin_ffs(i)

 /* Missing POSIX functions. Don't use MinGW-w64 macros. */
 #undef gmtime_r