NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-arm/56839: GCC emits wrong codes for compare_and_swap_1 builtins



The following reply was made to PR port-arm/56839; it has been noted by GNATS.

From: Martin Husemann <martin%duskware.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: port-arm/56839: GCC emits wrong codes for compare_and_swap_1
 builtins
Date: Wed, 5 Feb 2025 11:50:18 +0100

 I am not convinced GCC is wrong here. The ABI says the caller needs to
 0-extend or sign-extend the sub-word value and pass it as a 32bit register
 value. So it all boils down to what the signature of the called function
 is - and unfortunately that seems to be poorly or not documented anywhere.
 
 But: gcc/dist/libgcc/config/arm/ implements the functions as taking
 signed values - so that would match the gcc generated call sites.
 
 #define SUBWORD_VAL_CAS(TYPE, WIDTH)                                    \
   TYPE HIDDEN                                                           \
   __sync_val_compare_and_swap_##WIDTH (TYPE *ptr, TYPE oldval,          \
                                        TYPE newval)                     \
 
 SUBWORD_VAL_CAS (short,       2)
 SUBWORD_VAL_CAS (signed char, 1)
 
 
 I think we need to make our functions match that (basically Nick's patch,
 plus maybe extensions to a few other functions).
 
 Martin
 


Home | Main Index | Thread Index | Old Index