[Openmp-commits] [openmp] r304828 - Fix static initializers for locks.

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Tue Jun 6 13:24:41 PDT 2017


Author: jlpeyton
Date: Tue Jun  6 15:24:41 2017
New Revision: 304828

URL: http://llvm.org/viewvc/llvm-project?rev=304828&view=rev
Log:
Fix static initializers for locks.

Fix static initializers to use the proper unlocked value for the poll
field of the tas and futex locks.

Patch by Terry Wilmarth

Differential Revision: https://reviews.llvm.org/D33794

Modified:
    openmp/trunk/runtime/src/kmp_lock.h

Modified: openmp/trunk/runtime/src/kmp_lock.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_lock.h?rev=304828&r1=304827&r2=304828&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_lock.h (original)
+++ openmp/trunk/runtime/src/kmp_lock.h Tue Jun  6 15:24:41 2017
@@ -122,7 +122,8 @@ extern void __kmp_validate_locks(void);
 // ----------------------------------------------------------------------------
 
 struct kmp_base_tas_lock {
-  volatile kmp_int32 poll; // 0 => unlocked; locked: (gtid+1) of owning thread
+  // KMP_LOCK_FREE(tas) => unlocked; locked: (gtid+1) of owning thread
+  volatile kmp_int32 poll;
   kmp_int32 depth_locked; // depth locked, for nested locks only
 };
 
@@ -140,7 +141,7 @@ typedef union kmp_tas_lock kmp_tas_lock_
 //    kmp_tas_lock_t xlock = KMP_TAS_LOCK_INITIALIZER( xlock );
 #define KMP_TAS_LOCK_INITIALIZER(lock)                                         \
   {                                                                            \
-    { 0, 0 }                                                                   \
+    { KMP_LOCK_FREE(tas), 0 }                                                  \
   }
 
 extern int __kmp_acquire_tas_lock(kmp_tas_lock_t *lck, kmp_int32 gtid);
@@ -178,7 +179,7 @@ extern void __kmp_destroy_nested_tas_loc
 // ----------------------------------------------------------------------------
 
 struct kmp_base_futex_lock {
-  volatile kmp_int32 poll; // 0 => unlocked
+  volatile kmp_int32 poll; // KMP_LOCK_FREE(futex) => unlocked
   // 2*(gtid+1) of owning thread, 0 if unlocked
   // locked: (gtid+1) of owning thread
   kmp_int32 depth_locked; // depth locked, for nested locks only
@@ -199,7 +200,7 @@ typedef union kmp_futex_lock kmp_futex_l
 //    kmp_futex_lock_t xlock = KMP_FUTEX_LOCK_INITIALIZER( xlock );
 #define KMP_FUTEX_LOCK_INITIALIZER(lock)                                       \
   {                                                                            \
-    { 0, 0 }                                                                   \
+    { KMP_LOCK_FREE(futex), 0 }                                                \
   }
 
 extern int __kmp_acquire_futex_lock(kmp_futex_lock_t *lck, kmp_int32 gtid);




More information about the Openmp-commits mailing list