[openib-general] Re: registering read-only memory
Michael S. Tsirkin
mst at mellanox.co.il
Mon May 23 09:01:58 PDT 2005
Quoting r. Roland Dreier <roland at topspin.com>:
> Subject: Re: registering read-only memory
>
> Michael> What about the patch that I posted?
>
> Adding the "const" makes sense but adding "volatile" doesn't seem good
> to me.
Could you explain why? Since the library never accesses the data, it has no
effect except turning off a warning.
Volatile says like "this buffer can change without the application
writing there", and thats what we have with hardware writing there, no?
> I think it's better for the tiny subset of people who really
> need "volatile" to add casts.
>
> - R.
>
IMO, you cant always do this. If you have a non-volatile variable and cast
it to a volatile pointer, compiler is permitted to detect
this and ignore the volatile attribute, making the code
that polls data incorrect (I'm not claiming gcc is smart enough to do
this, though).
--
MST - Michael S. Tsirkin
More information about the general
mailing list