This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: switch question in recog.c


On Wed, Oct 08, 2003 at 12:38:54AM +0200, Michael Matz wrote:
> Hi,
> 
> On Tue, 7 Oct 2003, DJ Delorie wrote:
> 
> > > Constructed useless example (i.e. not the usual memcpy() unrolling):
> >
> > Duff's device wasn't a memcpy() unrolling.
> 
> See again http://www.lysator.liu.se/c/duffs-device.html commenting from
> Tom himself.  His initial posting was about the loop
> 	send(short *to, short *from, int count)
>         { do *to = *from++; while(--count>0); }
> 
> That's basically a memcpy().  I'm not old enough to know if Tom really is
> the inventor of this "use" of C features, but not even Tom remembers ;-)

It is not a memcpy(), but similar in structure. If it had been memcpy()
it would have been '*to++ = from++' instead of '*to = *from++'. Note
that the address written to never changes.
What the code does is write a buffer to some memory-mapped
I/O-register (pointed to by 'to').


-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]