This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: instruction sync -- need to preserve order


Rayson Ho <raysonlogin@yahoo.com> writes:

> Hi,
> 
> How can I make sure that gcc does not schedule instructions across a
> memory barrier?? I am porting a threads library from AIX to PPC Linux,
> and on AIX, the compiler has a build-in instruction that allows me to
> do that.

What you really want to do is specify to GCC that the memory barrier
affects memory, like this (assuming the barrier you're using is the
"sync" instruction):

  asm ("sync" : : : "memory");

Instructions that don't affect memory will still be scheduled across
it, but memory will be consistent.

-- 
- Geoffrey Keating <geoffk@geoffk.org> <geoffk@redhat.com>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]