Re: [LAD] Atomic Operations

From: Olivier Guilyardi <list@email-addr-hidden>
Date: Thu Dec 17 2009 - 15:56:43 EET

On 12/17/2009 01:03 PM, Tim Blechmann wrote:
>> +#if defined(__APPLE__)
>> +#include <libkern/OSAtomic.h>
>> +#define MEMORY_BARRIER() OSMemoryBarrier()
>> +#elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
>> +#define MEMORY_BARRIER() __sync_synchronize()
>> +#else
>> +#warning SMP Danger: memory barriers are not supported on this system
>> +#endif
>
> there was a buggy gcc version, that didn't implement
> __sync_synchronize() correctly on x86, causing errors on nehalem
> machines (which don't have a shared cache).

There also are bugs on ARM, x86-64, etc..

> if sse is enabled, _mm_mfence() can be used to work around this compiler
> bug ...

IMO, it's the compiler job to figure how to implement a memory barrier.
Otherwise, we're going to end up with a 200 lines macro def, with a workaround
for this, a workaround for that,... GCC devs are more competent for this I
think, and will keep it up-to-date.

--
  Olivier
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
Received on Thu Dec 17 16:15:06 2009

This archive was generated by hypermail 2.1.8 : Thu Dec 17 2009 - 16:15:06 EET