M
Mark A. Odell
If I have a structure that may point to a volatile "region (e.g. device)"
or a context in memory what would be the best way to use the volatile
keyword?
E.g.
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;
- or -
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?
Thanks.
or a context in memory what would be the best way to use the volatile
keyword?
E.g.
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;
- or -
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?
Thanks.