Fix broken build on x86 Android
BUG=2545
R=fischman@webrtc.org, henrike@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/3019004

Patch from Lu Quiang <qiang.lu@intel.com>.

git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@5081 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/modules/audio_device/android/single_rw_fifo.cc b/modules/audio_device/android/single_rw_fifo.cc
index 29a1351..d65ab9f 100644
--- a/modules/audio_device/android/single_rw_fifo.cc
+++ b/modules/audio_device/android/single_rw_fifo.cc
@@ -10,11 +10,6 @@
 
 #include "webrtc/modules/audio_device/android/single_rw_fifo.h"
 
-#if !defined(__ARMEL__)
-// ARM specific due to the implementation of MemoryBarrier.
-#error trying to compile ARM code for non-ARM target
-#endif
-
 static int UpdatePos(int pos, int capacity) {
   return (pos + 1) % capacity;
 }
@@ -23,6 +18,7 @@
 
 namespace subtle {
 
+#if defined(__ARMEL__)
 // From http://src.chromium.org/viewvc/chrome/trunk/src/base/atomicops_internals_arm_gcc.h
 // Note that it is only the MemoryBarrier function that makes this class arm
 // specific. Borrowing other MemoryBarrier implementations, this class could
@@ -34,6 +30,20 @@
   ((KernelMemoryBarrierFunc)0xffff0fa0)();
 }
 
+#elif defined(__x86_64__) || defined (__i386__)
+// From http://src.chromium.org/viewvc/chrome/trunk/src/base/atomicops_internals_x86_gcc.h
+// mfence exists on x64 and x86 platforms containing SSE2.
+// x86 platforms that don't have SSE2 will crash with SIGILL.
+// If this code needs to run on such platforms in the future,
+// add runtime CPU detection here.
+inline void MemoryBarrier() {
+  __asm__ __volatile__("mfence" : : : "memory");
+}
+
+#else
+#error Add an implementation of MemoryBarrier() for this platform!
+#endif
+
 }  // namespace subtle
 
 SingleRwFifo::SingleRwFifo(int capacity)