At 1:27 PM -0800 2/27/02, Julian Elischer wrote:
>There are saveral places (e.g. if_ie.c) where data
>is copied out of a buffer that is shared with the hardware.
>The pointer to this is correctly labelled as "volatile", though
>at the time we will copy the data out we know it to be stable.

Note:   "at the time we will copy the data ... we know"

>A while ago I proposed the following patch:
>  * Note: the "volatile" below does not REQUIRE that the argument be
>  * volatile, but rather ony says that it is OK to use a volatile * i
>  * there. Same for the const. I know a const volatile sounds strange
>  * but it only indicates that either is acceptable.
>  */
>void    bcopy __P((volatile const void *from, volatile void *to,
>            size_t len));

This will always allow bcopy to do the copy to or from any volatile
location, even if the call is done at a bad time.  Any programmer
calling bcopy should at least get a little flag waved at them if
they are working with volatile arguments.

How philosophically sickening would it be to create a macro:

#define bcopy_volatile(x,y) bcopy((casts)x,(casts)y)

so that you can have cleaner-looking source code, but still have
it so the programmer has to *explicitly* say "Yes, I know I am
dealing with volatile memory here".

Garance Alistair Drosehn            =   [EMAIL PROTECTED]
Senior Systems Programmer           or  [EMAIL PROTECTED]
Rensselaer Polytechnic Institute    or  [EMAIL PROTECTED]

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to