[cfe-dev] Theoretical question: Duff's device and AST
Filipe Cabecinhas
filcab at gmail.com
Sat Jul 19 17:07:51 PDT 2008
On 19 Jul, 2008, at 22:23, Jesper wrote:
>
> int n = (count + 7) / 8;
> switch (count % 8) {
> case 0: do { *to = *from++;
> case 7: *to = *from++;
> case 6: *to = *from++;
> case 5: *to = *from++;
> case 4: *to = *from++;
> case 3: *to = *from++;
> case 2: *to = *from++;
> case 1: *to = *from++;
> } while (--n > 0);
> }
>
> Obviously, with memcpy, no one really needs to use it, but it is
> nonetheless part of the C language that clang endeavors to cover, and
> may be part of programs that clang will be asked to compile or
> pretty-print. I'm interested purely academically in what the answer
> might be.
>
Why would you think that, with memcpy, you would have no need for
duff's device?
As you can see from the code you posted, the 'to' pointer is never
changed. Normally one would use duff's device with memory mapped IO,
not with memory-to-memory tranfers :-)
- Filipe Cabecinhas
More information about the cfe-dev
mailing list