[llvm-dev] New atomic functions on Sparc

Chris.Dewhurst via llvm-dev llvm-dev at lists.llvm.org
Fri Apr 1 09:41:55 PDT 2016


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;
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160401/8596e3d0/attachment.html>


More information about the llvm-dev mailing list