http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55561



--- Comment #28 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> 
2013-01-01 17:13:39 UTC ---

(In reply to comment #26)

> For config/linux/ptrlock the changes are:

> [...]



Following your suggestions, I applied the following patch (mistakes are mine),

which allows me to run without warnings from libgomp:



Index: config/linux/wait.h

===================================================================

--- config/linux/wait.h (revision 194730)

+++ config/linux/wait.h (working copy)

@@ -51,7 +51,7 @@

   if (__builtin_expect (gomp_managed_threads > gomp_available_cpus, 0))

     count = gomp_throttled_spin_count_var;

   for (i = 0; i < count; i++)

-    if (__builtin_expect (*addr != val, 0))

+    if (__builtin_expect (__atomic_load_n(addr,MEMMODEL_RELAXED) != val, 0))

       return 0;

     else

       cpu_relax ();

Index: config/linux/ptrlock.c

===================================================================

--- config/linux/ptrlock.c      (revision 194730)

+++ config/linux/ptrlock.c      (working copy)

@@ -50,9 +50,9 @@

 #endif

   do

     do_wait (intptr, 2);

-  while (*intptr == 2);

+  while (__atomic_load_n(intptr, MEMMODEL_RELAXED) == 2);

   __asm volatile ("" : : : "memory");

-  return *ptrlock;

+  return (void*)__atomic_load_n(ptrlock, MEMMODEL_ACQUIRE);

 }



 void

Index: config/linux/ptrlock.h

===================================================================

--- config/linux/ptrlock.h      (revision 194730)

+++ config/linux/ptrlock.h      (working copy)

@@ -48,8 +48,9 @@

 {

   uintptr_t oldval;



-  if ((uintptr_t) *ptrlock > 2)

-    return *ptrlock;

+  uintptr_t v = (uintptr_t)__atomic_load_n(ptrlock, MEMMODEL_ACQUIRE);

+  if (v > 2)

+    return (void*)v;



   oldval = 0;

   if (__atomic_compare_exchange_n (ptrlock, &oldval, 1, false,

Reply via email to