From f1e89bc3407002bf7342326be7f9167d316fa624 Mon Sep 17 00:00:00 2001
From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 21 Jun 2006 08:59:44 +0000
Subject: [PATCH] 	* critical.c (GOMP_critical_name_start): Fix *pptr
 initialization 	when gomp_mutex_t is larger than pointer and
 HAVE_SYNC_BUILTINS is 	defined.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114843 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog  | 6 ++++++
 libgomp/critical.c | 6 ++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index dc86f86bdac5..8cd5519f404d 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,9 @@
+2006-06-21  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.
+
 2006-06-20  Jakub Jelinek  <jakub@redhat.com>
 
 	PR libgomp/26175
diff --git a/libgomp/critical.c b/libgomp/critical.c
index 70159ec7a6ed..90821634b5e9 100644
--- a/libgomp/critical.c
+++ b/libgomp/critical.c
@@ -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;
-- 
GitLab