File powerpc-elision-enable-envvar.patch of Package glibc

2016-02-11  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>

	* sysdeps/unix/sysv/linux/powerpc/elision-conf.c
	(elision_init): Further restrict enablement based
	on whether GLIBC_ELISION_ENABLE=yes is in the env.
---
 sysdeps/unix/sysv/linux/powerpc/elision-conf.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Index: glibc-2.22/sysdeps/unix/sysv/linux/powerpc/elision-conf.c
===================================================================
--- glibc-2.22.orig/sysdeps/unix/sysv/linux/powerpc/elision-conf.c
+++ glibc-2.22/sysdeps/unix/sysv/linux/powerpc/elision-conf.c
@@ -21,6 +21,7 @@
 #include <elision-conf.h>
 #include <unistd.h>
 #include <dl-procinfo.h>
+#include <string.h>
 
 /* Reasonable initial tuning values, may be revised in the future.
    This is a conservative initial value.  */
@@ -61,7 +62,18 @@ elision_init (int argc __attribute__ ((u
 {
 #ifdef ENABLE_LOCK_ELISION
   int elision_available = (GLRO (dl_hwcap2) & PPC_FEATURE2_HAS_HTM) ? 1 : 0;
-  __pthread_force_elision = __libc_enable_secure ? 0 : elision_available;
+
+  /* Scan the environment and conditionally enable TLE.  */
+  if (elision_available != 0 && __libc_enable_secure == 0)
+    {
+      for ( ; *environ != NULL; environ++)
+	  if (**environ == 'G' &&
+	      strcmp (*environ,"GLIBC_ELISION_ENABLE=yes") == 0)
+	    {
+	      __pthread_force_elision = elision_available;
+	      break;
+	    }
+    }
 #endif
   if (!__pthread_force_elision)
     /* Disable elision on rwlocks.  */