NetBSD-Bugs archive

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

Re: port-sh3/60773: sh3 __sync_val_compare_and_swap_1 test failures



Maybe we should just close this as a duplicate of PR 56839 (GCC emits
wrong codes for compare_and_swap_1 bultins on armv5 (el & eb))?

The same issue is turning up on sparc:

FAILED: /tmp/build/2026.09.22.23.22.21-sparc/src/tests/lib/libc/atomic/t___sync_compare_and_swap.c:189: successful case: res expects 0x88 but 0xffffff88

https://releng.netbsd.org/b5reports/sparc/2026/2026.09.22.23.22.21/test.html#lib_libc_atomic_t___sync_compare_and_swap___sync_val_compare_and_swap_1

But not on any other architectures I checked.

> Date: Thu, 24 Sep 2026 03:18:03 +0300
> From: Valery Ushakov <uwe%stderr.spb.ru@localhost>
> 
> PS: Please, can someone write a manual page for these?  It's scores of
> function names that all look alike with a sprinkle of scrabble bag
> spillover randomly glued in unexpected places.

If we do that, we will still have to be careful to distinguish:

(a) the compiler builtins that gcc/clang recognize
from
(b) the elf library symbols that gcc/clang generate calls to.

And I suspect they are not the same...

> gcc info only talks about "__sync_val_compare_and_swap" and refers to
> Intel's Itanium psABI, which is probably printed on fine leafs of
> unobtanium (if you are lucky - with a microfiche copy on archive.org
> w/out an OCR layer).  Anyway, finding this information shouldn't be a
> wild goose chase or an exercise in RTFS and repo archeology.

Didn't seem too hard to find a plausible referent with a web search
for `intel itanium psabi':

https://refspecs.linuxfoundation.org/elf/IA64-SysV-psABI.pdf

We should archive this ourselves, and at least link to it from
<https://wiki.NetBSD.org/abi>.

Unfortunately, it is not entirely clear on signedness, also appears to
be more about the compiler builtins than the elf library symbols
judging by the ellipsis part...  (I also have no idea what the
sentence about the ellipsis is supposed to mean!)

    7.4.3 Atomic Compare-and-swap Operation

    "int __sync_bool_compare_and_swap (type* ptr, type oldvalue, type
     newvalue, ...)"

    "type __sync_val_compare_and_swap (type* ptr, type oldvalue, type
     newvalue, ...)"

    Where type may be one of int, long, long long, unsigned int,
    unsigned long, unsigned long long.  The ellipsis (...) refers to
    an optional list of variables protected by the memory barrier.

I just did a quick search for the string `__sync_val'; perhaps if you
actually read the rest of the document it will say how the symbols are
supposed to be defined.

But I bet it's just ambiguous and got randomly chosen differently on
different architectures for gcc's codegen.



Home | Main Index | Thread Index | Old Index