diff --git a/zookeeper-3.4.5-atomic.patch b/zookeeper-3.4.5-atomic.patch
new file mode 100644
index 0000000..570a0ff
--- /dev/null
+++ b/zookeeper-3.4.5-atomic.patch
@@ -0,0 +1,32 @@
+diff -up zookeeper-3.4.5/src/c/src/mt_adaptor.c.atomic zookeeper-3.4.5/src/c/src/mt_adaptor.c
+--- zookeeper-3.4.5/src/c/src/mt_adaptor.c.atomic 2013-06-14 09:58:27.000000000 +0200
++++ zookeeper-3.4.5/src/c/src/mt_adaptor.c 2013-06-14 10:00:09.000000000 +0200
+@@ -482,27 +482,7 @@ int32_t inc_ref_counter(zhandle_t* zh,in
+
+ int32_t fetch_and_add(volatile int32_t* operand, int incr)
+ {
+-#ifndef WIN32
+- int32_t result;
+- asm __volatile__(
+- "lock xaddl %0,%1\n"
+- : "=r"(result), "=m"(*(int *)operand)
+- : "0"(incr)
+- : "memory");
+- return result;
+-#else
+- volatile int32_t result;
+- _asm
+- {
+- mov eax, operand; //eax = v;
+- mov ebx, incr; // ebx = i;
+- mov ecx, 0x0; // ecx = 0;
+- lock xadd dword ptr [eax], ecx;
+- lock xadd dword ptr [eax], ebx;
+- mov result, ecx; // result = ebx;
+- }
+- return result;
+-#endif
++ return __atomic_add_fetch(operand, incr, __ATOMIC_SEQ_CST);
+ }
+
+ // make sure the static xid is initialized before any threads started
diff --git a/zookeeper.spec b/zookeeper.spec
index d2797f1..b12ed5c 100644
--- a/zookeeper.spec
+++ b/zookeeper.spec
@@ -1,7 +1,7 @@
%global _hardened_build 1
Name: zookeeper
Version: 3.4.5
-Release: 5%{?dist}
+Release: 6%{?dist}
Summary: A high-performance coordination service for distributed applications
Group: Development/Libraries
License: ASL 2.0 and BSD
@@ -20,6 +20,7 @@ Patch2: %{name}-3.4.5-zktreeutil-gcc.patch
Patch3: %{name}-3.4.5-disable-cygwin-detection.patch
Patch4: %{name}-3.4.5-build-contrib.patch
Patch5: %{name}-3.4.5-add-PIE-and-RELRO.patch
+Patch6: %{name}-3.4.5-atomic.patch
BuildRequires: autoconf
BuildRequires: automake
@@ -144,6 +145,7 @@ find -name "*.dll" -delete
%patch3 -p0
%patch4 -p1
%patch5 -p1
+%patch6 -p1
sed -i "s|pom|jar|" dist-maven/%{name}-%{version}.pom
sed -i "s|checkstyle|com.puppycrawl.tools|" dist-maven/%{name}-%{version}.pom
@@ -305,6 +307,9 @@ find %{buildroot} -name '*.la' -exec rm -f {} ';'
%doc LICENSE.txt NOTICE.txt src/contrib/zkpython/README
%changelog
+* Fri Jun 14 2013 Dan Horák - 3.4.5-6
+- use fetch_and_add from GCC, fixes build on non-x86 arches
+
* Tue Jun 11 2013 gil cattaneo 3.4.5-5
- fixed zookeeper.so non-standard-executable-perm thanks to Björn Esser