This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
volatile with O2
- From: thomas joseph <thomascanny at yahoo dot co dot nz>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 21 Mar 2003 00:29:50 +1200 (NZST)
- Subject: volatile with O2
Hi All,
I have a small problem with volatile and O2.
I try to access device registers which are memory
mapped in to user space. When I try to read the
registers the application shows different values
from those of driver.
I defined all the necessary members as volatile. But
still it does not help. But when I inserted a
memory barrier before accessing those registers
I seem to be getting the correct values.
The code looks like this.
#define mb() __asm__ __volatile__ ("lock; addl $0,
0%%esp): : :"memory")
mb();
/* ulStatus is volatile unsigned long. */
regStatus = pIpRegs->ulStatus;
mb();
Basically I am not sure why I need to use mb()
in user space or Is it necessary for this kind of
an application ?
Or is the driver I am using is faulty. Actuall the
driver uses remap_page_range with page protection
flags set as __PAG_PCD | __PAGE_PWT, which
disables caching for the mapped area.
Could some body help me with this problem or if I
need to use any other compiler option pls inform me.
I tried -fvolatile as well. But it does not help.
Thanks and Regards,
--thomas
http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.