diff mbox

[v3,05/34] int128: Add int128_make128

Message ID 20160909130110.GA24307@hhmipssw201.hh.imgtec.org
State New
Headers show

Commit Message

Leon Alrae Sept. 9, 2016, 1:01 p.m. UTC
On Sat, Sep 03, 2016 at 09:39:33PM +0100, Richard Henderson wrote:
> Allows Int128 to be used more generally, rather than having to
> begin with 64-bit inputs and accumulate.
> 
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>  include/qemu/int128.h | 20 +++++++++++++++-----
>  1 file changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/include/qemu/int128.h b/include/qemu/int128.h
> index 08f1db1..67440fa 100644
> --- a/include/qemu/int128.h
> +++ b/include/qemu/int128.h
> @@ -10,6 +10,11 @@ static inline Int128 int128_make64(uint64_t a)
>      return a;
>  }
>  
> +static inline Int128 int128_make128(uint64_t lo, uint64_t hi)
> +{
> +    return (unsigned __int128)hi << 64 | lo;
> +}
> +

This causes build failures for me on CentOS6.5:
/user/lea/dev/qemu/include/qemu/int128.h:7: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Int128’
/user/lea/dev/qemu/include/qemu/int128.h:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int128_make64’
/user/lea/dev/qemu/include/qemu/int128.h:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int128_make128’
(...)

This is because CONFIG_INT128 is set if test for __int128_t succeeds, not
__int128. The following change on top of patches 4 and 5 in this series
fixes the problem for me:

Comments

Richard Henderson Sept. 9, 2016, 8:16 p.m. UTC | #1
On 09/09/2016 06:01 AM, Leon Alrae wrote:
> This causes build failures for me on CentOS6.5:
> /user/lea/dev/qemu/include/qemu/int128.h:7: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Int128’
> /user/lea/dev/qemu/include/qemu/int128.h:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int128_make64’
> /user/lea/dev/qemu/include/qemu/int128.h:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int128_make128’
> (...)
>
> This is because CONFIG_INT128 is set if test for __int128_t succeeds, not
> __int128. The following change on top of patches 4 and 5 in this series
> fixes the problem for me:
>
> diff --git a/include/qemu/int128.h b/include/qemu/int128.h
> index 261b55f..5c9890d 100644
> --- a/include/qemu/int128.h
> +++ b/include/qemu/int128.h
> @@ -4,7 +4,7 @@
>  #ifdef CONFIG_INT128
>  #include "qemu/bswap.h"
>
> -typedef __int128 Int128;
> +typedef __int128_t Int128;
>
>  static inline Int128 int128_make64(uint64_t a)
>  {
> @@ -13,7 +13,7 @@ static inline Int128 int128_make64(uint64_t a)
>
>  static inline Int128 int128_make128(uint64_t lo, uint64_t hi)
>  {
> -    return (unsigned __int128)hi << 64 | lo;
> +    return (__uint128_t)hi << 64 | lo;
>  }

Thanks, I'll fold that in.


r~
diff mbox

Patch

diff --git a/include/qemu/int128.h b/include/qemu/int128.h
index 261b55f..5c9890d 100644
--- a/include/qemu/int128.h
+++ b/include/qemu/int128.h
@@ -4,7 +4,7 @@ 
 #ifdef CONFIG_INT128
 #include "qemu/bswap.h"

-typedef __int128 Int128;
+typedef __int128_t Int128;

 static inline Int128 int128_make64(uint64_t a)
 {
@@ -13,7 +13,7 @@  static inline Int128 int128_make64(uint64_t a)

 static inline Int128 int128_make128(uint64_t lo, uint64_t hi)
 {
-    return (unsigned __int128)hi << 64 | lo;
+    return (__uint128_t)hi << 64 | lo;
 }