Path: utzoo!attcan!uunet!lll-winken!lll-tis!oodis01!uplherc!sp7040!obie!wsccs!terry From: terry@wsccs.UUCP (Every system needs one) Newsgroups: comp.lang.c Subject: Re: volatile: a summary Summary: The shadow knows... why can't the compiler? Message-ID: <580@wsccs.UUCP> Date: 14 Jun 88 02:10:36 GMT References: <11837@mimsy.UUCP> <3811@pasteur.Berkeley.Edu> Lines: 42 In article <3811@pasteur.Berkeley.Edu>, faustus@ic.Berkeley.EDU (Wayne A. Christopher) writes: > In article <11837@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes: > > Is the [volatile] keyword necessary? > > > > A perfect compiler would know as much as all its programmers combined, > > and could use whatever rules those programmers would use to detect > > `real volatility'. Yes yes yes. > The problem is that these rules may be in the manual for the graphics > board the programmer is writing a driver for. Say there are two memory > mapped registers, "model_number" and "time_of_day", declared as > > int *model_number = (int *) 0xf0; /* Shouldn't be volatile. */ > int *time_of_day = (int *) 0ff4; /* Should be volatile. */ > > model_number will never change, but time_of_day will. How is the compiler > going to tell the difference, without volatile? No no no. The compiler will know because, as part of the board installation, you will tell it... or we could make a hardware-standard (I know; too much to ask for) method of asking it. The machine should "know" about the machine. How can you possibly expect it to know if you don't tell it ("how can you have any pudding if you don't eat your meat?"). The question raised by your new board is whether "volitility" will be defined in an installation dependant way by the programmer, or in an installation independant way by the installer. We have a great deal of hardware-specific kernel information already there... what's the point in providing yet another method of making "magic" numbers "known" to the computer via "volitile" in the compiler when it is just as easily done by reference to a device configuration file? This file would not only be useful to the compiler, it would allow configuration, and possibly even machine independant installation of drivers and devices. | Terry Lambert UUCP: ...{ decvax, ihnp4 } ...utah-cs!century!terry | | @ Century Software OR: ...utah-cs!uplherc!sp7040!obie!wsccs!terry | | SLC, Utah | | These opinions are not my companies, but if you find them | | useful, send a $20.00 donation to Brisbane Australia... | | 'Signatures; it's not how long you make them, it's how you make them long!' |