From 2d1a45ccb1e19521f6c9741e0a864b6fed22e8f7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Wed, 25 Feb 2015 17:21:25 +0100
Subject: [PATCH] glibc: explicitly disable lock elision support, patch from
 Fedora.

The lock elision support in glibc has a runtime check even if the build
option is disabled. This patch from Fedora completely disables that
check if the build option is disabled, and we disable this now.
---
 .../glibc-disable-rwlock-elision.patch        | 24 +++++++++++++++++++
 srcpkgs/glibc/template                        |  3 ++-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/glibc/patches/glibc-disable-rwlock-elision.patch

diff --git a/srcpkgs/glibc/patches/glibc-disable-rwlock-elision.patch b/srcpkgs/glibc/patches/glibc-disable-rwlock-elision.patch
new file mode 100644
index 00000000000..c161393f4a0
--- /dev/null
+++ b/srcpkgs/glibc/patches/glibc-disable-rwlock-elision.patch
@@ -0,0 +1,24 @@
+Taken from Fedora, disable the lock elision run time check if it's not enabled
+at build time.
+
+--- sysdeps/unix/sysv/linux/x86/elision-conf.c	2014-09-27 00:25:46.443462345 -0400
++++ sysdeps/unix/sysv/linux/x86/elision-conf.c	2014-09-27 00:29:53.586615813 -0400
+@@ -62,12 +62,16 @@
+ 	      char **argv  __attribute__ ((unused)),
+ 	      char **environ)
+ {
+-  __elision_available = HAS_RTM;
+ #ifdef ENABLE_LOCK_ELISION
++  __elision_available = HAS_RTM;
+   __pthread_force_elision = __libc_enable_secure ? 0 : __elision_available;
+-#endif
+   if (!HAS_RTM)
+     __elision_aconf.retry_try_xbegin = 0; /* Disable elision on rwlocks */
++#else
++  __elision_available = 0;
++  __pthread_force_elision = 0;
++  __elision_aconf.retry_try_xbegin = 0;
++#endif
+ }
+ 
+ #ifdef SHARED
diff --git a/srcpkgs/glibc/template b/srcpkgs/glibc/template
index 9f9da1c5fde..a298eed628f 100644
--- a/srcpkgs/glibc/template
+++ b/srcpkgs/glibc/template
@@ -1,7 +1,7 @@
 # Template file for 'glibc'
 pkgname=glibc
 version=2.21
-revision=2
+revision=3
 bootstrap=yes
 short_desc="The GNU C library"
 maintainer="Juan RP <xtraeme@gmail.com>"
@@ -80,6 +80,7 @@ do_configure() {
 		--disable-profile --enable-kernel=2.6.32 \
 		--enable-stack-guard-randomization \
 		--without-selinux --without-cvs --without-gd \
+		--disable-lock-elision \
 		libc_cv_rootsbindir=/usr/sbin \
 		libc_cv_rtlddir=${_libdir} libc_cv_slibdir=${_libdir}
 }