This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Can I force a word read-modify-write instread of a byte write?
- From: Ian Lance Taylor <iant at google dot com>
- To: "Phil Endecott" <spam_from_gcc_help at chezphil dot org>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: 02 Jul 2007 09:55:10 -0700
- Subject: Re: Can I force a word read-modify-write instread of a byte write?
- References: <1183370633557@dmwebmail.belize.chezphil.org>
"Phil Endecott" <spam_from_gcc_help@chezphil.org> writes:
> I know that in some circumstances gcc will generate read-modify-write
> sequences to access memory locations, for example if I have a bitfield
> struct. Is there a way in which I can tell it to only do (32-bit)
> word writes to a region of memory, and to do read-modify-write
> sequences instead of byte writes, even though the processor does have
> byte write instructions?
Sure, this is what the volatile qualifier is for. If you always
access the memory through volatile qualified pointers, the compiler
will always access the memory precisely as you write in the program.
This is one of the few cases where volatile is actually useful.
Ian