Re: Q: volatile struct elements or entire struct?
From: Chris Torek (nospam_at_torek.net)
Date: 09/23/04
- Next message: Barry Schwarz: "Re: Problem with DO-WHILE Loop"
- Previous message: Mabden: "Re: union access"
- In reply to: Mark A. Odell: "Q: volatile struct elements or entire struct?"
- Next in thread: Mark A. Odell: "Re: Q: volatile struct elements or entire struct?"
- Reply: Mark A. Odell: "Re: Q: volatile struct elements or entire struct?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 23 Sep 2004 00:07:17 GMT
In article <news:Xns956C9FD7F9153CopyrightMarkOdell@130.133.1.4>
Mark A. Odell <odellmark@hotmail.com> wrote:
[which of these should one use:]
>a) volatile on struct objects
>
>struct Foo {
> unsigned char command;
> unsigned char status;
> unsigned long baseAddr;
> unsigned long addrRange;
>}
>
>volatile struct Foo *pDevFoo = (some dev. address);
> struct Foo hostFoo;
This is the version I prefer, for several reasons, the most valid :-)
being the one shown right here in your example: you can make a
non-volatile version of it.
>b) volatile on struct members
>
>struct Foo
>{
> volatile unsigned char command;
> volatile unsigned char status;
> volatile unsigned long baseAddr;
> volatile unsigned long addrRange;
>}
>
>struct Foo *pDevFoo = (some dev. address);
>struct Foo hostFoo; /* live with extra accesses */
>
>Does my use of volatile in a) even do what I intend? That is, make
>accesses to the device volatile?
Yes. Both methods work (provided, of course, that your implementation's
definition of "volatile" does what you need in the first place --
if not, neither method works anyway!).
-- In-Real-Life: Chris Torek, Wind River Systems Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603 email: forget about it http://web.torek.net/torek/index.html Reading email is like searching for food in the garbage, thanks to spammers.
- Next message: Barry Schwarz: "Re: Problem with DO-WHILE Loop"
- Previous message: Mabden: "Re: union access"
- In reply to: Mark A. Odell: "Q: volatile struct elements or entire struct?"
- Next in thread: Mark A. Odell: "Re: Q: volatile struct elements or entire struct?"
- Reply: Mark A. Odell: "Re: Q: volatile struct elements or entire struct?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|