diff options
author | fischman@webrtc.org <fischman@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2013-11-04 19:06:08 +0000 |
---|---|---|
committer | fischman@webrtc.org <fischman@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2013-11-04 19:06:08 +0000 |
commit | 690a03c8ddbb9ab1a0adc69f7580200db1064817 (patch) | |
tree | b309b8ae0d35f79aac15242763df7f987d92cf30 | |
parent | 1bd9a7bae6ce165d499855a1f4baeca0c65ba6b4 (diff) | |
download | webrtc-690a03c8ddbb9ab1a0adc69f7580200db1064817.tar.gz |
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
-rw-r--r-- | modules/audio_device/android/single_rw_fifo.cc | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/modules/audio_device/android/single_rw_fifo.cc b/modules/audio_device/android/single_rw_fifo.cc index 29a13517..d65ab9fb 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 webrtc { 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 @@ inline void MemoryBarrier() { ((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) |