8ae002
commit b023e4ca99f5e81f90d87d23cd267ef2abd2388c
8ae002
Author: Andi Kleen <ak@linux.intel.com>
8ae002
Date:   Sat Dec 22 00:58:34 2012 -0800
8ae002
8ae002
    Add new internal mutex type flags for elision.
8ae002
    
8ae002
    Add Enable/disable flags used internally
8ae002
    
8ae002
    Extend the mutex initializers to have the fields needed for
8ae002
    elision. The layout stays the same, and this is not visible
8ae002
    to programs.
8ae002
    
8ae002
    These changes are not exposed outside pthread
8ae002
Index: glibc-2.17-c758a686/nptl/pthreadP.h
8ae002
===================================================================
8ae002
--- glibc-2.17-c758a686.orig/nptl/pthreadP.h
8ae002
+++ glibc-2.17-c758a686/nptl/pthreadP.h
8ae002
@@ -61,6 +61,10 @@
8ae002
 enum
8ae002
 {
8ae002
   PTHREAD_MUTEX_KIND_MASK_NP = 3,
8ae002
+
8ae002
+  PTHREAD_MUTEX_ELISION_NP    = 256,
8ae002
+  PTHREAD_MUTEX_NO_ELISION_NP = 512,
8ae002
+
8ae002
   PTHREAD_MUTEX_ROBUST_NORMAL_NP = 16,
8ae002
   PTHREAD_MUTEX_ROBUST_RECURSIVE_NP
8ae002
   = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_RECURSIVE_NP,
8ae002
@@ -93,12 +97,21 @@ enum
8ae002
   PTHREAD_MUTEX_PP_ERRORCHECK_NP
8ae002
   = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ERRORCHECK_NP,
8ae002
   PTHREAD_MUTEX_PP_ADAPTIVE_NP
8ae002
-  = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ADAPTIVE_NP
8ae002
+  = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ADAPTIVE_NP,
8ae002
+  PTHREAD_MUTEX_ELISION_FLAGS_NP
8ae002
+  = PTHREAD_MUTEX_ELISION_NP | PTHREAD_MUTEX_NO_ELISION_NP,
8ae002
+
8ae002
+  PTHREAD_MUTEX_TIMED_ELISION_NP =
8ae002
+	  PTHREAD_MUTEX_TIMED_NP | PTHREAD_MUTEX_ELISION_NP,
8ae002
+  PTHREAD_MUTEX_TIMED_NO_ELISION_NP =
8ae002
+	  PTHREAD_MUTEX_TIMED_NP | PTHREAD_MUTEX_NO_ELISION_NP,
8ae002
 };
8ae002
 #define PTHREAD_MUTEX_PSHARED_BIT 128
8ae002
 
8ae002
 #define PTHREAD_MUTEX_TYPE(m) \
8ae002
   ((m)->__data.__kind & 127)
8ae002
+#define PTHREAD_MUTEX_TYPE_ELISION(m) \
8ae002
+  ((m)->__data.__kind & (127|PTHREAD_MUTEX_ELISION_FLAGS_NP))
8ae002
 
8ae002
 #if LLL_PRIVATE == 0 && LLL_SHARED == 128
8ae002
 # define PTHREAD_MUTEX_PSHARED(m) \
8ae002
Index: glibc-2.17-c758a686/nptl/sysdeps/pthread/pthread.h
8ae002
===================================================================
8ae002
--- glibc-2.17-c758a686.orig/nptl/sysdeps/pthread/pthread.h
8ae002
+++ glibc-2.17-c758a686/nptl/sysdeps/pthread/pthread.h
8ae002
@@ -83,27 +83,39 @@ enum
8ae002
 
8ae002
 
8ae002
 /* Mutex initializers.  */
8ae002
+#if __PTHREAD_MUTEX_HAVE_ELISION == 1 /* 64bit layout.  */
8ae002
+#define __PTHREAD_SPINS 0, 0
8ae002
+#elif __PTHREAD_MUTEX_HAVE_ELISION == 2 /* 32bit layout.  */
8ae002
+#define __PTHREAD_SPINS { 0, 0 }
8ae002
+#else
8ae002
+#define __PTHREAD_SPINS 0
8ae002
+#endif
8ae002
+
8ae002
 #ifdef __PTHREAD_MUTEX_HAVE_PREV
8ae002
 # define PTHREAD_MUTEX_INITIALIZER \
8ae002
-  { { 0, 0, 0, 0, 0, 0, { 0, 0 } } }
8ae002
+  { { 0, 0, 0, 0, 0, __PTHREAD_SPINS, { 0, 0 } } }
8ae002
 # ifdef __USE_GNU
8ae002
 #  define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
8ae002
-  { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { 0, 0 } } }
8ae002
+  { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }
8ae002
 #  define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
8ae002
-  { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { 0, 0 } } }
8ae002
+  { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, __PTHREAD_SPINS, { 0, 0 } } }
8ae002
 #  define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
8ae002
-  { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { 0, 0 } } }
8ae002
+  { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }
8ae002
+#  define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
8ae002
+  { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }
8ae002
+
8ae002
 # endif
8ae002
 #else
8ae002
 # define PTHREAD_MUTEX_INITIALIZER \
8ae002
-  { { 0, 0, 0, 0, 0, { 0 } } }
8ae002
+  { { 0, 0, 0, 0, 0, { __PTHREAD_SPINS } } }
8ae002
 # ifdef __USE_GNU
8ae002
 #  define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
8ae002
-  { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { 0 } } }
8ae002
+  { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { __PTHREAD_SPINS } } }
8ae002
 #  define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
8ae002
-  { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { 0 } } }
8ae002
+  { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { __PTHREAD_SPINS } } }
8ae002
 #  define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
8ae002
-  { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { 0 } } }
8ae002
+  { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { __PTHREAD_SPINS } } }
8ae002
+
8ae002
 # endif
8ae002
 #endif
8ae002