[PATCH] Fix GOMP_critical_name_start

Jakub Jelinek jakub@redhat.com
Mon Jun 19 16:36:00 GMT 2006


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



More information about the Gcc-patches mailing list