[PATCH 08/10] semihosting/arm-compat-semi: replace target_long with int64_t

Pierrick Bouvier posted 10 patches 2 months, 2 weeks ago
Maintainers: "Alex Bennée" <alex.bennee@linaro.org>, Peter Maydell <peter.maydell@linaro.org>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>
There is a newer version of this series
[PATCH 08/10] semihosting/arm-compat-semi: replace target_long with int64_t
Posted by Pierrick Bouvier 2 months, 2 weeks ago
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 semihosting/arm-compat-semi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index e3b520631b3..715a22528ab 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -502,7 +502,7 @@ void do_common_semihosting(CPUState *cs)
 
     case TARGET_SYS_ISERROR:
         GET_ARG(0);
-        common_semi_set_ret(cs, (target_long)arg0 < 0);
+        common_semi_set_ret(cs, (int64_t)arg0 < 0);
         break;
 
     case TARGET_SYS_ISTTY:
-- 
2.47.2
Re: [PATCH 08/10] semihosting/arm-compat-semi: replace target_long with int64_t
Posted by Richard Henderson 2 months, 2 weeks ago
On 7/31/25 08:06, Pierrick Bouvier wrote:
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   semihosting/arm-compat-semi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
> index e3b520631b3..715a22528ab 100644
> --- a/semihosting/arm-compat-semi.c
> +++ b/semihosting/arm-compat-semi.c
> @@ -502,7 +502,7 @@ void do_common_semihosting(CPUState *cs)
>   
>       case TARGET_SYS_ISERROR:
>           GET_ARG(0);
> -        common_semi_set_ret(cs, (target_long)arg0 < 0);
> +        common_semi_set_ret(cs, (int64_t)arg0 < 0);
>           break;
>   
>       case TARGET_SYS_ISTTY:

Here we have a semantic change.  For 32-bit, we used get_user_u32, so this will always 
return false.


r~
Re: [PATCH 08/10] semihosting/arm-compat-semi: replace target_long with int64_t
Posted by Pierrick Bouvier 2 months, 2 weeks ago
On 7/31/25 6:25 PM, Richard Henderson wrote:
> On 7/31/25 08:06, Pierrick Bouvier wrote:
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>>    semihosting/arm-compat-semi.c | 2 +-
>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
>> index e3b520631b3..715a22528ab 100644
>> --- a/semihosting/arm-compat-semi.c
>> +++ b/semihosting/arm-compat-semi.c
>> @@ -502,7 +502,7 @@ void do_common_semihosting(CPUState *cs)
>>    
>>        case TARGET_SYS_ISERROR:
>>            GET_ARG(0);
>> -        common_semi_set_ret(cs, (target_long)arg0 < 0);
>> +        common_semi_set_ret(cs, (int64_t)arg0 < 0);
>>            break;
>>    
>>        case TARGET_SYS_ISTTY:
> 
> Here we have a semantic change.  For 32-bit, we used get_user_u32, so this will always
> return false.
> 

Right... I'll add the intermediate missing cast based on 
is_64bit_semihosting(env).

Thanks,
Pierrick

> 
> r~