diff mbox

win32: Add missing function ffs

Message ID 1276351632-8072-1-git-send-email-weil@mail.berlios.de
State New
Headers show

Commit Message

Stefan Weil June 12, 2010, 2:07 p.m. UTC
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.

v2: Use __builtin_ffs as suggested by Richard Henderson

Cc: Richard Henderson <rth@twiddle.net>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 osdep.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

Comments

Richard Henderson June 12, 2010, 3:52 p.m. UTC | #1
On 06/12/2010 07:07 AM, Stefan Weil wrote:
> v2: Use __builtin_ffs as suggested by Richard Henderson
> 
> Cc: Richard Henderson <rth@twiddle.net>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>

Acked-by: Richard Henderson <rth@twiddle.net>


r~
Stefan Weil June 24, 2010, 8:50 p.m. UTC | #2
Am 12.06.2010 16:07, schrieb Stefan Weil:
> 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.
>
> v2: Use __builtin_ffs as suggested by Richard Henderson
>
> Cc: Richard Henderson<rth@twiddle.net>
> Signed-off-by: Stefan Weil<weil@mail.berlios.de>
> ---
>   osdep.c |    7 +++++++
>   1 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/osdep.c b/osdep.c
> index abbc8a2..dbf872a 100644
> --- a/osdep.c
> +++ b/osdep.c
> @@ -167,6 +167,13 @@ int qemu_create_pidfile(const char *filename)
>
>   #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)
>
>    

Ping. The patch should be applied to qemu master.

Thanks,
Stefan
Blue Swirl June 27, 2010, 8:25 p.m. UTC | #3
Thanks, applied.

On Thu, Jun 24, 2010 at 8:50 PM, Stefan Weil <weil@mail.berlios.de> wrote:
> Am 12.06.2010 16:07, schrieb Stefan Weil:
>>
>> 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.
>>
>> v2: Use __builtin_ffs as suggested by Richard Henderson
>>
>> Cc: Richard Henderson<rth@twiddle.net>
>> Signed-off-by: Stefan Weil<weil@mail.berlios.de>
>> ---
>>  osdep.c |    7 +++++++
>>  1 files changed, 7 insertions(+), 0 deletions(-)
>>
>> diff --git a/osdep.c b/osdep.c
>> index abbc8a2..dbf872a 100644
>> --- a/osdep.c
>> +++ b/osdep.c
>> @@ -167,6 +167,13 @@ int qemu_create_pidfile(const char *filename)
>>
>>  #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)
>>
>>
>
> Ping. The patch should be applied to qemu master.
>
> Thanks,
> Stefan
>
>
>
diff mbox

Patch

diff --git a/osdep.c b/osdep.c
index abbc8a2..dbf872a 100644
--- a/osdep.c
+++ b/osdep.c
@@ -167,6 +167,13 @@  int qemu_create_pidfile(const char *filename)
 
 #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)