New atomic functions on Sparc

I’m not quite sure I understand what’s happening here, but the following test (which derives from GCC tests) isn’t working for Sparc. Could anyone explain what’s happening and, if possible where the fix might lie in the new atomics code for Sparc? I’m not too sure what to do with this right now. I’ll open a bug if this turns out to be a genuine bug, but right now, I’m not sure it is.

The code aborts on the test, which is a failure.

#include <stdio.h>
extern void abort(void);

char v = 0;
char expected = 0;
char max = ~0;

#define STRONG 0

int main ()
{
__atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED);
__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED);
if (!__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE))
{
printf (“Error: Values for v=%d, expected=%d\n”, (int) v, (int) expected);
abort ();
}

return 0;
}

I assume you're compiling for sparcv9? Atomics of sizes != 4 or 8 bytes are
just completely busted at the moment. This is on my list of things to fix
in the near future.