Path: utzoo!attcan!uunet!husc6!bloom-beacon!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP (der Mouse) Newsgroups: comp.lang.c Subject: Re: volatile Message-ID: <1111@mcgill-vision.UUCP> Date: 18 May 88 07:36:32 GMT References: <20345@pyramid.pyramid.com> <502@wsccs.UUCP> <51431@sun.uucp> <526@wsccs.UUCP> Organization: McGill University, Montreal Lines: 54 Posted: Wed May 18 03:36:32 1988 In article <526@wsccs.UUCP>, terry@wsccs.UUCP (Every system needs one) writes: > All I'm saying, again and again and again, is that the compiler > writer, not the compiler user should bear the burden of matching the > language to the architecture. I have agreed before that volitile is > OK for DMA where the user prefers to use a buzz-loop instead of an > interrupt. Say a message passing operating system. Or for emptying a serial line card silo into the user's buffer....what happens to for (count=sludevice->wcr;count>0;count--) { *bufptr++ = sludevice->recvbuf; } when the optimizer rewrites it to temp = sludevice->recvbuf; for (count=sludevice->wcr;count>0;count--) { *bufptr++ = temp; } Or are you intending to prohibit such an optimization altogether? Then sorry, you'll be left in the dust. The compiler simply doesn't have enough information to guess whether sludevice points to a memory-mapped device or not! > I don't believe in impossible; just very very hard and requiring > intelligent thought. Ah, you expect the compiler to notice that the file it's compiling happens to look something like a device driver, this struct pointer variable name ends in "device", therefore it should be treated as volatile? Good luck trying to convince your compiler vendor. >> Compiler technology is getting really good, and we need a way to >> tell the optimisers that strange things can happen. > If it's sooooo advanced, it could determine volatility (or aliasing) > without me having to tell it. This is my entire point. If it isn't > that advanced, it should either quit pretending or be fixed. There's an intermediate stage. Compiler technology is good enough to do some serious optimizations if it's told what's volatile. It is not good enough to figure out what's volatile and what isn't (I don't expect it to be, either, not before we have serious (Turing-capable) artifical intelligence). Since joe programmer writing matrix inversion routines (say) can completely ignore volatile and get all the optimizations, we put up with making the few who write code that uses signals or memory-mapped devices or shared memory or other things that more-or-less require volatile use volatile. der Mouse uucp: mouse@mcgill-vision.uucp arpa: mouse@larry.mcrcim.mcgill.edu