This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix GOMP_critical_name_start


Hi!

--disable-linux-futex critical failed omp_parse{2,4}.f90 tests.
The code apparently was expecting __sync_val_compare_and_swap to return
the *pptr value after the atomic operation, not before.

Ok for trunk?

2006-06-19  Jakub Jelinek  <jakub@redhat.com>

	* critical.c (GOMP_critical_name_start): Fix *pptr initialization
	when gomp_mutex_t is larger than pointer and HAVE_SYNC_BUILTINS is
	defined.

--- libgomp/critical.c.jj	2006-01-27 08:31:16.000000000 +0100
+++ libgomp/critical.c	2006-06-19 17:56:16.000000000 +0200
@@ -72,12 +72,14 @@ GOMP_critical_name_start (void **pptr)
 	  gomp_mutex_t *nlock = gomp_malloc (sizeof (gomp_mutex_t));
 	  gomp_mutex_init (nlock);
 
-	  plock = __sync_val_compare_and_swap (pptr, plock, nlock);
-	  if (plock != nlock)
+	  plock = __sync_val_compare_and_swap (pptr, NULL, nlock);
+	  if (plock != NULL)
 	    {
 	      gomp_mutex_destroy (nlock);
 	      free (nlock);
 	    }
+	  else
+	    plock = nlock;
 #else
 	  gomp_mutex_lock (&create_lock_lock);
 	  plock = *pptr;

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]